[FFmpeg-user] Fixed GOP encoding for HLS
Andrew Sinclair
ajsinclair at gmail.com
Wed Dec 5 02:40:40 CET 2012
Looks like the frames are getting out of sync after the first 6 or so (see
below which is ffprobe via python formatting). I have also attached a
sample m3u8 off an Envivio encoder below which has the keyframes right on
10 secs
I will have a play with the current options but having the ability to force
a keyframe at a specified interval would be ideal for this purpose.
I Frame: 0
I Frame: 3
I Frame: 12
I Frame: 24
I Frame: 36
I Frame: 48
I Frame: 60
I Frame: 72
I Frame: 83
I Frame: 95
I Frame: 107
I Frame: 110
I Frame: 119
I Frame: 131
I Frame: 143
I Frame: 155
I Frame: 167
I Frame: 179
I Frame: 185
I Frame: 191
I Frame: 203
I Frame: 215
I Frame: 227
I Frame: 239
I Frame: 245
I Frame: 251
I Frame: 263
I Frame: 275
I Frame: 287
I Frame: 299
I Frame: 311
I Frame: 323
I Frame: 335
#EXT-X-MEDIA-SEQUENCE:4826
#EXT-X-PROGRAM-DATE-TIME:2012-12-03T20:21:50Z
#EXTINF:10,
20121203T065726-1200-4826.ts
#EXT-X-PROGRAM-DATE-TIME:2012-12-03T20:22:00Z
#EXTINF:10,
20121203T065726-1200-4827.ts
#EXT-X-PROGRAM-DATE-TIME:2012-12-03T20:22:10Z
#EXTINF:10,
20121203T065726-1200-4828.ts
#EXT-X-PROGRAM-DATE-TIME:2012-12-03T20:22:19Z
#EXTINF:10,
20121203T065726-1200-4829.ts
#EXT-X-PROGRAM-DATE-TIME:2012-12-03T20:22:29Z
#EXTINF:10,
20121203T065726-1200-4830.ts
On 5 December 2012 11:00, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Wednesday 2012-12-05 10:15:46 +1100, Andrew Sinclair 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
>
> Can you confirm that the resulting ts has the timestamp at the exact
> location? Or in other words, are you sure that -g 12 -keyint_min 12
> produces a fixed GOP of 12 frames (ffprobe -show_packets or
> -show_frames should confirm this).
>
> > 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!):
>
> The trick I used was using -force_key_frames in ffmpeg and then use a
> reasonable value for -segment_time_delta (half the value of the
> framerate should be safe), check the segment examples.
>
> We could eventually extend -force_key_frames to accept an expression,
> in case specifying 0,6,12,... etc. is awkward.
> --
> FFmpeg = Fast Fancy Merciless Peaceful Elegant Guide
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
More information about the ffmpeg-user
mailing list