Iam kinda new to ffmpeg so bear with me.
I’m using the software Topaz video Enhance AI to upscale some videos. It creates .pngs of each upscaled frame and then I merge them with ffmpeg into a h265 video.
My problem now is Iam currently upscaling a .mp4 with varible framerate:
Frame rate : 29.970 FPS
Minimum frame rate : 29.960 FPS
Maximum frame rate : 29.970 FPS
It probably won’t be a huge issue in this example but how can I tell ffmpeg to encode with this exact variable framerate so the audio isn’t out of sync?
My current ffmpeg command is:
ffmpeg -framerate 30000/1001 -i %06d.png -c:v libx265 -crf 16 -preset faster -pix_fmt yuv420p10le E:\movies\no.mkv
Good question, I only know how to do constant rate factor. I know it will do some VBR automagically but I don’t know how to force a max and min frame rate. At this point the man pages or gnu info articles will be your friend. Or ask on the ffpmeg website if you cannot find on their forvm or wiki.
The problem is that Topaz Video Enhance AI can’t/won’t handle Variable Frame rate files to upscale, you need to convert your file to Constant Frame Rate first, then upscale, then turn the image set into a video to re-mux the audio without it going out of sync.
Variable frame rate is incredibly common on Android source videos. Nintendo Switch NVENC encoder videos are variable in MediaInfo, but actually run at 30.00fps. Same with anything you shoot with your Android video camera function.
Since the variation is not that great, I have a feeling it’s a Handbrake source file. You should not have major desync issues if you convert it to constant frame rate. Where you experience desync is iPhone files that drop the framerate mid-file to 23.976 for low light. or if it’s an Android file where minimum is 29.970 and maximum is 30.333. (Because Android works in Fractional frame rates, not integers)
BTW, Video2X might be a better solution that does not require PNG conversion.
The time-stamps, specifying which video frame to display at which instant, is stored in the container (e.g. mkv). When reencoding you want to use the ffmpeg option -copyts to preserve it. Once you separate the video from the container, such as converting to a series of png images, or converting to a less advanced container format, you’ve lost that timing information, and there’s realistically no way to get it back.
That’s why ffmpeg has its own filter component. You should find a libavfilter component to do whatever filtering you need, so that it can be done inside the video encoding pipeline and preserve those time-stamps and related metadata.