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.