VideoHelp Forum
+ Reply to Thread
Results 1 to 18 of 18
Thread
  1. Taking a 5.1 surround .mkv file and converting it to stereo mp4 using ffmpeg. My code looks like this

    ffmpeg -i input.mkv -vcodec copy -acodec libmp3lame output.mp4
    Even though input.mkv is a constant frame rate 23.98p file, what I’m getting is a variable frame rate 23.98 output file. Why is this? Thanks.
    Quote Quote  
  2. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Recommend you create a new ticket over at https://trac.ffmpeg.org/

    You'll need to post the complete un-cut log output of the ffmpeg run, and post a link to the sample input file used.

    Cheers.
    Quote Quote  
  3. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Actually, no.

    MediaInfo may report this resulting MP4 container as VFR because the generated flavour of MP4 container is able to support VFR; that doesn't certainly mean the frame actually varies, because MediaInfo did not analyse a statistic over the whole play time. And even if, the variance is probably only in very few milliseconds, you won't notice.
    Quote Quote  
  4. Interesting. I was using MediaInfo, and I also checked via VirtualDub and Adobe Premiere Pro. All three reported it as VFR...but you're right, it may not actually be.

    the generated flavour of MP4 container is able to support VFR
    Is it possible, with ffmpeg, to generate a different "flavour" of MP4 that does not support VFR? Just to be safe.
    Quote Quote  
  5. And even if, the variance is probably only in very few milliseconds, you won't notice.
    But that's the kind of thing that can make a video unreadable by standalone players. I've had an issue once with a downloaded MKV file which my brother's LG BRD player couldn't play because of a "variable framerate" flag, if I remember correctly it was solved by setting the correct framerate with TSMuxer then re-muxing it as MKV (all other methods failed).
    Quote Quote  
  6. Member
    Join Date
    Jul 2009
    Location
    United States
    Search Comp PM
    Originally Posted by seanmcnally View Post
    Is it possible, with ffmpeg, to generate a different "flavour" of MP4 that does not support VFR? Just to be safe.
    According to the docs it should be creating a CFR file. Try using ffprobe -show_streams to see what it says.

    Also you could try the first method here: https://trac.ffmpeg.org/wiki/How to speed up / slow down a video to recreate the the timestamps.
    Quote Quote  
  7. This is a feature, not a bug. ffmpeg uses a time base of 1/90000 for MP4 files. 24000/1001 cannot be represented exactly as N/90000 where N is an integer. It works out to 7353.75/90000. Using either 7353/90000 or 7354/90000 would result in a slow drift from the true frame rate. So ffmpeg uses a variable frame rate alternating between 3753/90000 for 1 frame and 3754/90000 for 3 frames. So technically it's variable frame rate. But it's effectively a constant frame rate.
    Last edited by jagabo; 16th Sep 2021 at 20:44.
    Quote Quote  
  8. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Originally Posted by jagabo View Post
    This is a feature, not a bug.


    Cough ... I used to use that phrase reasonably often, back in the day when men were men and women were less conned by advertising into spending $$ on 3/4" thick makeup
    Quote Quote  
  9. Originally Posted by jagabo View Post
    This is a feature, not a bug. ffmpeg uses a time base of 1/90000 for MP4 files. 24000/1001 cannot be represented exactly as N/90000 where N is an integer. It works out to 7353.75/90000. Using either 7353/90000 or 7354/90000 would result in a slow drift from the true frame rate. So ffmpeg uses a variable frame rate alternating between 3753/90000 for 1 frame and 3754/90000 for 3 frames. So technically it's variable frame rate. But it's effectively a constant frame rate.
    This sounds right but...frankly, this explanation is a bit over my head.

    This Variable Frame Rate thing seems to be an issue for me once again. When I export an MP4 from Adobe Premiere Pro, it's a CFR file. If I do anything to it with FFMpeg, it becomes VFR. This causes issues in AVStoDVD. Is there any way for me to force FFMpeg to create a CFR file?
    Quote Quote  
  10. I don't know how to force ffmpeg to use a different time base when muxing to mp4. But if you can live with MKV you should be get a CFR video.
    Quote Quote  
  11. Originally Posted by jagabo View Post
    I don't know how to force ffmpeg to use a different time base when muxing to mp4. But if you can live with MKV you should be get a CFR video.
    Unfortunately it seems to go both ways. Right now my use case is taking an MP4, converting to MKV and adding subtitles, then burning with AVStoDVD. The output file is always VFR (regardless of whether I add subtitles), even though the original MP4 is CFR. AVStoDVD doesn't like that, the video winds up very choppy during playback.
    Quote Quote  
  12. CFR MP4 to MKV can often lead to VFR because of the container timebase differences.

    what do you mean "adding subtitles" ? did you mean muxing in soft subs ? If so, try mkvmerge (mkvtoolnix) if they are a format not supported by mp4 . Or are you hardcoding them with ffmpeg ? If so, export MP4 . What else are you doing in ffmpeg?

    Adobe MP4 to ffmpeg MP4 should be CFR because the timebase is 1/24000 for a 23.976 file (24000/1001) exported from Adobe . The timestamps are retained
    Quote Quote  
  13. Originally Posted by poisondeathray View Post
    what do you mean "adding subtitles" ? did you mean muxing in soft subs ?
    Yes, I am muxing in 15 different srt files, using the mov_text encoder, so that they are properly supported in the MP4 container.

    Originally Posted by poisondeathray View Post
    CFR MP4 to MKV can often lead to VFR because of the container timebase differences.
    What else are you doing in ffmpeg?
    I am also adding in chapters using map_metadata
    Quote Quote  
  14. @seanmcnally
    mp4fpsmod.exe converts the VFR to CFR
    https://github.com/nu774/mp4fpsmod
    (You may have to google for the executable)

    Or try by adding in your ffmpeg commandline:
    -video_track_timescale 60
    (you may have to change the number, see the docs)

    Edit1: Here an executable of mp4fpsmod:
    http://www.mediafire.com/file/qyrj0d84gfauvdm/mp4fpsmod-0.26-Win64.7z/file

    Edit2:
    Or you could remux your VFR mp4 to an intermediate file (container) which does not support VFR (e.g. *.avi or *.ts), and then remux back to mp4. Something like:
    Code:
    ffmpeg -r 24000.0/1001.0  -i "yourVFR.mp4" -c:v copy -c:a copy "yourCFR.avi"
    ffmpeg -fflags +genpts -i "yourCFR.avi" -c:v copy -c:a copy "yourCFR.mp4"
    del yourCFR.avi
    Last edited by Sharc; 8th Jan 2022 at 04:38.
    Quote Quote  
  15. Originally Posted by seanmcnally View Post
    Originally Posted by jagabo View Post
    I don't know how to force ffmpeg to use a different time base when muxing to mp4. But if you can live with MKV you should be get a CFR video.
    Unfortunately it seems to go both ways. Right now my use case is taking an MP4, converting to MKV and adding subtitles, then burning with AVStoDVD. The output file is always VFR (regardless of whether I add subtitles), even though the original MP4 is CFR.
    Sorry, I was thinking of Handbrake (which will output CFR to MKV) not ffmpeg.
    Quote Quote  
  16. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    If you're having specific problems with AvstoDvd, post the log. The program can usually deal with VFR
    Quote Quote  
  17. Originally Posted by seanmcnally View Post
    Unfortunately it seems to go both ways. Right now my use case is taking an MP4, converting to MKV and adding subtitles, then burning with AVStoDVD. The output file is always VFR (regardless of whether I add subtitles), even though the original MP4 is CFR. AVStoDVD doesn't like that, the video winds up very choppy during playback.
    You probably should upload a small sample of a "VFR" source, the encoded version after AVStoDVD has had at it, and also the AVStoDVD log file. I'll confess the way AVStoDVD converts truly VFR video to CFR makes no sense to me, but it'd be better to play with some samples rather than guess.
    Quote Quote  
  18. Found the answer, thanks to poisondeathray, as well as some other users on the site. The answer is basically to just not use FFMpeg, but if you must, the process for fixing this is different depending on what kind of file you are working with

    For MP4 files, use MP4FPSMod. It's not easy to find a link to the Windows version, but here's the one I used.

    Run this from the command line:
    Code:
    "mp4fpsmod.exe" --fps 0:24000/1001  "file.mp4" -o "file_fixed.mp4"
    Change the values based on what frame rate you're trying to achieve. It's simple math - 24000/1001 = 23.976 with some extra decimals.
    For 23.976fps, use 24000/1001.
    For 29.97fps, use 30000/1001.
    For 59.94fps, use 60000/1001.
    For 24fps, use 24000/1000
    For 30fps, use 30000/1000
    For 60fps, use 60000/1000.

    For MKV files, you need MKVToolNix. There are two ways of doing this - to do it from the GUI, you need to create a text file with this inside it
    Code:
    # timestamp format v1
    assume 23.976
    Put whatever frame rate is desired after the word "assume" (29.97, 59.94 30, 60, etc.) Name it whatever you want, open up your MKV in the GUI, then select the video stream, and add your text file under "Timestamp File" on the right hand side (see an explanation screenshot here.)

    Alternatively, you can do this from the command line without needing to create a text file, using this code:

    Code:
    "C:\Program Files\MKVToolNix\mkvmerge.exe" --output "C:\file_fixed.mkv" --language 0:eng --default-track 0:yes --display-dimensions 0:1920x1080 --default-duration 0:24000/1001p --language 1:eng --default-track 1:yes (C:\original_file.mkv) --track-order 0:0,0:1
    The key part in the command line code is putting --default-duration 0:24000/1001p after the display dimensions. Change this value to reflect your desired framerate, using the instructions given for the MP4 version.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!