Hllo all
i have recorded a video from my mobile camera
it recorded in variable frame rate and big size
Code:Frame rate mode : Variable Frame rate : 29.530 FPS Minimum frame rate : 20.882 FPS Maximum frame rate : 29.615 FPS
i am working on this video and i wanna make this video at constant frame rate of 24 FPS with using ffmpeg
i readed methods at here - https://trac.ffmpeg.org/wiki/ChangingFrameRate
on website There are two ways to change the output frame rate:
1. With the -r option used as an output option
2. With the fps filter
am confused between these two methods ,which will give better results?
video has slow and fast motions.
+ Reply to Thread
Results 1 to 8 of 8
-
Anonymous543Guest
-
-r works after all video processing and before encoding - this is quite crude way to convert framerate also as mentioned in documentation it will not create constant frame rate video (only limit frame rate to specified max i.e. everything above will be dropped).
fps filter works in filter level (i.e. it will process video with all implication for example video format conversion) and will create always constant frame rate video
Both methods are rather crude way to do framerate conversion.
Being on your place i would do something else - for example covert video to constant, higher than target framerate like 48 or 72 fps and then decimate it to achieve 24 fps keeping motion as much as possible smooth.
You can use different methods to do this:
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
https://ffmpeg.org/ffmpeg-filters.html#minterpolate
https://github.com/slowmoVideo/slowmoVideo/
https://github.com/dthpham/butterflow
You can do decimation using:
https://ffmpeg.org/ffmpeg-filters.html#mpdecimate
https://ffmpeg.org/ffmpeg-filters.html#decimate-1
There is many possibilities but anyway firstly i would do 48 or more fps video and later i would apply static decimation pattern to create 24fps.
You can mix approach and probably to achieve best results you need to try different methods...
PS
I would rather keep motion accuracy at highest sane fps value (like 30000/1001 in your case) than decimate it to 24 fps. -
Anonymous543Guest
Does That means if i set -r 24 then every frames which is above 24fps in source will be dropped and lower then 24fps will remain same?
and if i set -fps 24 then every frames which is above 24fps in source will be dropped and lower then 24fps will be duplicated?? -
-r takes effect after all filtering, but before encoding of the video stream has taken place.
The -r logic depends on the video sync method set (-vsync).
For an output format like MP4, which defaults to constant frame rate (CFR), -r will generate a CFR stream. For variable frame rate formats, like Matroska, the -r value acts as a ceiling, so that a lower frame rate input stream will pass through, and a higher frame rate stream, will have frames dropped, in order to match the target rate.
https://ffmpeg.org/ffmpeg-filters.html#fps
Convert the video to specified constant frame rate by duplicating or dropping frames as necessary.
Be noticed that fps may select video frames to be discarded in suboptimal way i.e. it may discard frame with motion and keep static frame... this may lead to additional motion artifacts.
Not clear what is your goal (except framerate and vfr/cfr conversion)... -
Anonymous543GuestBoth methods are fast, -r is at higher abstraction layer (hard data discard + PTS manipulation) where "-filter:v fps=30" will operate at video data level.
Be noticed that fps may select video frames to be discarded in suboptimal way i.e. it may discard frame with motion and keep static frame... this may lead to additional motion artifacts.
Not clear what is your goal (except framerate and vfr/cfr conversion)...
-r
or
-fps
after changing frame rate will my audio will be in sync with video? -
-
Anonymous543GuestBeing on your place i would do something else - for example covert video to constant, higher than target framerate like 48 or 72 fps and then decimate it to achieve 24 fps keeping motion as much as possible smooth.
With cli ,i know how to extract raw bitstream but,
never did any manipulation with pts and dts and also i don't know properly how they works
I guess raw bitstream doesn't contains any pts and dts..it's the wrapper/containers who contains them -
PTS presentation time stamp
DTS decoding time stamp
PTS says when decoded video frame shall be displayed and it always raising (in case of the CFR video files monotonically i.e. delta between PTS is constant)
DTS says when frame should be decoded - commonly (modern codecs) frames are stored non-monotonically.
You don't need to manipulate PTS manually - framerate conversion process will do this for you.
example for anyfps to 48 fps to 24
Code:-vf minterpolate=mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1:fps=48,decimate=cycle=2,format=pix_fmts=yuv420p
Similar Threads
-
ffmpeg MKV to MP4 without rencode makes output frame rate variable?
By Anonymous543 in forum Newbie / General discussionsReplies: 26Last Post: 1st May 2024, 17:05 -
ffmpeg change frame rate on muxing not working,...
By Selur in forum Newbie / General discussionsReplies: 2Last Post: 10th Dec 2020, 07:42 -
Need variable frame rate ffmpeg
By Budman1 in forum Video ConversionReplies: 15Last Post: 9th Mar 2020, 05:10 -
FFmpeg is changing the frame rate to Variable when copying video?
By kkiller23 in forum Newbie / General discussionsReplies: 5Last Post: 1st Dec 2019, 13:14 -
ffmpeg, Interlace, Frame Rate and File Size
By chris319 in forum Video ConversionReplies: 4Last Post: 15th Jun 2018, 01:08