[FFmpeg-user] Fixed GOP encoding for HLS

Anatol anatol2002 at gmail.com
Wed Dec 5 05:19:03 CET 2012


Your command line does not 'force' key-frame every 12 frames, it just
'recommends' it. Default ffmpeg settings has 'scenecut' key-frames
generation. This option is vital for preserving video quality. In order to
'force' key frames at certain rate u actually have to spell-out the exact
timings that u want them to appear at. Use 'froce_keyframes' command line
option. DON'T turn of the scenecut key frames.

By the way half sec GOPs are by far much too small, this also
can degrade the quality. 2-3 sec is enough.

On Wed, Dec 5, 2012 at 1:15 AM, Andrew Sinclair <ajsinclair at gmail.com>wrote:

> Hi,
>
> I am trying to encode and segment for Apple HLS devices and am look for any
> tips from anyone that has mastered this.
>
> I am trying to get the segments in the .m3u8 files to be exactly aligned
> for so that each segment is precisely 6 seconds long and I have experience
> with encoders that do this quite well as I suspect that not being aligned
> is causing issues on an Android device I am working on.
>
> To get this aligned I am encoding with frame rate 24 and a min/max GOP of
> 12 (based on notes in the ffmpeg docs on the -segment command) however I
> still see variation in the segment size.
>
> Can anyone tell me what the optimal settings for this are? Does anyone know
> how the segments end up not aligned if I am forcing requesting keyframes
> every 12 frames and this shows up in ffprobe?
>
> Example encode:
> ffmpeg -i 131375031.mp4 -vcodec libx264 -b:v 500k -r 24 -g 12 -keyint_min
> 12 -coder 0 -profile:b baseline out_gop12.ts
>
> Example segment:
> ffmpeg -i out_gop12.ts -codec copy -map 0  -f segment -segment_list
> playlist_gop12.m3u8 -segment_time 6 out_gop12_seg6-%03d.ts
>
> Resulting index file extract (note the segment lengths vary a lot!):
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-ALLOWCACHE:1
> #EXTINF:7.719244,
> out_gop12_seg6-000.ts
> #EXTINF:4.750000,
> out_gop12_seg6-001.ts
> #EXTINF:6.125000,
> out_gop12_seg6-002.ts
> #EXTINF:6.541667,
> out_gop12_seg6-003.ts
> #EXTINF:9.333333,
> out_gop12_seg6-004.ts
> #EXTINF:1.750000,
> out_gop12_seg6-005.ts
> #EXTINF:6.666667,
> out_gop12_seg6-006.ts
> #EXTINF:6.166667,
> out_gop12_seg6-007.ts
> #EXTINF:5.166667,
> out_gop12_seg6-008.ts
> #EXTINF:6.625000,
> out_gop12_seg6-009.ts
> #EXTINF:6.541667,
> out_gop12_seg6-010.ts
> #EXTINF:6.291667,
> out_gop12_seg6-011.ts
> #EXTINF:9.583333,
> out_gop12_seg6-012.ts
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list