encode video in reverse?

2019-01-22 00:10发布

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 frame (so a folder of images labelled 1.jpg, 2.jpg etc), then write a script to change the image names, and then re-encode the ivdeo from these files.

Does anyone know of a quicker way?

This is an FLV video.

Thank you

标签: ffmpeg
2条回答
smile是对你的礼貌
2楼-- · 2019-01-22 00:24

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
查看更多
做个烂人
3楼-- · 2019-01-22 00:34

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:

and

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
查看更多
登录 后发表回答