View Full Version : Reverse video
ricardo.santos
9th February 2015, 18:16
Hi everyone!
Just recorded some timelapses and "joined" them with avisynth using:
DirectShowSource("01.mp4")+DirectShowSource("02.mp4")+DirectShowSource("03.mp4")
Is it possible to make video "02" play in reverse, just that one? I tried putting ".Reverse" and "Reverse()" after the video and it doesnt work, is this possible with avisynth?
Thanks
Groucho2004
9th February 2015, 18:24
Reverse() should work:
DirectShowSource("01.mp4")+DirectShowSource("02.mp4").Reverse()+DirectShowSource("03.mp4")
ricardo.santos
9th February 2015, 19:15
Hi Groucho, i tried your advice but when previewing the avs in mpc the player displays a grey screen, the video shows up in virtualdub but it takes ages to play, they're all full hd clips, perhaps my system cant cope?
wonkey_monkey
9th February 2015, 19:24
Is it possible to make video "02" play in reverse, just that one? I tried putting ".Reverse" and "Reverse()" after the video and it doesnt work
Edit: it does sound like the codec just isn't capable of decoding the frames quickly enough.
Most video codecs are optimised for forward playback, since this is their usual usage, so trying to request frames in reverse is about the most CPU-consuming thing you can ask them to do. Even on a super-fast computer, you could be asking it to decode up to 300 frames (not an unusual key-frame distance these days) to get the frame you want - and then it'll do the same all over again for the next frame you want, because it's before the last one, not after it as the codec expects.
For the quick fix, while you're working on the project, try re-encoding the file with an intra-frame codec like MJPEG or MagicYUV - the file will be (much) larger but reverse should work at full speed. Once the project's done you can delete the re-encoded file and you'll still have the original if you ever need it again.
I've been think about caching for reverse play lately, but haven't come up with any particularly brilliant ideas of how to do it, so if anyone knows of any, let me know.
David
poisondeathray
9th February 2015, 19:28
And directshowsource() can be problematic with frame accuracy. Even more so with Reverse() and Long GOP formats
Groucho2004
9th February 2015, 22:33
OK, just did a test with 2 normal length 1080p movies:
LoadPlugin("E:\Apps\VideoTools\AVSPlugins\LSMASHSource.dll")
a = LWLibavVideoSource("source\test1.264", threads = 1)
b = LWLibavVideoSource("source\test2.264", threads = 1).Reverse()
return a+b
Speed was fine, memory usage only about 100 MB.
Please post your full script. Also, if you're using Avisynth MT, try running it single-threaded.
StainlessS
10th February 2015, 00:44
If you have problems playing reverse using LSmash, suggest render to lossless first (LSmash and FFMpegSource can both sometimes produce out of order frames)
setlocal
REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"
REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."
REM Where to place output file, No terminating Backslash.
set OUTDIR="D:\AVS\AVI"
FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM *.mkv *.TS *.y4m *.yuv) DO (
%FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
)
Pause
Converts to UTVideo codec
or replace with this line for HuffYUV
%FFMPEG% -i "%INDIR%\%%A" -vcodec huffyuv -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
As provided, uses FFMPeg in path C:\BIN\ffmpeg.exe, converts files in same directory as BAT file to output at D:\AVS\AVI.
You can add file extensions if required.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.