mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.91k stars 2.87k forks source link

Passing ffmpeg's -force_key_frames to mpv encoder? #8557

Open twilson90 opened 3 years ago

twilson90 commented 3 years ago

I'm using mpv in encoding mode (--o=...), trying to make it so it outputs a keyframe every second, regardless of frame rate (which can potentially vary from 24 to 60fps in one encoding).

The way this is done in ffmpeg is with the helpful parameter -force_key_frames which can take a measure of time or an expression to calculate how often there should be a keyframe.

I've tried adding it as a key/value in --vd-lavc-o and --demuxer-lavf-o but I get AVOption 'force_key_frames' not found and Could not set AVOption force_key_frames='expr:gte(t,n_forced*1)' respectively.

As far as I can tell I can only define my keyframe interval by setting ovcopts-add=g=<number> or ovcopts-add=x264opts=%36%keyint=<number>:min-keyint=<number>:no-scenecut, but these are not capable of defining intervals as time unlike -force_key_frames.

Is there any way to do this with a pre-existing mpv commandline argument without altering the source code? If not, how can I add it as a parameter to my fork of MPV?

po5 commented 1 week ago

I would like to have this feature, there is a PR that was closed due to lack of replies in #8580.