O fluxo recebido não tem trilha de vídeo consistente

2

Estou transmitindo um vídeo para um mecanismo de streaming (nginx-rtmp) usando o ffmpeg usando o seguinte comando:

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

No entanto, quando estou fazendo um ffprobe desse fluxo, diretamente para o mecanismo de streaming, às vezes não há vídeo no fluxo.

O comando para testar o fluxo: ffprobe -loglevel 'debug' rtmp://stream-engine/mystream

95% Eu recebo a seguinte saída:

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

Que está tudo bem, recebo faixas de vídeo e áudio.

5% das vezes recebo o seguinte:

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

Nós tentamos muitas opções, muitos codificadores. Nós o reproduzimos com diferentes fontes de fluxo (ffmpeg, wowzaGoCoder, wirecast) e diferentes mecanismos de streaming (wowza, nginx-rtmp). Algumas configurações dificultam a reprodução, mas ainda acontece ...

Como pode ser que o mesmo fluxo possa ter uma faixa de vídeo "às vezes"? O que estamos perdendo? Como podemos torná-lo mais resistente a esse bug (muito frustrante)?

Editar:

Se gravarmos o fluxo, e se ele não detectar a trilha de vídeo, o registro exibirá após algum tempo que a trilha de vídeo foi detectada, mas como a gravação já começou sem ela, o fluxo gravado não tem trilha de vídeo. / p>

Registro da gravação de fluxo 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..

    
por Pat-rice 24.08.2017 / 11:18

1 resposta

1

Obrigado ao comentário mulvya: Stream recebido não t tem trilha de vídeo consistente , aumentando o valor de analysisuration e o probesize dá mais chances ao ffmpeg de detectar todas as informações necessárias para processar corretamente o fluxo.

Valor padrão com base na documentação do ffmpeg: link são:

  • 5s para analisar a duração
  • 5 MB para tamanho da sonda

Qual fluxo de alta qualidade não é suficiente.

    
por 24.08.2017 / 14:26