<p>Several files generated in XAVC have 2 B-frames before the I-frame and I've been trying to transcode those files using <code>ffmpeg</code> to match the structure at a lower resolution/bitrate, but I've been unable to do so. I was hoping that <code>-force_key_frames source</code> would do that, but it always makes the first frame a key frame, so is there a way to match the <code>pict_type</code> and have 2 B-frames before the I-frame while transcoding with <code>ffmpeg</code>?</p>

CC BY-SA 4.0
2024-09-21T04:22:30.727Z
How are you determining the order of the frames in the source?
Gyan
CC BY-SA 4.0
2024-09-24T18:10:00.750Z
This command outputs the frames and then also stepping through the `ffmpeg` code with a debugger:
`ffprobe -show_entries frame=pts,pkt_pos,pict_type -of csv=p=0 -I test.mp4`
Dave Johansen
<ffmpeg><transcoding><keyframes>
Generating B-frames before I-frame with ffmpeg (like XAVC)
Dave Johansen
# Generating B-frames before I-frame with ffmpeg (like XAVC)

(Asked by: username_0 on 2024-09-21)

Several files generated in XAVC have 2 B-frames before the I-frame and I've been trying to transcode those files using `ffmpeg` to match the structure at a lower resolution/bitrate, but I've been unable to do so. I was hoping that `-force_key_frames source` would do that, but it always makes the first frame a key frame, so is there a way to match the `pict_type` and have 2 B-frames before the I-frame while transcoding with `ffmpeg`?

**Tags:** ffmpeg, transcoding, keyframes

> **Comments:**
> **username_1**: How are you determining the order of the frames in the source?  
> **username_0**: This command outputs the frames and then also stepping through the `ffmpeg` code with a debugger: `ffprobe -show_entries frame=pts,pkt_pos,pict_type -of csv=p=0 -I test.mp4`  

---

## 0 answers

