Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

encode video in reverse?

Tags:

ffmpeg

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

like image 549
bob Avatar asked Mar 31 '10 13:03

bob


People also ask

Can you edit a video to play in reverse?

FilmoraGo is a full-feature mobile editing app, which means it can also play the video clips backwards in your Android or iOS smartphone with ease.

What app makes videos in reverse?

PowerDirector PowerDirector is a professional reverse video app with tons of other powerful features. This reverse video app supports reverse playback and variable speed. PowerDirector is free to download on both iOS and Android devices.


1 Answers

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
like image 93
Andrew Stubbs Avatar answered Oct 23 '22 17:10

Andrew Stubbs