次のコマンドを使用してffmpegを使用してストリーミングエンジン(nginx-rtmp)にビデオをストリーミングしています:
_ffmpeg -re -fflags +genpts -stream_loop -1 -i Sintel.mp4 -c copy -f flv rtmp://stream-engine/myStream
_
ただし、このストリームのffprobe
をストリーミングエンジンに直接実行していると、ストリームにビデオがない場合があります。
ストリームをテストするコマンド:_ffprobe -loglevel 'debug' rtmp://stream-engine/mystream
_
95%次の出力が得られます。
ffprobe version 3.0.2 Copyright (c) 2007-2016 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.38) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --Host-cflags= --Host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libvpx --enable-vda libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 [rtmp @ 0x7ff57e4028a0] No default whitelist set [tcp @ 0x7ff57e402d40] No default whitelist set [rtmp @ 0x7ff57e4028a0] Handshaking... [rtmp @ 0x7ff57e4028a0] Type answer 3 [rtmp @ 0x7ff57e4028a0] Server version 13.14.10.13 [rtmp @ 0x7ff57e4028a0] Proto = rtmp, path = /source/myStream, app = source, fname = myStream [rtmp @ 0x7ff57e4028a0] Server bandwidth = 5000000 [rtmp @ 0x7ff57e4028a0] Client bandwidth = 5000000 [rtmp @ 0x7ff57e4028a0] New incoming chunk size = 4096 [rtmp @ 0x7ff57e4028a0] Creating stream... [rtmp @ 0x7ff57e4028a0] Sending play command for 'myStream' [flv @ 0x7ff57f002e00] Format flv probed with size=2048 and score=100 [flv @ 0x7ff57f002e00] Before avformat_find_stream_info() pos: 13 bytes read:2266 seeks:0 [flv @ 0x7ff57f002e00] Unknown type |RtmpSampleAccess [flv @ 0x7ff57f002e00] video stream discovered after head already parsed [h264 @ 0x7ff580000000] no picture [flv @ 0x7ff57f002e00] All info found [flv @ 0x7ff57f002e00] rfps: 23.750000 0.014474 [flv @ 0x7ff57f002e00] rfps: 23.833333 0.006451 Last message repeated 1 times [flv @ 0x7ff57f002e00] rfps: 23.916667 0.001640 Last message repeated 1 times [flv @ 0x7ff57f002e00] rfps: 24.000000 0.000043 [flv @ 0x7ff57f002e00] rfps: 24.083333 0.001659 Last message repeated 1 times [flv @ 0x7ff57f002e00] rfps: 24.166667 0.006488 Last message repeated 1 times [flv @ 0x7ff57f002e00] rfps: 24.250000 0.014530 [flv @ 0x7ff57f002e00] rfps: 48.000000 0.000173 [flv @ 0x7ff57f002e00] rfps: 120.000000 0.001079 [flv @ 0x7ff57f002e00] rfps: 240.000000 0.004316 [flv @ 0x7ff57f002e00] rfps: 23.976024 0.000173 Last message repeated 1 times [flv @ 0x7ff57f002e00] rfps: 47.952048 0.000694 Last message repeated 1 times [flv @ 0x7ff57f002e00] After avformat_find_stream_info() pos: 345943 bytes read:345943 seeks:0 frames:256 Input #0, flv, from 'rtmp://stream-engine/myStream': Metadata: Server : NGINX RTMP (github.com/arut/nginx-rtmp-module) displayWidth : 1280 displayHeight : 544 fps : 24 profile : level : Duration: 00:00:00.00, start: 186.878000, bitrate: N/A Stream #0:0, 215, 1/1000: Audio: aac (LC), 48000 Hz, 5.1, fltp, 128 kb/s Stream #0:1, 41, 1/1000: Video: h264 (High), 4 reference frames, yuv420p(left), 1280x544 [SAR 1:1 DAR 40:17], 1/48, 24.42 fps, 24 tbr, 1k tbn, 48 tbc detected 4 logical cores [AVIOContext @ 0x7ff57e60cec0] Statistics: 345943 bytes read, 0 seeks [rtmp @ 0x7ff57e4028a0] Deleting stream...
それはすべて問題ありません、私はビデオとオーディオの両方のトラックを取得します。
5%の確率で次のようになります。
ffprobe version 3.0.2 Copyright (c) 2007-2016 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.38) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --Host-cflags= --Host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libvpx --enable-vda libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 [rtmp @ 0x7fe5cb407900] No default whitelist set [tcp @ 0x7fe5cb408100] No default whitelist set [rtmp @ 0x7fe5cb407900] Handshaking... [rtmp @ 0x7fe5cb407900] Type answer 3 [rtmp @ 0x7fe5cb407900] Server version 13.14.10.13 [rtmp @ 0x7fe5cb407900] Proto = rtmp, path = /source/myStream, app = source, fname = myStream [rtmp @ 0x7fe5cb407900] Server bandwidth = 5000000 [rtmp @ 0x7fe5cb407900] Client bandwidth = 5000000 [rtmp @ 0x7fe5cb407900] New incoming chunk size = 4096 [rtmp @ 0x7fe5cb407900] Creating stream... [rtmp @ 0x7fe5cb407900] Sending play command for 'myStream' [flv @ 0x7fe5cb800a00] Format flv probed with size=2048 and score=100 [flv @ 0x7fe5cb800a00] Before avformat_find_stream_info() pos: 13 bytes read:2288 seeks:0 [flv @ 0x7fe5cb800a00] Unknown type |RtmpSampleAccess [flv @ 0x7fe5cb800a00] max_analyze_duration 5000000 reached at 5019000 microseconds st:0 [flv @ 0x7fe5cb800a00] After avformat_find_stream_info() pos: 87188 bytes read:87188 seeks:0 frames:241 Input #0, flv, from 'rtmp://stream-engine/myStream': Metadata: Server : NGINX RTMP (github.com/arut/nginx-rtmp-module) displayWidth : 1280 displayHeight : 544 fps : 24 profile : level : Duration: 00:00:00.00, start: 343.593000, bitrate: N/A Stream #0:0, 241, 1/1000: Audio: aac (LC), 48000 Hz, 5.1, fltp, 128 kb/s [AVIOContext @ 0x7fe5cb604480] Statistics: 87188 bytes read, 0 seeks [rtmp @ 0x7fe5cb407900] Deleting stream...
多くのオプション、多くのエンコーダーを試しました。さまざまなストリームソース(ffmpeg、wowzaGoCoder、wirecast)とさまざまなストリーミングエンジン(wowza、nginx-rtmp)で再現しました。一部の構成では再現が難しくなりますが、それでも発生します...
同じストリームに「時々」ビデオトラックを含めることができるのはどうしてですか?何が欠けていますか?このような(非常に苛立たしい)バグに対して、どうすればより回復力を高めることができますか?
編集:
ストリームを録画し、ビデオトラックが検出されない場合、しばらくするとビデオトラックが検出されたログが表示されますが、それなしで録画がすでに開始されているため、録画されたストリームにはビデオトラックがありません。
ストリーム記録のログ_ffmpeg -loglevel debug -y -i rtmp://stream-engine/myStream -c copy -f flv output.flv
_:
ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.38) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --Host-cflags= --Host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libvpx --enable-vda libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Splitting the commandline. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-i' ... matched as input file with argument 'rtmp://stream-engine/myStream'. Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'. Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'. Reading option 'output.flv' ... matched as output file. Finished splitting the commandline. Parsing a group of options: global . Applying option loglevel (set logging level) with argument debug. Applying option y (overwrite output files) with argument 1. Successfully parsed a group of options. Parsing a group of options: input file rtmp://stream-engine/myStream. Successfully parsed a group of options. Opening an input file: rtmp://stream-engine/myStream. [rtmp @ 0x7fa1a5d00c60] No default whitelist set [tcp @ 0x7fa1a5c0dac0] No default whitelist set [rtmp @ 0x7fa1a5d00c60] Handshaking... [rtmp @ 0x7fa1a5d00c60] Type answer 3 [rtmp @ 0x7fa1a5d00c60] Server version 13.14.10.13 [rtmp @ 0x7fa1a5d00c60] Proto = rtmp, path = /source/S1IwVWndb, app = source, fname = S1IwVWndb [rtmp @ 0x7fa1a5d00c60] Server bandwidth = 5000000 [rtmp @ 0x7fa1a5d00c60] Client bandwidth = 5000000 [rtmp @ 0x7fa1a5d00c60] New incoming chunk size = 4096 [rtmp @ 0x7fa1a5d00c60] Creating stream... [rtmp @ 0x7fa1a5d00c60] Sending play command for 'S1IwVWndb' [flv @ 0x7fa1a6801200] Format flv probed with size=2048 and score=100 [flv @ 0x7fa1a6801200] Before avformat_find_stream_info() pos: 13 bytes read:2271 seeks:0 [flv @ 0x7fa1a6801200] Unknown type |RtmpSampleAccess [flv @ 0x7fa1a6801200] max_analyze_duration 5000000 reached at 5019000 microseconds st:0 [flv @ 0x7fa1a6801200] After avformat_find_stream_info() pos: 87184 bytes read:87184 seeks:0 frames:241 Input #0, flv, from 'rtmp://stream-engine/myStream': Metadata: Server : NGINX RTMP (github.com/arut/nginx-rtmp-module) displayWidth : 1280 displayHeight : 544 fps : 24 profile : level : Duration: 00:00:00.00, start: 344.126000, bitrate: N/A Stream #0:0, 241, 1/1000: Audio: aac (LC), 48000 Hz, 5.1, fltp, 128 kb/s Successfully opened the file. Parsing a group of options: output file output.flv. Applying option c (codec name) with argument copy. Applying option f (force format) with argument flv. Successfully parsed a group of options. Opening an output file: output.flv. [file @ 0x7fa1a5c1cec0] Setting default whitelist 'file,crypto' Successfully opened the file. Output #0, flv, to 'output.flv': Metadata: Server : NGINX RTMP (github.com/arut/nginx-rtmp-module) displayWidth : 1280 displayHeight : 544 fps : 24 profile : level : encoder : Lavf57.25.100 Stream #0:0, 0, 1/1000: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, 5.1, 128 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help cur_dts is invalid (this is harmless if it occurs once at the start per stream) [flv @ 0x7fa1a6801200] video stream discovered after head already parsed [flv @ 0x7fa1a6801200] New video stream 0:1 at pos:144269 and DTS:352.667s size= 371kB time=00:00:22.57 bitrate= 134.6kbits/s speed= 1.3x video:0kB audio:353kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.082170% Input file #0 (rtmp://stream-engine/myStream): Input stream #0:0 (audio): 1058 packets read (361263 bytes); Total: 1058 packets (361263 bytes) demuxed Output file #0 (output.flv): Output stream #0:0 (audio): 1058 packets muxed (361263 bytes); Total: 1058 packets (361263 bytes) muxed 0 frames successfully decoded, 0 decoding errors [AVIOContext @ 0x7fa1a5c1cf80] Statistics: 3 seeks, 1061 writeouts [AVIOContext @ 0x7fa1a5d00fa0] Statistics: 2401247 bytes read, 0 seeks [rtmp @ 0x7fa1a5d00c60] Deleting stream..
Mulvyaコメントのおかげで: 受信したストリームには一貫したビデオトラックがありません 、analyzedurationとprobesizeの値を増やすと、ストリームを正しく処理するために必要なすべての情報をffmpegで検出する機会が増えます。
Ffmpegドキュメントに基づくデフォルト値: https://ffmpeg.org/ffmpeg-formats.html#Format-Options は次のとおりです。
高品質のストリームにはどちらが十分ではありません。