Empfangene Streams haben keine konsistente Videospur

1137
Pat-rice

Ich streame ein Video zu einer Streaming-Engine (nginx-rtmp) mit ffmpeg mit folgendem Befehl:

ffmpeg -re -fflags +genpts -stream_loop -1 -i Sintel.mp4 -c copy -f flv rtmp://stream-engine/myStream

Wenn ich jedoch einen ffprobedieser Stream direkt an die Streaming-Engine durchführe, gibt es manchmal kein Video im Stream.

Der Befehl zum Testen des Streams: ffprobe -loglevel 'debug' rtmp://stream-engine/mystream

95% erhalte ich folgende Ausgabe:

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...

Was gut ist, ich bekomme sowohl Video- als auch Audiospuren.

In 5% der Fälle bekomme ich Folgendes:

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...

Wir haben viele Optionen ausprobiert, viele Encoder. Wir haben es mit verschiedenen Stream-Quellen (ffmpeg, wowzaGoCoder, wirecast) und verschiedenen Streaming-Engines (wowza, nginx-rtmp) reproduziert. Einige Konfigurationen erschweren die Wiedergabe, treten jedoch immer noch auf ...

Wie kann es sein, dass derselbe Stream "manchmal" eine Videospur hat? Was fehlt uns? Wie können wir diesen (sehr frustrierenden) Fehler widerstandsfähiger machen?

Bearbeiten:

Wenn wir den Stream aufnehmen und die Videospur nicht erkennt, zeigt das Protokoll nach einiger Zeit, dass die Videospur erkannt wird. Da jedoch die Aufzeichnung bereits ohne gestartet wurde, hat der aufgezeichnete Stream keine Videospur.

Protokoll der Stream-Aufzeichnung 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..

2
Versuchen Sie die Erkennung mit `-analyzeduration 20M -probesize 20M` vor` -i ... ` Gyan vor 7 Jahren 2
Außerdem kann stream_loop unzuverlässig sein und Lücken in Markierungen erzeugen. Gyan vor 7 Jahren 0
@ Mulvya vielen Dank, es hat funktioniert! Pat-rice vor 7 Jahren 0

1 Antwort auf die Frage

1
Pat-rice

Dank mulvya-Kommentar: Der empfangene Stream verfügt nicht über eine konsistente Videospur . Durch Erhöhen des Analysewerts und der Testgröße erhält ffmpeg mehr Chancen, alle Informationen zu ermitteln, die zur korrekten Verarbeitung des Streams erforderlich sind.

Standardwert basierend auf der ffmpeg-Dokumentation: https://ffmpeg.org/ffmpeg-formats.html#Format-Options sind:

  • 5s für die Analysedauer
  • 5 MB für die Sondengröße

Was für qualitativ hochwertige Streams nicht ausreicht.