minterpolate=fps=original_fps fails because FFmpeg has no variable named original_fps inside the filter graph.
You must supply an actual number (e.g. 30, 60, 25, …).
Therefore you have to query the frame-rate first, then inject that number into the command.
Below are two practical ways to do it.
- Get the frame-rate with MediaMetadataRetriever
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(videoPath);
// returns a string like "30.000000"
String fpsStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE);
float fps = Float.parseFloat(fpsStr); // 30.0
mmr.release();
Now build the FFmpeg command with that value:
String[] cmd = {
"-ss", "70", "-to", "85", "-i", src.getAbsolutePath(),
"-an",
"-filter_complex",
"[0:v]crop=640:360:100:200,setpts=4*PTS,minterpolate=fps=" + fps + ":mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1[v]",
"-map", "[v]",
"-c:v", "libx264", "-preset", "slow", "-crf", "18",
dst.getAbsolutePath()
};
- Let FFmpeg itself read the frame-rate (no MediaMetadataRetriever)
If you prefer a pure FFmpeg solution you can use the fps filter to normalise the rate first, then feed that into minterpolate.
This keeps the original effective frame-rate without hard-coding it:
ffmpeg \
-ss 70 -to 85 -i input.mp4 \
-an \
-filter_complex "\
[0:v]crop=640:360:100:200,\
fps=fps=30,\
setpts=4*PTS,\
minterpolate=fps=30:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1[v]" \
-map "[v]" \
-c:v libx264 -preset slow -crf 18 \
output.mp4
Replace the two 30s with whatever you know the source to be, or obtain it via MediaMetadataRetriever as shown above.
Key point
minterpolate must receive a numeric literal for fps.
Use MediaMetadataRetriever (or ffprobe) once, cache the value, then inject it into the filter string.