I have a case where i have a mkv file encoded to a 2.5 GB file with x264/CRF settings, in this file group of pictures are not of equal duration (i.e 2,4 or 6 seconds ...).
Now i want to create a mpeg-dash version of the file by extracting the video track to mp4 and set the keyframe interval to 2sec losslessly preserving size (minus other audio and subtitle tracks)
What i already have that work:
Fix keyframe to 2s with x264:
-codec:v libx264 -force_key_frames 'expr:gte(t,n_forced*2)' -movflags faststart
But it require also encoding settings that change the quality:
-b:v 3500k -maxrate 6000k -bufsize 3500k
In this case i don't need to change the quality from CRF encoding, just change keyframe interval and set faststart flag.
note: I have detailed bitrate informations about the file obtained by parsing output of ffprobe: average, min and max bitrate in kb/s. Please avoid solution using -crf 0, mpeg-dash files are later crypted using MP4Box that crash with CRF encoded files.
How can i do this using ffmpeg ?
Edit:
Sorry my question is not clear, i'm fine with re-encode, i want to preserve quality as much as possible.
Using a little more than source mean bitrate for the -b:v parameter the resulting file size is almost same as source, metric test results are not as good i expect:
PSNR 41.03 (expected 44+)
VMAF 76.32 (expected 92+)
Is my bitrate approch good ? Is there anything i can try to improve metric results ?