Categories
Video

GOP configuration with FFmpeg

Test

You can use ffprobe to investigate the GOP configuration of a h264 videofile. Some formats require a certain GOP structure to work. In your GOP structure you got I-Frames,P-Frames and B-frames.

The example below has en I-frame each 50 frames. and 3 b-frames for between each P-frame. B-frames can be adaptable so you might see fewer B frames between som P-frames. this structure is compatible for HLS streaming.

[code language=”bash”]
ffprobe version git-2017-02-15-1b90e24 Copyright (c) 2007-2017 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
configuration: –prefix=/home/wowza/ffmpeg_build –extra-cflags=-I/home/wowza/ffmpeg_build/include –extra-ldflags=-L/home/wowza/ffmpeg_build/lib –bindir=/home/wowza/bin –extra-libs=-ldl –enable-gpl –enable-nonfree –enable-libfdk_aac –enable-libmp3lame –enable-libopus –enable-libvorbis –enable-libx264
libavutil 55. 47.100 / 55. 47.100
libavcodec 57. 80.100 / 57. 80.100
libavformat 57. 66.102 / 57. 66.102
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 73.100 / 6. 73.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘20170623_194545_direkt_720p.mp4’:
Metadata:
major_brand : f4v
minor_version : 0
compatible_brands: isommp42m4v
creation_time : 2017-06-23T17:45:45.000000Z
Duration: 00:45:50.69, start: 0.000000, bitrate: 3206 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280×720, 3004 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-06-23T17:45:45.000000Z
handler_name : WowzaStreamingEngine
encoder : WowzaStreamingEngine
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 195 kb/s (default)
Metadata:
creation_time : 2017-06-23T17:45:45.000000Z
handler_name : WowzaStreamingEngine
pict_type=I
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=B
pict_type=P
pict_type=B
pict_type=B
pict_type=P
pict_type=I
pict_type=B
pict_type=B
pict_type=B
pict_type=P
[/code]

Setting GOP structure

This is a example of trying to convert an prores file to a Sony MXF compatible file. This example does not work in Vegas.

[code language=”bash”]
ffmpeg.exe -i oas.mov -pix_fmt yuv422p10le -filter_complex "[0:a]pan=mono|c0=c0[a0];[0:a]pan=mono|c0=c1[a1]" -map 0:v -map "[a0]" -map "[a1]" -c:v libx264 -profile:v high422 -level 4.1 -preset superfast -b:v 4M -coder 1 -x264-params keyint=24:min-keyint=24:scenecut=0:bframes=2:b-adapt=0:ref=2:b-adapt=0:open-gop=1 -tune fastdecode -c:a pcm_s16le -ar 48000 -f mxf oas.test57.mxf
[/code]

keyint=24

Setting a I-frame

min-keyint=24

I-frames can be adaptable , setting this to the same as keyint disables this.

scenecut=0

adaptable can be adaptable and add a I-frame if the picture changes to much. adding scencut=0 disables this, now forcing x264 to add a i-frame each 24 frame.

bframes=2

Setting how many b-frames there can be between each p-frame.

b-adapt=0

B-frames can be adaptable adding more or less b-frames then 2 b-frames. this settings disables that.

open-gop=1

Normaly x264 produces closed gop. resulting in the last frame och each GOP being a p-frame. adding open-gop=1 creates a open gop with b-frame instead.