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 » Fri Jan 12, 2018 5:46 pm

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: 6070
Joined: Sat Apr 21, 2007 8:54 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by mduell » Fri Jan 12, 2018 6:32 pm

Set keyint and min-keyint to 5 times your framerate.

User avatar
BradleyS
Moderator
Posts: 1321
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS » Sat Jan 13, 2018 7:37 am

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.

User avatar
Rodeo
HandBrake Team
Posts: 11907
Joined: Tue Mar 03, 2009 8:55 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by Rodeo » Sat Jan 13, 2018 8:18 am

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: 1321
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS » Sat Jan 13, 2018 9:12 am

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 » Thu Jan 18, 2018 4:43 pm

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: 1321
Joined: Thu Aug 09, 2007 12:16 pm

Re: Keyframe frequency (Handbrake for HLS)

Post by BradleyS » Thu Jan 18, 2018 4:46 pm

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

Post Reply