5

I have the following command cobbled together so far:

ffmpeg -i input.mp4 -filter_complex "\
    [0:v]trim=start=175.2:end=200.9,setpts=PTS-STARTPTS[v1]; \
    [0:a]atrim=start=175.2:end=200.9,asetpts=PTS-STARTPTS[a1]; \
    [0:v]trim=start=214.3:end=324,setpts=PTS-STARTPTS[v2]; \
    [0:a]atrim=start=214.3:end=324,asetpts=PTS-STARTPTS[a2]; \
    [v1][a1][v2][a2]concat=n=2:v=1:a=1[outv][outa]" \
    -map "[outv]" -map "[outa]" output.mp4

Extracting the clips and concatenating them into one video works fine. However, this command recodes the video to 25fps, as indicated by a warning:

[fc#0 @ 0000029e38732840] [vo0->#0:0 @ 0000029e38739b80] No information about the input framerate is available. Falling back to a default value of 25fps. Use the -r option if you want a different framerate.

I want it to keep the framerate of the original video, no matter what it is, and not drop or insert frames to change the framerate. If I use multiple input files, I want it to just use the framerate of the first one (because they’re gonna be the same anyway).

How do I achieve this?

1 Answer 1

4

It looks like a bug in FFmpeg version 7.0

We may fix it by adding -fps_mode passthrough argument.
According to the documentation:

passthrough (0) Each frame is passed with its timestamp from the demuxer to the muxer.


Testing:

Create synthetic 5fps video file (for testing):
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=5 -f lavfi -i sine=frequency=400 -vcodec libx264 -acodec aac -pix_fmt yuv420p -t 400 input.mp4

Executing the original command with FFmpeg 5.1.2:
ffmpeg -y -i input.mp4 -filter_complex "[0:v]trim=start=175.2:end=200.9,setpts=PTS-STARTPTS[v1];[0:a]atrim=start=175.2:end=200.9,asetpts=PTS-STARTPTS[a1];[0:v]trim=start=214.3:end=324,setpts=PTS-STARTPTS[v2];[0:a]atrim=start=214.3:end=324,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

There is no warning message with FFmpeg 5.1.2.

Checking the framerate of output.mp4 using MediaInfo:

Frame rate mode                          : Constant
Frame rate                               : 5.000 FPS

Executing the original command with FFmpeg 7.0:
./ffmpeg-7.0-full_build/bin/ffmpeg -y -i input.mp4 -filter_complex "[0:v]trim=start=175.2:end=200.9,setpts=PTS-STARTPTS[v1];[0:a]atrim=start=175.2:end=200.9,asetpts=PTS-STARTPTS[a1];[0:v]trim=start=214.3:end=324,setpts=PTS-STARTPTS[v2];[0:a]atrim=start=214.3:end=324,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

There is a warning message "No information about the input framerate is available".

Checking the framerate of output.mp4 using MediaInfo:

Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS

FFmpeg 7.0 changed the framerate to 25 fps.


Executing the updated (with -fps_mode passthrough) command with FFmpeg 7.0:
./ffmpeg-7.0-full_build/bin/ffmpeg -y -i input.mp4 -fps_mode passthrough -filter_complex "[0:v]trim=start=175.2:end=200.9,setpts=PTS-STARTPTS[v1];[0:a]atrim=start=175.2:end=200.9,asetpts=PTS-STARTPTS[a1];[0:v]trim=start=214.3:end=324,setpts=PTS-STARTPTS[v2];[0:a]atrim=start=214.3:end=324,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

There is a new warning message: "MB rate (84000000) > level limit (16711680)" (another bug?).

Checking the framerate of output.mp4 using MediaInfo:

Format profile                           : [email protected]
...
Frame rate mode                          : Constant
Frame rate                               : 5.000 FPS

Most video players ignore the "Level", but if level 6.2 is problematic, try using other version of FFmpeg.

1
  • Did not expect that it would be an actual bug. Thank you so much for your investigation.
    – Timwi
    Commented Jun 1 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .