Results 1 to 7 of 7

Thread: ffmpeg hangs computer when using reverse

  1. #1
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    5,261
    Distro
    Ubuntu

    Question ffmpeg hangs computer when using reverse

    I'm trying to reverse a video clip. But when I do, my computer hangs, and all I can do is reboot with REIBUS.

    Making a straight copy works fine. For example, to copy the second minute of a video to a new file, this works flawlessly.
    Code:
    ffmpeg -i input.avi -ss 60 -t 60 -codec:a copy -codec:v copy copy.avi
    However, doing the same thing in reverse causes my computer to hang.
    Code:
    ffmpeg -i input.avi -ss 60 -t 60 -vf reverse -af areverse copy.avi
    How can I reverse a short video clip without the computer hanging? In fairness, I don't understand ffmpeg well, so I've copied instructions from the web. If I'm using incorrect or inefficient options, please let me know!

    EDIT 1: I specifically want to use the command line in order to automate a large number of clips, so a GUI solution won't work for me.

    EDIT 2: I am trying to mix various clips together, only some of which are reversed, so it would be great if I could use ffmpeg. Otherwise I need to look at concatenating videos outside ffmpeg.
    Last edited by Paddy Landau; June 14th, 2018 at 05:43 PM. Reason: More information
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  2. #2
    Join Date
    Aug 2016
    Location
    Wandering
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: ffmpeg hangs computer when using reverse

    Hi Paddy Landau long time no see. I hope this is not to confusing.
    I too a long time ago had to do something along these commands:
    Code:
    cat $(ls -t *jpg) | ffmpeg -f image2pipe -vcodec mjpeg -r 25 -i - -i backwards.wav -vcodec libx264 -vpre slow -crf 20 -threads 0 -acodec flac output.mkv
    Or something like this also "should" work.
    For video only>> this is from my notes back in the year 2016:
    Code:
    ffmpeg -i /storage/emulated/0/ffvid/frameCount.mp4 -vf reverse reversed.mp4
    For audio and video:
    Code:
    ffmpeg -i /storage/emulated/0/ffvid/frameCount.mp4 -vf reverse -af areverse reversed.mp4
    This filter buffers the entire clip. For larger files, segment the file, reverse each segment and then concat the reversed segments.
    I got this idea form stackexchange and I think things have changed some since then.
    Good Luck
    With realization of one's own potential and self-confidence in one's ability, one can build a better world.
    Dalai Lama>>
    Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD

  3. #3
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    5,261
    Distro
    Ubuntu

    Re: ffmpeg hangs computer when using reverse

    Thanks for the reply.

    I find your first example confusing — where do the JPG files come from? Did you split the original video into its individual frames, and extract the audio into a separate file? This seems like a fairly time-consuming and inefficient way to do it, but if it's the only way, that's how it will have to be. My problem with this method is that I wouldn't know how to figure out the frames per second, especially if the original had a variable rate (does that ever happen)?

    If you compare your third example with my original post, you'll see that it is precisely what I'm already doing, which seems to hang my system. (Your second example excludes the audio, which isn't what I want.)
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  4. #4
    Join Date
    Aug 2016
    Location
    Wandering
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: ffmpeg hangs computer when using reverse

    It seems that it isn't possible using ffmpeg to encode a video in reverse without first dumping it to images and then back again.
    Have a look here: https://stackoverflow.com/questions/...deo-in-reverse
    I was just as confused at first as you are now. Keep in mind that at times what we want to do is sometimes very time consuming and awkward.
    I know you have said you prefer command line but Openshot might be a more eloquent solution. (it's a very intuitive an easy to use video editor.
    You have to right click on the imported clip then properties -> speed tab, change the direction of the clip.)

    Or even "kdenlive" reverse clip>> right-click on the clip: clip jobs / reverse clip. (I have also used this with xenial 16.04)
    Just trying to help.
    Last edited by 1fallen; June 15th, 2018 at 02:24 PM.
    With realization of one's own potential and self-confidence in one's ability, one can build a better world.
    Dalai Lama>>
    Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD

  5. #5
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    5,261
    Distro
    Ubuntu

    Re: ffmpeg hangs computer when using reverse

    I think that I've figured out what the problem is with ffmpeg hanging when reversing. It worked when I used a tiny clip of just 5 seconds. Looking at what was happening as I tried a longer clip, it seems that ffmpeg fills the swap partition rapidly. A 60-second clip quickly reached filled 1.6 Gb of swap, at which point I cancelled before the computer would hang.

    I've been trying the method described for dumping frames and resurrecting them in reverse, but without success. It seems that the ffmpeg command has changed since that was posted.

    I'm officially giving up now. It's become far too difficult.
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  6. #6
    Join Date
    Aug 2016
    Location
    Wandering
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: ffmpeg hangs computer when using reverse

    I'm officially giving up now. It's become far too difficult.
    Or just bite the bullet and use "OpenShot" it just took me under 5 mins to choose the clip I wanted to reverse from a 1 hour video>>>the clip itself was 1min 45secs long.
    Way easier than using the CLI method.
    With realization of one's own potential and self-confidence in one's ability, one can build a better world.
    Dalai Lama>>
    Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD

  7. #7
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    5,261
    Distro
    Ubuntu

    Re: ffmpeg hangs computer when using reverse

    Quote Originally Posted by 1fallen View Post
    Or just bite the bullet and use "OpenShot"…
    Thanks, but as I said, this is for "a large number of clips." I do use OpenShot, and unfortunately it's not appropriate in this case.

    Until the bug in ffmpeg is resolved, I'll do without this function. It's become way too complicated for my rather simple needs
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •