Page 1 of 1

Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Wed Oct 09, 2013 3:05 am
by shadowing
I'm currently trying to stream to a rtmp server using bmdcapture and ffmpeg. I'm running the following command:

Code: Select all
bmdcapture -C 1 -A 2 -p 8 -c 2 -V 4 -m 1 -s 16 -F nut -f pipe:1 | ffmpeg -rtbufsize 2147483647 -threads 8 -re -copyts -i - -pix_fmt yuv420p -profile high -ab 256k -vf yadif -vcodec libx264 -maxrate:v 1024k -minrate:v 1024k -bufsize:v 1024k -tune zerolatency -ar 44100 -preset veryfast -acodec libfaac -f flv "rtmp://localhost:1935/live/test live=1"


However, after running for a couple of minutes to hours, ffmpeg eventually spits out this error:

Code: Select all
[flv @ 0x2279ba0] Failed to update header with correct duration
[flv @ 0x2279ba0] Failed to update header with correct filesize.


Has anyone here encountered this? If so, how did you guys fix it?

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Wed Oct 09, 2013 6:43 am
by Roman Pytkin Pekarek
im using this one :

bmdcapture -m 2 -A 1 -F nut -f pipe:1 | ffmpeg -re -i - -c:v libx264 -profile:v high422 -aspect 16:9 -r 50 -g 48 -keyint_min 48 -sc_threshold 0 -vb 2500k -c:a libvo_aacenc -ab 48k -ar 48000 -ac 2 -f flv "rtmp://WOWZA_IP:1935/live/streamname"

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Mon Oct 28, 2013 8:43 pm
by lu_zero
Curious, try using avconv. https://libav.org/avconv.html

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Thu Nov 07, 2013 5:00 am
by shadowing
Sorry for the lack of update. Here's a better report of the actual problem:

