简体   繁体   中英

ffmpeg can't change number of B-frames

When streaming from a source I keep receiving frames following the same pattern: I-frame P-frame I-frame P-frame I-frame P-frame... . I tried many options and read as many questions here as I found, but I can't find a way to increse the number of P-frame or at least enable B-frames.

Mainly it seems that I should use:

 ffprobe rtsp://localhost/video -g 30 -bf 3 -show_frames -of csv

What am I doing wrong?

With the -bf option you set the number of B-frames.

But you have to use ffmpeg to reencode the input in order to change the GOP structure.

Take for example:

ffmpeg -i input.mp4 -c:v libx264 -g 12 -bf 2 -flags +cgop output.mp4

The resulting output should have the following GOP structure:

position 1 2 3 1 2 3 1 2 3 1 2 3
frame I B B P B B P B B P B B I

On a shell you can easily output the GOP structure with ffprobe .

Analyze 2 seconds of the file:

ffmpeg -i input.mp4 -map 0 -c copy -t 2 -f nut pipe: | ffprobe pipe: -show_frames | grep pict_type

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM