encode video in reverse?

前端 未结 2 1004
无人及你
无人及你 2020-12-08 03:21

Does anyone know if it is possible to encode a video using ffmpeg in reverse? (So the resulting video plays in reverse?)

I think I can by generating images for each

相关标签:
2条回答
  • 2020-12-08 03:44

    I've created a script for this based on Andrew Stubbs' answer

    https://gist.github.com/hfossli/6003302

    Can be used like so

    ./ffmpeg_sox_reverse.sh -i Desktop/input.dv -o test.mp4
    
    0 讨论(0)
  • 2020-12-08 03:52

    No, it isn't possible using ffmpeg to encode a video in reverse without dumping it to images and then back again. There are a number of guides available online to show you how to do it, notably:

    • http://ubuntuforums.org/showthread.php?t=1353893

    and

    • https://sites.google.com/site/linuxencoding/ffmpeg-tips

    The latter of which follows:

    Dump all video frames

    $ ffmpeg -i input.mkv -an -qscale 1 %06d.jpg
    

    Dump audio

    $ ffmpeg -i input.mkv -vn -ac 2 audio.wav
    

    Reverse audio

    $ sox -V audio.wav backwards.wav reverse
    

    Cat video frames in reverse order to FFmpeg as input

    $ cat $(ls -r *jpg) | ffmpeg -f image2pipe -vcodec mjpeg -r 25 -i - -i backwards.wav -vcodec libx264 -vpre slow -crf 20 -threads 0 -acodec flac output.mkv
    

    Use mencoder to deinterlace PAL dv and double the frame rate from 25 to 50, then pipe to FFmpeg.

    $ mencoder input.dv -of rawvideo -ofps 50 -ovc raw -vf yadif=3,format=i420 -nosound -really-quiet -o - | ffmpeg -vsync 0 -f rawvideo -s 720x576 -r 50 -pix_fmt yuv420p -i - -vcodec libx264 -vpre slow -crf 20 -threads 0 video.mkv
    
    0 讨论(0)
提交回复
热议问题