聲明:轉帖時請註明出處ide
版本:函數
ffmpeg 3.0編碼
ffmpeg version 3.0-static Copyright (c) 2000-2016 the FFmpeg developers日誌
轉碼命令:code
./ffmpeg -i test_2.flv -vcodec libx264 -b:v 300000 -r 10 -report -y -f flv test_2out.flv -vcodec libx264 -b:v 900000 -r 12 -report -y -f flv test_3out.flv視頻
一轉多時輸出日誌:ip
frame= 43 fps=0.0 q=27.0 q=14.0 size= 3kB time=00:00:04.09 bitrate= 5.5kbits/s dup=0 drop=31 speed=8.19x ... frame= 57 fps= 57 q=26.0 q=15.0 size= 96kB time=00:00:05.53 bitrate= 141.5kbits/s dup=0 drop=43 speed= 5.5x ... frame= 69 fps= 46 q=26.0 q=17.0 size= 156kB time=00:00:06.71 bitrate= 189.8kbits/s dup=0 drop=52 speed=4.45x ... frame= 79 fps= 26 q=25.0 Lq=17.0 size= 423kB time=00:00:07.83 bitrate= 442.3kbits/s dup=0 drop=60 speed=2.57x print_report finish:18812880 video:1181kB audio:243kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Input file #0 (test_2.flv): Input stream #0:0 (video): 119 packets read (564093 bytes); 118 frames decoded; Input stream #0:1 (audio): 336 packets read (62299 bytes); 335 frames decoded (343040 samples); Total: 455 packets (626392 bytes) demuxed Output file #0 (test_2out.flv): Output stream #0:0 (video): 79 frames encoded; 79 packets muxed (301597 bytes); Output stream #0:1 (audio): 297 frames encoded (342144 samples); 298 packets muxed (124551 bytes); Total: 377 packets (426148 bytes) muxed Output file #1 (test_3out.flv): Output stream #1:0 (video): 95 frames encoded; 95 packets muxed (907510 bytes); Output stream #1:1 (audio): 297 frames encoded (342144 samples); 298 packets muxed (124551 bytes); Total: 393 packets (1032061 bytes) muxed 453 frames successfully decoded, 0 decoding errors
經過以上的日誌能夠看出,只會選擇一路進行輸出,另一路的編碼信息是看不到的。it
frame= 79 fps= 26 q=25.0 Lq=17.0 size= 423kB time=00:00:07.83 bitrate= 442.3kbits/s dup=0 drop=60 speed=2.57xio
Output stream #0:0 (video): 79 frames encoded; 79 packets muxed (301597 bytes);ast
Output stream #1:0 (video): 95 frames encoded; 95 packets muxed (907510 bytes);
即:
Output stream 0的視頻 編碼統計 信息輸出, Output stream 1的視頻 編碼統計 信息並無輸出。
修改ffmpeg代碼,使stream 0和stream 1的視頻編碼統計信息都輸出,即
frame= 42 fps=0.0 q=28.0 size= 2kB time=00:00:03.99 bitrate= 4.7kbits/s dup=0 drop=30 speed=7.98x frame= 50 fps=0.0 q=15.0 size= 82kB time=00:00:03.99 bitrate= 167.2kbits/s dup=0 drop=30 speed=7.98x ... frame= 56 fps= 55 q=26.0 size= 87kB time=00:00:05.37 bitrate= 133.2kbits/s dup=0 drop=41 speed=5.25x frame= 67 fps= 65 q=15.0 size= 305kB time=00:00:05.37 bitrate= 464.9kbits/s dup=0 drop=41 speed=5.25x ... frame= 68 fps= 45 q=27.0 size= 148kB time=00:00:06.60 bitrate= 184.1kbits/s dup=0 drop=51 speed=4.33x frame= 81 fps= 53 q=17.0 size= 468kB time=00:00:06.60 bitrate= 580.0kbits/s dup=0 drop=51 speed=4.33x ... frame= 78 fps= 25 q=26.0 Lsize= 419kB time=00:00:07.70 bitrate= 445.3kbits/s dup=0 drop=59 speed=2.45x print_report nb_output_stream:4, nb_output_files:2, num:1, nb_streams:2, ost_index:2 frame= 93 fps= 30 q=17.0 Lsize= 1001kB time=00:00:07.70 bitrate=1065.3kbits/s dup=0 drop=59 speed=2.45x video:1166kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Input file #0 (test_2.flv): Input stream #0:0 (video): 117 packets read (562734 bytes); 116 frames decoded; Input stream #0:1 (audio): 331 packets read (61405 bytes); 330 frames decoded (337920 samples); Total: 448 packets (624139 bytes) demuxed Output file #0 (test_2out.flv): Output stream #0:0 (video): 78 frames encoded; 78 packets muxed (298887 bytes); Output stream #0:1 (audio): 293 frames encoded (337536 samples); 294 packets muxed (122880 bytes); Total: 372 packets (421767 bytes) muxed Output file #1 (test_3out.flv): Output stream #1:0 (video): 93 frames encoded; 93 packets muxed (895256 bytes); Output stream #1:1 (audio): 293 frames encoded (337536 samples); 294 packets muxed (122880 bytes); Total: 387 packets (1018136 bytes) muxed 446 frames successfully decoded, 0 decoding errors
其中nb_frames_drop,大約等於(視頻輸入幀數-視頻1輸出幀數) + (視頻輸入幀數-視頻1輸出幀數)
即:
116 - 78 = 38, 116 - 93 = 23, 38 + 23 = 61,其中drop了59幀。
在do_video_out()函數中, nb_frames_drop值的計算過程。
if (nb0_frames == 0 && ost->last_dropped) { nb_frames_drop++; av_log(NULL, AV_LOG_VERBOSE, "*** dropping frame %d from stream %d at ts %"PRId64"\n", ost->frame_number, ost->st->index, ost->last_frame->pts); } if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) { if (nb_frames > dts_error_threshold * 30) { av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1); nb_frames_drop++; return; } nb_frames_dup += nb_frames - (nb0_frames && ost->last_dropped) - (nb_frames > nb0_frames); av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1); }