VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Anonymous543
    Guest
    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.
    Quote Quote  
  2. -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.
    Quote Quote  
  3. Anonymous543
    Guest
    Originally Posted by pandy View Post
    -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).
    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?


    Originally Posted by pandy View Post
    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
    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??
    Quote Quote  
  4. Originally Posted by kirito View Post
    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?
    -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.

    Originally Posted by kirito View Post
    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??
    https://ffmpeg.org/ffmpeg-filters.html#fps
    Convert the video to specified constant frame rate by duplicating or dropping frames as necessary.
    Both 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)...
    Quote Quote  
  5. Anonymous543
    Guest
    Both 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)...
    which command you will suggest for vfr to cfr conversion
    -r
    or
    -fps


    after changing frame rate will my audio will be in sync with video?
    Quote Quote  
  6. Originally Posted by kirito View Post
    which command you will suggest for vfr to cfr conversion
    -r
    or
    -fps


    after changing frame rate will my audio will be in sync with video?
    Of course '-fps', '-r' is incapable to deliver CFR as explained earlier.
    Audio should be in sync as video and audio duration will be the same (accuracy will be 1/24).
    Quote Quote  
  7. Anonymous543
    Guest
    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.
    I'll try to use this methods tommorow but it seams difficult to manipulate pts dts and then decimate ,can you explain more about this pts and dts
    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
    Quote Quote  
  8. Originally Posted by kirito View Post
    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.
    I'll try to use this methods tommorow but it seams difficult to manipulate pts dts and then decimate ,can you explain more about this pts and dts
    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
    it may be too slow for you - then you may wish to sacrifice quality to speedup overall conversion.
    Quote Quote  



Similar Threads

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