ffmpeg started on 2013-11-06 at 19:12:55
Report written to "ffmpeg-20131106-191255.log"
Command line:
ffmpeg -report -rtbufsize 2147483647 -threads 8 -re -copyts -i - -pix_fmt yuv420p -profile high -ab 256k -vf yadif -g 50 -vcodec libx264 -maxrate:v 1024k -minrate:v 1024k -bufsize:v 1024k -sc_threshold 0 -tune zerolatency -keyint_min 50 -ar 44100 -preset veryfast -acodec libfaac -f flv "rtmp://localhost:1935/live/4bZe7TBKQ8Q1p3B live=1"
ffmpeg version N-57040-ga72bf5f Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 10 2013 17:41:02 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --prefix=/home/sdi/ffmpeg_static --enable-runtime-cpudetect --disable-debug --disable-ffserver --disable-shared --enable-libfaac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-libass --enable-libfreetype --enable-librtmp --enable-gpl --enable-nonfree --extra-libs=-ldl
libavutil 52. 46.101 / 52. 46.101
libavcodec 55. 35.100 / 55. 35.100
libavformat 55. 19.100 / 55. 19.100
libavdevice 55. 4.100 / 55. 4.100
libavfilter 3. 88.101 / 3. 88.101
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-rtbufsize' ... matched as AVOption 'rtbufsize' with argument '2147483647'.
Reading option '-threads' ... matched as AVOption 'threads' with argument '8'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-copyts' ... matched as option 'copyts' (copy timestamps) with argument '1'.
Reading option '-i' ... matched as input file with argument '-'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-profile' ... matched as option 'profile' (set profile) with argument 'high'.
Reading option '-ab' ... matched as AVOption 'ab' with argument '256k'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'yadif'.
Reading option '-g' ... matched as AVOption 'g' with argument '50'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'.
Reading option '-maxrate:v' ... matched as AVOption 'maxrate:v' with argument '1024k'.
Reading option '-minrate:v' ... matched as AVOption 'minrate:v' with argument '1024k'.
Reading option '-bufsize:v' ... matched as AVOption 'bufsize:v' with argument '1024k'.
Reading option '-sc_threshold' ... matched as AVOption 'sc_threshold' with argument '0'.
Reading option '-tune' ... matched as AVOption 'tune' with argument 'zerolatency'.
Reading option '-keyint_min' ... matched as AVOption 'keyint_min' with argument '50'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '44100'.
Reading option '-preset' ... matched as AVOption 'preset' with argument 'veryfast'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'libfaac'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'rtmp://localhost:1935/live/4bZe7TBKQ8Q1p3B live=1' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option copyts (copy timestamps) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file -.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: -.
[nut @ 0x3aae0e0] Format nut probed with size=2048 and score=100
[nut @ 0x3aae0e0] File position before avformat_find_stream_info() is 240
[nut @ 0x3aae0e0] All info found
[nut @ 0x3aae0e0] File position after avformat_find_stream_info() is 706522
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, nut, from 'pipe:':
Metadata:
encoder : Lavf55.5.3
Duration: N/A, start: 0.000000, bitrate: 1536 kb/s
Stream #0:0, 1, 1001/24000: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x486, 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0:1, 1, 1/48000: Audio: pcm_s16le (PSD[16] / 0x10445350), 48000 Hz, stereo, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output file rtmp://localhost:1935/live/4bZe7TBKQ8Q1p3B live=1.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Applying option profile (set profile) with argument high.
Please use -profile:a or -profile:v, -profile is ambiguous
Applying option vf (set video filters) with argument yadif.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument libx264.
Applying option ar (set audio sampling rate (in Hz)) with argument 44100.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument libfaac.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: rtmp://localhost:1935/live/4bZe7TBKQ8Q1p3B live=1.
Parsing...
Parsed protocol: 0
Parsed host : localhost
Parsed app : live
RTMP_Connect1, ... connected, handshaking
HandShake: Type Answer : 03
HandShake: Server Uptime : -564517939
HandShake: FMS Version : 49.194.144.119
HandShake: Handshaking finished....
RTMP_Connect1, handshaked
RTMP_SendPacket: fd=4, size=93
Invoking connect
RTMP_ReadPacket: fd=4
HandleServerBW: server BW = 2500000
RTMP_ReadPacket: fd=4
HandleClientBW: client BW = 2500000 2
RTMP_ReadPacket: fd=4
HandleCtrl, received ctrl. type: 0, len: 6
HandleCtrl, Stream Begin 0
RTMP_ReadPacket: fd=4
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 189 bytes
(object begin)
Property: <Name: no-name., STRING: _result>
Property: <Name: no-name., NUMBER: 1.00>
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: fmsVer, STRING: FMS/3,0,1,123>
Property: <Name: capabilities, NUMBER: 31.00>
(object end)
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: level, STRING: status>
Property: <Name: code, STRING: NetConnection.Connect.Success>
Property: <Name: description, STRING: Connection succeeded>
Property: <Name: objectEncoding, NUMBER: 0.00>
(object end)
(object end)
HandleInvoke, server invoking <_result>
HandleInvoke, received result for method call <connect>
RTMP_SendPacket: fd=4, size=44
Invoking releaseStream
RTMP_SendPacket: fd=4, size=40
Invoking FCPublish
RTMP_SendPacket: fd=4, size=25
Invoking createStream
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 30 bytes
(object begin)
Property: <Name: no-name., STRING: onBWDone>
Property: <Name: no-name., NUMBER: 0.00>
Property: NULL
Property: <Name: no-name., NUMBER: 8192.00>
(object end)
HandleInvoke, server invoking <onBWDone>
RTMP_SendPacket: fd=4, size=21
Invoking _checkbw
RTMP_ReadPacket: fd=4
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 139 bytes
(object begin)
Property: <Name: no-name., STRING: _error>
Property: <Name: no-name., NUMBER: 2.00>
Property: NULL
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: level, STRING: error>
Property: <Name: code, STRING: NetConnection.Call.Failed>
Property: <Name: description, STRING: Specified stream not found in call to releaseStream>
(object end)
(object end)
HandleInvoke, server invoking <_error>
HandleInvoke, received result id 2.000000 without matching request
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 21 bytes
(object begin)
Property: <Name: no-name., STRING: _result>
Property: <Name: no-name., NUMBER: 3.00>
Property: NULL
Property: NULL
(object end)
HandleInvoke, server invoking <_result>
HandleInvoke, received result id 3.000000 without matching request
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 91 bytes
(object begin)
Property: <Name: no-name., STRING: onFCPublish>
Property: <Name: no-name., NUMBER: 0.00>
Property: NULL
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: code, STRING: NetStream.Publish.Start>
Property: <Name: description, STRING: 4bZe7TBKQ8Q1p3B>
(object end)
(object end)
HandleInvoke, server invoking <onFCPublish>
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 29 bytes
(object begin)
Property: <Name: no-name., STRING: _result>
Property: <Name: no-name., NUMBER: 4.00>
Property: NULL
Property: <Name: no-name., NUMBER: 1.00>
(object end)
HandleInvoke, server invoking <_result>
HandleInvoke, received result for method call <createStream>
RTMP_SendPacket: fd=4, size=45
Invoking publish
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 120 bytes
(object begin)
Property: <Name: no-name., STRING: _error>
Property: <Name: no-name., NUMBER: 5.00>
Property: NULL
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: level, STRING: error>
Property: <Name: code, STRING: NetConnection.Call.Failed>
Property: <Name: description, STRING: call to function _checkbw failed>
(object end)
(object end)
HandleInvoke, server invoking <_error>
HandleInvoke, received result id 5.000000 without matching request
RTMP_ReadPacket: fd=4
RTMP_ReadPacket: fd=4
RTMP_ClientPacket, received: invoke 185 bytes
(object begin)
Property: <Name: no-name., STRING: onStatus>
Property: <Name: no-name., NUMBER: 0.00>
Property: NULL
Property: <Name: no-name., OBJECT>
(object begin)
Property: <Name: level, STRING: status>
Property: <Name: code, STRING: NetStream.Publish.Start>
Property: <Name: description, STRING: Stream `4bZe7TBKQ8Q1p3B` is now published>
Property: <Name: details, STRING: 4bZe7TBKQ8Q1p3B>
Property: <Name: clientid, STRING: 2826_1_19585616>
(object end)
(object end)
HandleInvoke, server invoking <onStatus>
HandleInvoke, onStatus: NetStream.Publish.Start
Successfully opened the file.
detected 24 logical cores
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'video_size' to value '720x486'
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'pix_fmt' to value '17'
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'time_base' to value '1001/24000'
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x3a99120] Setting 'frame_rate' to value '24000/1001'
[graph 0 input from stream 0:0 @ 0x3a99120] w:720 h:486 pixfmt:uyvy422 tb:1001/24000 fr:24000/1001 sar:0/1 sws_param:flags=2
[format @ 0x3a9ac40] compat: called with args=[yuv420p]
[format @ 0x3a9ac40] Setting 'pix_fmts' to value 'yuv420p'
[auto-inserted scaler 0 @ 0x3a99c60] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 0x3a99c60] w:iw h:ih flags:'0x4' interl:0
[Parsed_yadif_0 @ 0x3a98b80] auto-inserting filter 'auto-inserted scaler 0' between the filter 'graph 0 input from stream 0:0' and the filter 'Parsed_yadif_0'
[AVFilterGraph @ 0x3a9e2c0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto-inserted scaler 0 @ 0x3a99c60] w:720 h:486 fmt:uyvy422 sar:0/1 -> w:720 h:486 fmt:yuv420p sar:0/1 flags:0x4
[graph 1 input from stream 0:1 @ 0x3a9ae20] Setting 'time_base' to value '1/48000'
[graph 1 input from stream 0:1 @ 0x3a9ae20] Setting 'sample_rate' to value '48000'
[graph 1 input from stream 0:1 @ 0x3a9ae20] Setting 'sample_fmt' to value 's16'
[graph 1 input from stream 0:1 @ 0x3a9ae20] Setting 'channel_layout' to value '0x3'
[graph 1 input from stream 0:1 @ 0x3a9ae20] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[audio format for output stream 0:1 @ 0x3aa6980] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:1 @ 0x3aa6980] Setting 'sample_rates' to value '44100'
[audio format for output stream 0:1 @ 0x3aa6980] Setting 'channel_layouts' to value '0x4|0x3|0x7|0x107|0x37|0x3f'
[audio format for output stream 0:1 @ 0x3aa6980] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
[AVFilterGraph @ 0x3a9b100] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x3aa96c0] ch:2 chl:stereo fmt:s16 r:48000Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
[libx264 @ 0x3ab3c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x3ab3c00] profile High, level 3.0
[libx264 @ 0x3ab3c00] 264 - core 136 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=7 lookahead_threads=7 sliced_threads=1 slices=7 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=50 keyint_min=26 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1024 vbv_bufsize=1024 crf_max=0.0 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://localhost:1935/live/4bZe7TBKQ8Q1p3B live=1':
Metadata:
encoder : Lavf55.19.100
Stream #0:0, 0, 1/1000: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 720x486, q=-1--1, max. 1024 kb/s, 1k tbn, 23.98 tbc
Stream #0:1, 0, 1/1000: Audio: aac (libfaac) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, s16, 256 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
Stream #0:1 -> #0:1 (pcm_s16le -> libfaac)
[libx264 @ 0x3ab3c00] frame= 0 QP=25.61 NAL=3 Slice:I Poc:0 I:1395 P:0 SKIP:0 size=42659 bytes
RTMP_SendPacket: fd=4, size=309
RTMP_SendPacket: fd=4, size=42
RTMP_SendPacket: fd=4, size=4
RTMP_SendPacket: fd=4, size=460
[libx264 @ 0x3ab3c00] frame= 1 QP=26.04 NAL=2 Slice:P Poc:2 I:12 P:196 SKIP:1187 size=719 bytes
RTMP_SendPacket: fd=4, size=43349
RTMP_SendPacket: fd=4, size=320
[libx264 @ 0x3ab3c00] frame= 2 QP=25.55 NAL=2 Slice:P Poc:4 I:23 P:352 SKIP:1020 size=1856 bytes
RTMP_SendPacket: fd=4, size=329
RTMP_SendPacket: fd=4, size=730
RTMP_SendPacket: fd=4, size=315
[libx264 @ 0x3ab3c00] frame= 3 QP=24.88 NAL=2 Slice:P Poc:6 I:25 P:619 SKIP:751 size=3680 bytes
RTMP_SendPacket: fd=4, size=302
RTMP_SendPacket: fd=4, size=1867
RTMP_SendPacket: fd=4, size=304
RTMP_SendPacket: fd=4, size=311
... (repeat above lines for a while)
[libx264 @ 0x3ab3c00] frame=101871 QP=29.62 NAL=2 Slice:P Poc:42 I:33 P:1164 SKIP:198 size=6429 bytes
frame=101872 fps= 23 q=28.0 size= 546993kB time=01:10:48.91 bitrate=1054.6kbits/s
RTMP_SendPacket: fd=4, size=380
[libx264 @ 0x3ab3c00] frame=101872 QP=29.92 NAL=2 Slice:P Poc:44 I:11 P:984 SKIP:400 size=4278 bytes
RTMP_SendPacket: fd=4, size=4752
RTMP_SendPacket: fd=4, size=436
[output stream 0:1 @ 0x3a9de40] EOF on sink link output stream 0:1:default.
[libx264 @ 0x3ab3c00] frame=101873 QP=29.43 NAL=2 Slice:P Poc:46 I:24 P:1073 SKIP:298 size=5187 bytes
[output stream 0:0 @ 0x3a9aa60] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
RTMP_SendPacket: fd=4, size=418
RTMP_SendPacket: fd=4, size=6440
RTMP_SendPacket: fd=4, size=419
RTMP_SendPacket: fd=4, size=419
[libfaac @ 0x3ab68a0] Trying to remove 227 more samples than there are in the queue
RTMP_SendPacket: fd=4, size=4289
RTMP_SendPacket: fd=4, size=233
RTMP_SendPacket: fd=4, size=5198
RTMP_SendPacket: fd=4, size=5
[flv @ 0x3ab0c20] Failed to update header with correct duration.
[flv @ 0x3ab0c20] Failed to update header with correct filesize.
frame=101874 fps= 23 q=28.0 Lsize= 547016kB time=01:10:48.99 bitrate=1054.6kbits/s
video:462563kB audio:78828kB subtitle:0 global headers:0kB muxing overhead 1.038972%
[libx264 @ 0x3ab3c00] frame I:2038 Avg QP:23.55 size: 29911
[libx264 @ 0x3ab3c00] frame P:99836 Avg QP:25.54 size: 4134
[libx264 @ 0x3ab3c00] mb I I16..4: 17.1% 35.8% 47.1%
[libx264 @ 0x3ab3c00] mb P I16..4: 3.9% 3.9% 0.3% P16..4: 32.1% 11.1% 4.3% 0.0% 0.0% skip:44.4%
[libx264 @ 0x3ab3c00] 8x8 transform intra:45.7% inter:38.1%
[libx264 @ 0x3ab3c00] coded y,uvDC,uvAC intra: 45.5% 53.7% 17.8% inter: 13.1% 14.7% 1.0%
[libx264 @ 0x3ab3c00] i16 v,h,dc,p: 43% 32% 20% 5%
[libx264 @ 0x3ab3c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 20% 35% 3% 3% 4% 4% 4% 5%
[libx264 @ 0x3ab3c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 22% 16% 5% 6% 7% 5% 6% 6%
[libx264 @ 0x3ab3c00] i8c dc,h,v,p: 54% 22% 19% 5%
[libx264 @ 0x3ab3c00] Weighted P-Frames: Y:3.1% UV:1.7%
[libx264 @ 0x3ab3c00] kb/s:891.81
229215 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x3ae6960] Statistics: 0 seeks, 285536 writeouts
RTMP_SendPacket: fd=4, size=42
Invoking FCUnpublish
RTMP_SendPacket: fd=4, size=34
Invoking deleteStream
[AVIOContext @ 0x3ab67e0] Statistics: 72116951330 bytes read, 0 seeks


If anyone can understand what this means, that'd be nice :)

Pytkin: I've tried using those commands, but no luck sadly :/

lu_zero: I'll go around trying avconv instead of ffmpeg, but I have a suspicion that the results would be the same.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Fri Nov 08, 2013 1:01 pm
by wieshka
I suggest you to switch to avconv for multiple reasons, main reason to mention - more then half year ago in cooperation with author of bmdtools (& author of RTMP support for avconv) - lu-zero we created branch version for libav which includes libbmd (3rd party lib, based on bmdtools) integration to avconv.

As integration is open sourced, you are welcome to use it and provide feedback @ github.

From my side I can tell, that I am running 24/7 RTMP streams with mentioned integration from more then 60 BMD cards (various), including newest BMD products.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Tue Nov 12, 2013 8:52 pm
by shadowing
wieshka: Thanks for the advice. Can you provide a link to your branch version?

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Mon Jan 20, 2014 4:26 am
by jeff dubin
Hi folks! I'm also trying to stream via a Decklink Mini Recorder, and I'm pulling my hair out trying to figure out what's going on here. I'm running Centos 6.5 64-bit w/ an Intel i7-4770K and 16GB RAM. Source is a consumer camcorder (Panasonic HC-V720) via HDMI at 1080i29.97 (only possible mode using this camera with this capture card). Destination is a low rate (~700k or less) Ustream feed plus a second, higher quality (20mbps) file saved locally. I'm focusing this post on the Ustream portion.

Bmdtools and libav 9.10 (./configure --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-gpl --enable-nonfree) built successfully. I can capture raw video locally (./bmdcapture -m 11 -F nut -A 2 -V 3 -f out) and play it back via VLC. I can stream video from a local file to Ustream with avconv. But I can't live stream from the camera directly to Ustream. I'm using:
Code: Select all
bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 |avconv -y -i - -c:v libx264 -r 29.97 -preset faster -vb 300k -c:a libfdk_aac -b:a 64k -f flv rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr

Using this method, avconv looks like it's about to start streaming, but then fails. See pastebin.com/7Kbv2bQK for an example. Could it have something to do with bmdcapture initially dropping a couple of frames (even though I have told it the correct mode, verified with Media Express)? No idea, but I then tried ffmpeg, but had the same problem. see pastebin.com/vJrA1kFQ for those details.

Next I compiled libav from the lu-zero git at github.com/lu-zero/libav (./configure --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libx264 --enable-libbmd). Aha -- now I'm getting further; I'm able to stream something... but not for long. Two problems:
1) After a few (sometimes 2? sometimes 5?) minutes, streaming stops, and I abruptly see "Killed". Like this:
Code: Select all
frame=8722 QP=21.00 NAL=2 Slice:P Poc:44  I:17   P:167  SKIP:736  size=800 bytes
[libx264 @ 0x25fbc20] frame=8723 QP=21.00 NAL=2 Slice:P Poc:46  I:16   P:186  SKIP:718  size=882 bytes
[libx264 @ 0x25fbc20] frame=8724 QP=21.00 NAL=2 Slice:P Poc:48  I:10   P:190  SKIP:720  size=874 bytes
[libx264 @ 0x25fbc20] frame=8725 QP=21.00 NAL=2 Slice:P Poc:50  I:10   P:185  SKIP:725  size=846 bytes
[libx264 @ 0x25fbc20] frame=8726 QP=21.00 NAL=2 Slice:P Poc:52  I:9    P:174  SKIP:737  size=817 bytes
frame=8727 QP=21.00 NAL=2 Slice:P Poc:54  I:10   P:183  SKIP:727  size=778 bytes
[libx264 @ 0x25fbc20] frame=8728 QP=21.00 NAL=2 Slice:P Poc:56  I:13   P:178  SKIP:729  size=853 bytes
[libx264 @ 0x25fbc20] frame=8729 QP=21.00 NAL=2 Slice:P Poc:58  I:9    P:197  SKIP:714  size=864 bytes
frame=8730 QP=21.00 NAL=2 Slice:P Poc:60  I:17   P:177  SKIP:726  size=852 bytes
[libx264 @ 0x25fbc20] frame=8731 QP=21.00 NAL=2 Slice:P Poc:62  I:10   P:186  SKIP:724  size=845 bytes
Killed
[root@videoserver libav-bmd]#


2) While I am streaming, things seem to be going up to Ustream okay, but on the client side (Ustream on Chrome/Firefox via Windows PC on a decent broadband connection, Ustream app on Galaxy S3 with strong LTE signal), I'm getting almost constant "buffering", a few seconds of video, and more buffering, etc.. It's maybe slightly better when I resize (-s 640x360), but still very much happening. I can verify that my capture box's CPU usage seems low, there's upstream bandwidth (I've lowered my outbound rate to under 450kbps, and I should have at least 850kbps available), and I've got plenty of downstream bandwidth (PC via broadband and phone via LTE).

So... I've spent a good 12 hours today trying to get to the bottom of this. No idea what step to take next. I see folks posting about multiple boxes running smooth -- I'd love to know your secret. I'd be extremely grateful for any help you guys can provide!

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Mon Jan 20, 2014 7:23 am
by Roman Pytkin Pekarek
try this :

Code: Select all
bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | ffmpeg -re -i - \
-c:v libx264 -pix_fmt yuv420p -vf "scale=640:360" -profile:v baseline -level 3.1 \
-aspect 16:9 -r 29.97 -vb 300k \
-c:a libvo_aacenc -ab 64k -ar 44100 -ac 2 \
-f flv "rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr"

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Tue Jan 21, 2014 12:56 am
by Reuben
Several observations:

1 - Why is your video bitrate set to 300k when you are shooting for 700k? Either way, there is no way in hell you're going to get reasonable quality 1080i video at either of those bitrates. Downscale the frame size before encoding ("-s" option). It's very unlikely you have any use for 1080 video for web streaming anyway, especially if you are using phone for playback. Try using the -crf flag rather than the -vb flag.

2 - Always set the "-re" flag when using a live source. Also the "-y" flag is not needed: you are not outputting a file.

3 - This is being picky, but use "-r 30000/1001" rather than "-r 29.97"

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Tue Jan 21, 2014 8:30 pm
by jeff dubin
Pytkin wrote:try this :

Code: Select all
bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | ffmpeg -re -i - \
-c:v libx264 -pix_fmt yuv420p -vf "scale=640:360" -profile:v baseline -level 3.1 \
-aspect 16:9 -r 29.97 -vb 300k \
-c:a libvo_aacenc -ab 64k -ar 44100 -ac 2 \
-f flv "rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr"

Thanks for the tip, Pytkin.

I ended up reinstalling the OS, and haven't yet recompiled ffmpeg, but I did try this with avconv and a couple of minor changes for command line compatibility:
Code: Select all
bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | avconv -re -i - \
-c:v libx264 -vf "scale=640:360" -profile:v baseline -level 31 \
-aspect 16:9 -r 29.97 -vb 300k \
-c:a libfdk_aac -ab 64k -ar 44100 -ac 2 \
-f flv "rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr"

Again, I'm having the same issue (and same thing happened previously with ffmpeg) -- it starts up and looks like it's about to stream, but then I see:
Code: Select all
[root@videoserver test]# bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | avconv -re -i - -c:v libx264 -vf "scale=640:360" -profile:v baseline -level 31 -aspect 16:9 -r 29.97 -vb 300k -c:a libfdk_aac -ab 64k -ar 44100 -ac 2 -f flv "rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr"
avconv version 9.10, Copyright (c) 2000-2013 the Libav developers
  built on Jan 21 2014 12:53:02 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
Tue Jan 21 15:16:36 2014
 Frame received (#1) - No input signal detected - Frames dropped 1 - Total dropped 1
[nut @ 0x1a45c20] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, nut, from 'pipe:':
  Metadata:
    encoder         : Lavf54.20.3
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: rawvideo, uyvy422, 1920x1080, 29.97 tbr, 29.97 tbn
    Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Tue Jan 21 15:16:37 2014
 Frame received (#13) - Input returned - Frames dropped 2 - Total dropped 2
[libx264 @ 0x1a49680] using SAR=1/1
[libx264 @ 0x1a49680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x1a49680] profile Constrained Baseline, level 3.1
[libx264 @ 0x1a49680] 264 - core 138 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=300 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Output #0, flv, to 'rtmp://1.16997247.fme.ustream.tv/ustreamVideo/16997247/Gmg04msdfobO50bkstnMtos0zbk4kgdr':
  Metadata:
    encoder         : Lavf54.20.3
    Stream #0.0: Video: libx264, yuv420p, 640x360 [PAR 1:1 DAR 16:9], q=-1--1, 300 kb/s, 1k tbn, 29.97 tbc
    Stream #0.1: Audio: libfdk_aac, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
  Stream #0:1 -> #0:1 (pcm_s16le -> libfdk_aac)
Press ctrl-c to stop encoding
Stopping Capture
pipe:: Operation not permitted=       0kB time=0.07 bitrate=  46.0kbits/s
Failed to update header with correct duration.
[flv @ 0x1a4b480] Failed to update header with correct filesize.
frame=    5 fps=  0 q=-1.0 Lsize=       4kB time=0.17 bitrate= 197.3kbits/s
video:0kB audio:1kB global headers:0kB muxing overhead 207.847534%
[libx264 @ 0x1a49680] frame I:1     Avg QP:23.09  size:   901
[libx264 @ 0x1a49680] frame P:4     Avg QP:24.00  size:    11
[libx264 @ 0x1a49680] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x1a49680] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0x1a49680] final ratefactor: 23.80
[libx264 @ 0x1a49680] coded y,uvDC,uvAC intra: 0.0% 1.6% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x1a49680] i16 v,h,dc,p: 96%  0%  4%  0%
[libx264 @ 0x1a49680] i8c dc,h,v,p: 67%  0% 33%  0%
[libx264 @ 0x1a49680] kb/s:45.27
[root@videoserver test]#

Unfortunately, putting the error in the code block doesn't show colors, but the error has something to do with "pipe:: Operation not permitted", which is about 2/3 down (and red).

So, I'm trying to figure out if this is a problem with bmdcapture, avconv, or Ustream. That error referencing the pipe makes me think it's something with bmdcapture, especially since when I used the older fork of avconv with built-in bmd support, I was connecting to Ustream fine for a little while.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Tue Jan 21, 2014 8:40 pm
by jeff dubin
Reuben wrote:Several observations:

1 - Why is your video bitrate set to 300k when you are shooting for 700k? Either way, there is no way in hell you're going to get reasonable quality 1080i video at either of those bitrates. Downscale the frame size before encoding ("-s" option). It's very unlikely you have any use for 1080 video for web streaming anyway, especially if you are using phone for playback. Try using the -crf flag rather than the -vb flag.

2 - Always set the "-re" flag when using a live source. Also the "-y" flag is not needed: you are not outputting a file.

3 - This is being picky, but use "-r 30000/1001" rather than "-r 29.97"

Thanks, Reuben. Sorry for the command line confusion... I have about 50 different tries in my history buffer and that's just the one I pulled out from when I was trying to make sure I wasn't exceeding my upstream bandwidth (I am scrambling the Ustream key before I post, fwiw). I'm certainly not going to be trying to stream 1080 -- I typically use "-s 640x360", just forgot to in this example. In any case, same results. I'll try the -crf flag, though I need to make sure my bandwidth stays reasonable. Also, -y was leftover from when I was testing by writing a local file... removed now. I added -re and set the frame rate as you described, but I still have the same issue.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Wed Jan 22, 2014 12:10 am
by Reuben
Try directing the output to a file rather than rtmp stream. It will at least help you narrow down the source of the problem. If writing to a file succeeds the problem is likely to do with the RTMP connection rather than the capture / encoding. If it fails, then vice versa.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Wed Jan 22, 2014 3:20 am
by jeff dubin
I've done that in the course of testing, and the files come out fine. But I've just finished testing with a different streaming provider, and have similar results. I'm able to start streaming for about 25-35 seconds, and then it bombs out with the same pipe:: Operation not permitted error.

