[英]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-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.我尝试了很多选项并在这里阅读了尽可能多的问题,但我找不到增加 P 帧数量或至少启用 B 帧的方法。
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.使用
-bf
选项可以设置 B 帧的数量。
But you have to use ffmpeg
to reencode the input in order to change the GOP structure.但是您必须使用
ffmpeg
重新编码输入以更改 GOP 结构。
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:生成的 output 应具有以下 GOP 结构:
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
.在 shell 上,您可以轻松地 output 使用
ffprobe
的 GOP 结构。
Analyze 2 seconds of the file:分析2秒的文件:
ffmpeg -i input.mp4 -map 0 -c copy -t 2 -f nut pipe: | ffprobe pipe: -show_frames | grep pict_type
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.