Keyframe frequency (Handbrake for HLS)

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Post Reply
Chris Canfield
Posts: 4
Joined: Fri Jan 12, 2018 5:34 pm

Keyframe frequency (Handbrake for HLS)

Post by Chris Canfield »

Hello! We're looking to segment our videos using HLS, but to do that we need to set a keyframe / sync frame / reference frames at every 5 seconds. Is there a way to tell Handbrake to encode with keyframes at fixed intervals?
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by mduell »

Set keyint and min-keyint to 5 times your framerate.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS »

To be clear, using a HandBrake preset using the x264 encoder, add keyint=5:min-keyint=5 to the additional options field on the video tab. The Production presets in the nightly build do something similar, for reference.
Deleted User 11865

Re: Keyframe frequency (Handbrake for HLS)

Post by Deleted User 11865 »

Guys, that's 5 frames, not 5 seconds. If you want it every 5 seconds, you need to multiply the frame rate by 5 ;)

Also, using intra-refresh=1 might help in an HLS streaming scenario, though I have never tried either (of HLS and PIR) myself.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS »

Ah, sorry. mduell had it correct and I fubared it. So if your frame rate is 29.97 or 30, you probably want keyint=150:min-keyint=150 which is 5*30, etc.
Chris Canfield
Posts: 4
Joined: Fri Jan 12, 2018 5:34 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by Chris Canfield »

Thanks Everyone! With a minor modification, this worked perfectly. I did have to add scenecut=0, which seems like it would be redundant with min-keyint, but didn't give clean boundaries without it. So the final string was "keyint=150:min-keyint=150:scenecut=0:"

Thank you!
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS »

Good call on scenecut. Glad it's working for you. :D
Post Reply