[FFmpeg-user] Changing video frame rate and keeping duration intact

Idan Yael idan.yael at gmail.com
Wed Jun 14 08:57:11 EEST 2017

I am trying to segment a video file, transcode each of the segments and
then stitch them all back to one. The process is working but I have noticed
that the final file has a different duration than the original one.
Probably because I am transcoding to a fixed frame rate which is different
from the source frame rate.

To segment the video I use:

ffmpeg -y -i video_only.mp4 -c copy -flags -global_header -segment_time 50
-break_non_keyframes 0 -reset_timestamps 0 \
  -segment_list file_segs.list -segment_format mp4 -segment_list_type
ffconcat -write_empty_segments 0 \
  -f segment file_seg-%d.mp4

Then, each segment is transcoded with this command:

ffmpeg -y -i $f -vcodec libx264 -vsync 1 -crf 18 -vf "fps=30" -pix_fmt
yuv420p -preset:v fast -profile:v main -level:v 4.1 transcoded/$f

And finally, concat:

ffmpeg -y -f concat -i file_segs.list -c:v copy -c:a copy -movflags
+faststart video_final.mp4

I've tried using "-r 30" instead on the filter (-vf), the same result. As
this is a part of a transcoding system I prefer not to check for the input
file fps before transcoding as it can be anything - variable fps too (which
is not so easy to detect)

Is there any way I can keep the duration intact while changing the frame
rate in this type of transcoding flow?


More information about the ffmpeg-user mailing list