benjojo / de-ip-hdmi

Convert a IP HDMI converter into a MKV stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't build working code

AdamLaurie opened this issue · comments

Hi, I'm new to go so sorry if this is a really dumb question, but do I have to do something special to create a binary prog from main.go? I've tried what seems to be the obvious choice: "go build main.go" but the resulting binary executes but doesn't actually work (the sender never starts streaming). The ready built package for Ubuntu/Debian works fine so I know my kit is all wired up correctly...

So the .deb I provided works fine, but when you build for yourself it doesnt?

Odd.

I just use

"go get -v"
"go build -v"

I assume you are using the latest .deb I have posted?

Yes, that's the situation. Here are two sessions - first, building and running, then running the installed .deb. As you can see, the first fails and the second one works:

addy@blap:de-ip-hdmi$ go build -v
_/home/software/unpacked/de-ip-hdmi
addy@blap:de-ip-hdmi$ sudo ./de-ip-hdmi -interface enx0050b64d263a
ffmpeg version 2.7.6-0ubuntu0.15.10.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
^C[mjpeg @ 0x25f3c80] No JPEG data found in image
[mjpeg @ 0x25eb2c0] decoding for stream 0 failed
[mjpeg @ 0x25eb2c0] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
/tmp/hdmi-Vfifo-GHZPk: could not find codec parameters
Input #0, mjpeg, from '/tmp/hdmi-Vfifo-GHZPk':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 25 tbr, 1200k tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, s32be, from 'pipe:0':
Duration: N/A, bitrate: 2822 kb/s
Stream #1:0: Audio: pcm_s32be, 44100 Hz, 2 channels, s32, 2822 kb/s
[matroska @ 0x25ff240] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, matroska, to 'pipe:1':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Audio: pcm_s32be ([255][255][255][255] / 0xFFFFFFFF), 44100 Hz, stereo (32 bit), 2822 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested
Received signal 2: terminating.

addy@blap:de-ip-hdmi$ sudo de-ip-hdmi -interface enx0050b64d263a
ffmpeg version 2.7.6-0ubuntu0.15.10.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
[mjpeg @ 0x2488c80] Changeing bps to 8
Input #0, mjpeg, from '/tmp/hdmi-Vfifo-rgIkj':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1280x540 [SAR 1:1 DAR 64:27], 25 tbr, 1200k tbn, 25 tbc
^CGuessed Channel Layout for Input Stream #1.0 : stereo
Input #1, s32be, from 'pipe:0':
Duration: N/A, bitrate: 2822 kb/s
Stream #1:0: Audio: pcm_s32be, 44100 Hz, 2 channels, s32, 2822 kb/s
[matroska @ 0x248c6a0] Codec for stream 0 does not use global headers but container format requires global headers
[matroska @ 0x248c6a0] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, matroska, to 'pipe:1':
Metadata:
encoder : Lavf56.36.100
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 1280x540 [SAR 1:1 DAR 64:27], q=2-31, 25 tbr, 1k tbn, 1200k tbc
Stream #0:1: Audio: pcm_s32be ([255][255][255][255] / 0xFFFFFFFF), 44100 Hz, stereo (32 bit), 2822 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Immediate exit requested
Received signal 2: terminating.

Interesting, Can you checkout d32cbab, build that, and see if that works?

Yes, that revision builds and works.

Woops!

Okay, That's irritating, I suspect there is some commit that went a little wrong there, Could you do me a favour and "git bisect" between that and HEAD and find the offending commit?

CC: @Shugyousha

Sure, no problem...

On Tue, Jul 12, 2016 at 12:52 PM, Ben Cox notifications@github.com wrote:

Woops!

Okay, That's irritating, I suspect there is some commit that went a little
wrong there, Could you do me a favour and "git bisect" between that and HEAD
and find the offending commit?

CC: @Shugyousha

Hm, I think I screwed up this line.

packet = append(macbytes[:6], packet[:6]...)

it should be (note the second colon):

packet = append(macbytes[:6], packet[6:]...)

Can you check if it works with this change? If it does I can send a
patch (or you can :) ).

Thanks for the bug report!

@Shugyousha yes, that fixes it! Thanks!

(BTW, I say 'fix', but I also have a problem that although the video sender now starts and I can see the packets with wireshark, the ffmpeg process hangs on the FIFO so you never get any output from de-ip-hdmi itself (this is also true of the .deb package). I have the same problem with my own python code, so I assume it's something to do with FIFOs as it's affecting both of us. Since I want to transcode when I'm done I just write to separate audio/video files, so I'm not that bothered but worth mentioning in case anyone else is also having that issue).

Here is the patch...

main.go.patch.gz

@AdamLaurie are you plugging the device directly into your system, or is it though going though a switch?

On Tue, Jul 12, 2016 at 09:56:15AM -0700, Adam Laurie wrote:

@Shugyousha yes, that fixes it! Thanks!

I thought I got the subslicing right on the first try but I obviously
didn't...

(BTW, I say 'fix', but I also have a problem that although the video
sender now starts and I can see the packets with wireshark, the ffmpeg
process hangs on the FIFO so you never get any output from de-ip-hdmi
itself. I have the same problem with my own python code, so I assume
it's something to do with FIFOs as it's affecting both of us. Since I
want to transcode when I'm done I just write to separate audio/video
files, so I'm not that bothered but worth mentioning in case anyone
else is also having that issue).

I don't have the hardware so I can't test it but to me it sounds like
the FIFO and the ffmpeg stdin are not being closed which results in
ffmpeg waiting for more data.

If we close videodis at the end of main() and close the WriteCloser in
DumpChanToFile it may work. It should look similar to this.

diff --git a/main.go b/main.go
index d9b37d4..6ab0cae 100644
--- a/main.go
+++ b/main.go
@@ -180,6 +180,7 @@ func main() {
}

}
  • close(videodis)
    }

func randString(n int) string {
@@ -228,7 +229,10 @@ func DumpChanToFile(channel chan []byte, file io.WriteCloser) {
}
}

  • log.Fatalf("Channel closed")
  • err := file.Close()
  • if err != nil {
  •   log.Printf("Error when closing pipe: %s", err)
    
  • }
    }

func BroadcastWakeups(ifname string, sendermac string) {


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#5 (comment)

@benjojo I've tried both and it makes no difference. The patch fixes the original issue in that the sender now sees the keepalives and starts streaming.

If you do a tcpdump, do you see the packets arrive at your interface?

Yes (well, wireshark, as previously mentioned). The problem is definitely with the FIFO. In python, I can stream either the video or the audio to ffmpeg via a pipe/stdin, or I can write both the video and audio to separate files, but if I try to write either via a FIFO it hangs on the the first write. I'm guessing it's the same problem with the go code.

Are you playing sound though the HDMI input? If not then use the -audio false option, otherwise it will hang.

Yes, I have both audio & video. Again, it all works fine if I write to files instead of FIFO.

BTW, with reference to audio, you mention in your blog:

"I found that the audio sample rate had changed to 44100hz, down from the 48000hz that danman reported. (Though this could be dependent on the input?)"

I can confirm after some experimentation that at least here in the UK I'm still getting 48KHz, so I suspect it's just whatever the input is set to as in my case that matches the sources.

Okay, Can you raise different issues for these things?

We have solved the build issue, I can see two issues here, not being able to send data into a FIFO, and the audio sampling issue

On 14/07/16 12:35, Ben Cox wrote:

Okay, Can you raise different issues for these things?

We have solved the build issue, I can see two issues here, not being
able to send data into a FIFO, and the audio sampling issue

The audio sampling thing is not an issue with your code - it was just an
observation in case you want to update your blog, as assuming the audio
rate is fixed at 44.1 will lead to incorrect frame rates when transcoding.

I will re-raise the FIFO issue though, and anything else I come across.

cheers,

Adam

Adam Laurie Tel: +44 (0) 20 7993 2690
Suite 7
61 Victoria Road
Surbiton
Surrey mailto:adam@algroup.co.uk
KT6 4JX http://rfidiot.org