The next thing I'd like to do is try to replicate the (software) setup of someone who is successfully streaming. Would you guys mind sharing info about your configuration, e.g. linux distro, version of the SDK, bmdtools, libav/ffmpeg, x264, and anything else you might feel is relevant? I'm debating trying Ubuntu, but I'd love to know what others are using before I start installing over and over. Many, many thanks in advance!

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Wed Jan 22, 2014 11:38 pm
by Roman Pytkin Pekarek
im using centos (=redhat) .. all binaries is posted here .. with tutorial .. use search ..

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Thu Jan 23, 2014 3:04 am
by Reuben
Gentoo, ffmpeg-2.1.3, x264 snapshot dated 2013-09-12, bmdtools latest git, latest drivers/SDK.

I stream to a LiveStream account (their legacy system, not the new one), to CDNs, and to my own nginx+rtmp module server. Streams generally last a few hours. Sources are usually SDI, occasionally HDMI. Audio source is usually analog. I have tried embedded audio a few times with HDMI, but it sometime causes problems. Embedded audio with SDI works fine.

I generally do not recommend trying to do this with Gentoo though unless you are really familiar with the internal nuts and bolts of a linux system.

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Fri Jan 24, 2014 4:10 am
by jeff dubin
Wiped out my hard drive and started from scratch. I'm still having the same problem. Here's what I'm doing to install everything:

Start with Centos 6.5 x86_64 ISO, install minimal desktop
Install updates and dev tools:
yum update
yum groupinstall development tools

Install DKMS:
wget http://linux.dell.com/dkms/permalink/dkms-2.2.0.3-1.noarch.rpm
yum install dkms-2.2.0.3-1.noarch.rpm

Install BMD driver:
wget http://software.blackmagicdesign.com/DesktopVideo/Blackmagic_Desktop_Video_Linux_9.8.tar.gz
yum install desktopvideo-9.8-redhat.x86_64.rpm

Reboot system

Install mediaexpress:
yum install mediaexpress-3.2.2-redhat.x86_64.rpm

Install tools and libs for ffmpeg:
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
./configure; make; make install

wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
./configure --enable-shared; make; make install

wget "http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2F&ts=1390083695&use_mirror=switch"
./configure; make; make install

wget "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.99%2F&ts=1390532317&use_mirror=switch"
yum install nasm
./configure; make; make install

Install ffmpeg:
wget http://www.ffmpeg.org/releases/ffmpeg-2.1.3.tar.bz2
./configure --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libx264; make; make install

Add /usr/local/lib to /etc/ld.so.conf

Get SDK:
wget http://software.blackmagicdesign.com/SDK0/Blackmagic_DeckLink_SDK_9.7.7.zip
unzip to /root/bmd/sdk

