[FFmpeg-user] -framerate, -r and -itsoffset confusion

Duncan Robertson duncan at writeinstone.com
Mon Sep 20 11:45:00 EEST 2021


I am creating a video file from a folder full of jpg frames and an mp3 or wav audio file with the following arguments:

-y -framerate 12 -itsoffset -654ms -i "C:\path/%06d.JPG" -i "C:\path/audio.mp3" -map 0:v:0 -map 1:a:0 -vf scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black -acodec aac -vcodec libx264 -ar 48000 -pix_fmt yuv420p -movflags +faststart "C:\path\output.mp4"

(This issue has also been posted in stackoverflow: https://stackoverflow.com/questions/69198721/ffmpeg-framerate-inconsistent)

The video frames are captured at 12fps. When I set -framerate 12 I get s slightly sped up video, say 28 seconds of video for every 12*30 frames.

Reproduction note: I have tried exporting the frames from a random video and then recompiling them as a kind of round-trip test and this does not happen in that test. I can not imagine what is different or why the issue only works with frames and audio recorded from my application. I can zip and upload a folder full of images and an audio file if anyone wants to try reproducing it but I can't explain how to reproduce it from first principles.

If I use -r this problem resolves and the output is 30 seconds of video as expected. But to sync the video and audio I am using -itsoffset because the two recorders don't necessarily start at the same moment. If I switch to -r the -itsoffset appears to be ignored making a/v sync impossible.

My main questions are therefore:

Does anyone have any suggestions?

What is the difference between -framerate and -r?

Is there a way to offset video and audio data for sync while using -r?

is there a way to force -framerate to encode more reliably?

Thanks for reading

Duncan





More information about the ffmpeg-user mailing list