4

A very annoying situation...
I have an MPG2 video that is at the framerate of 29.97, yet when converting to MP4 frames are duplicated.

That command (straight conversion, no options):
ffmpeg -i ~/Desktop/file.mpg ~/Desktop/file.mp4
causes duplicated frames...

While setting the framerate with:
ffmpeg -i ~/Desktop/file.mpg -framerate 29.97 ~/Desktop/file.mp4
Doesn't work either!

Leading me to try:
ffmpeg -i ~/Desktop/file.mpg -r 29.97 ~/Desktop/file.mp4
Still with duplicated frames!

Finally I tried ffmpeg's 3rd framerate option!:
ffmpeg -i ~/Desktop/file.mpg -vf fps=fps=29.97 ~/Desktop/file.mp4

Except, when it outputted, the audio/video was out of sync!

Which FPS option should I use?

2 Answers 2

3

Use

ffmpeg -i ~/Desktop/file.mpg -vsync 0 ~/Desktop/file.mp4

This skips duplication.

-vsync passthrough is synonymous with -vsync 0.

4
  • This sounds like it might work, but I get innumerable errors!
    – Henry7720
    Commented Oct 3, 2017 at 22:39
  • DTS errors? You can ignore those if the file plays correctly. Show the full log.
    – Gyan
    Commented Oct 4, 2017 at 5:22
  • where -vsync 0 is the same as the newer value -vsync passthrough. Each frame is passed with its timestamp from the demuxer to the muxer. Commented Sep 16, 2019 at 17:52
  • @l--marcl you should post this answer. this was exactly what I needed. I have a filtergraph that creates an intro video with an image input on a solid color bg (all through filters) and concats it to my video. everything seemed fine, but it outputted all duped frames. Now the problem is solved!
    – phip
    Commented Aug 29, 2022 at 3:39
1

-vsync is deprecated now, so you should use -fps_mode instead.

By default, the fps_mode is auto, so it may change your fps automatically. For example, the original source is variable frame rate, but ffmpeg may decide to change it to constant frame rate automatically, which may result in duplicated and dropped frames.

To prevent any fps change, set -fps_mode passthrough. (It's the same as -vsync 0 or -vsync passthrough).

For more info, see ffmpeg documentation.

ffmpeg -i ~/Desktop/file.mpg -fps_mode passthrough ~/Desktop/file.mp4

You must log in to answer this question.

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