Install BMD tools:
wget https://github.com/lu-zero/bmdtools/archive/master.zip
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make SDK_PATH=/root/bmd/sdk/Linux/include/

Test bmdcapture:
./bmdcapture -m 11 -F nut -A 2 -V 3 -f test.dat

Test with a capture to local file:
./bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | ffmpeg -loglevel debug -re -i - -c:v libx264 -pix_fmt yuv420p -vf "scale=640:360" -profile:v baseline -level 3.1 -aspect 16:9 -r 29.97 -vb 300k -c:a libfdk_aac -ab 64k -ar 44100 -ac 2 -f flv test.flv

Test to streaming provider:
./bmdcapture -m 11 -F nut -A 2 -V 3 -f pipe:1 | ffmpeg -loglevel debug -re -i - -c:v libx264 -pix_fmt yuv420p -vf "scale=640:360" -profile:v baseline -level 3.1 -aspect 16:9 -r 29.97 -vb 300k -c:a libfdk_aac -ab 64k -ar 44100 -ac 2 -f flv rtmp://xxxxxx:xxxxxx@p.ep155434.i.akamaientrypoint.net/Entrypoint/dclive_1_1@155434

Aaaaaaaand here's where it fails after about 30s. All tests before it run fine, but when I'm pushing out to a streaming server, I still get issues. Output of log at http://pastebin.com/saTHXmsP. Similar results with Ustream rtmp url. Maybe it's time to try a different distribution. Gentoo is too hardcore for me. Maybe Debian?

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Fri Jan 24, 2014 6:22 am
by Reuben
Try changing

Code: Select all
rtmp://xxxxxx:xxxxxx@p.ep155434.i.akamaientrypoint.net/Entrypoint/dclive_1_1@155434


to

Code: Select all
"rtmp://xxxxxx:xxxxxx@p.ep155434.i.akamaientrypoint.net/Entrypoint/dclive_1_1@155434 flashver=FME/2.5\20(compatible;\20FMSc\201.0)"


(take notice that quotes were added)

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Sat Jan 25, 2014 4:33 pm
by jeff dubin
I certainly appreciate the tips everyone has given, but in the end I just wasn't able to get it to work right. I tried CentOS 6, CentOS 5, and Ubuntu 12.04, but I encountered the same problem each time. I still have no idea exactly which piece was causing the problem. Unfortunately, I had to abandon Linux and move this over to Windows (believe me, it pains me to say that!). I hope to try again in a couple of months, so if anyone else has a similar problem and is able to solve it, please post the solution here -- I'd love to know what I was doing wrong!

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Sat Jan 25, 2014 5:02 pm
by Roman Pytkin Pekarek
jeff : it must be problem with your provider, if record onto disk is OK .. im using linux + ffmpeg daily .. to my own wowza servers .. and there is absolutely no problem ..

BTW: i want to look into your logs ... try normal log .. not debug level ..

Re: Issue streaming via rtmp using bmdtool + ffmpeg

PostPosted: Mon Feb 17, 2014 3:57 pm
by Timothy Turner
Was there a solution to this problem? I am also experience this problem using both ffmpeg and avconv. Howerver my issue also occurs when I attempt to capture to file as well. wieshka mentioned a branch that had libbmd built into the libav, I would be interested in this to help resolve my issue.

Thanks,


Tim