Log in

View Full Version : FFVideoSource desync


Eretria-chan
27th August 2013, 22:37
Maybe someone can enlighten me here...

I'm using this video (http://archive.org/download/DsCastlevaniaDawnOfSorrowall-soulsIn3508.59ByKriole/castlevaniados-tas-100souls-kriole.mkv) as source for my simple script:

Clip = "castlevaniados-tas-100souls-kriole.mkv"

# Load clips
Video = FFVideoSource(Clip)
Upper = Video.Crop(0, 0, 0, -192)
Bottom = Video.Crop(0, 192, 0, 0)
Both = Video
Audio = FFAudioSource(Clip)

# Fix top right screen
TopRight = Upper

# Fix left pane
Left = Bottom.LanczosResize(768, 576)

# Set right pane
RightPane = StackVertical(TopRight, Both)

# Put all together
StackHorizontal(Left, RightPane).AudioDub(Audio)

The problem is that whatever I do, I get audio/video desync because the video plays about 5x as fast as it should in the beginning. It only happens with the avisynth script and not with the original file. I've also tried reencoding it with huffyuv and with x264 with --force-cbr, but apparently the same issue happens. Same thing happens with DirectShowSource.

Anyone have any ideas on how to fix this desync?

creaothceann
27th August 2013, 22:44
You could download the emulator movie (http://tasvideos.org/1628M.html), play it back and encode it, e.g. with Lagarith.

sneaker_ger
27th August 2013, 22:48
Either copy the timecodes from the source or use something like FFVideoSource(Clip, fpsnum=60000, fpsden=1001).

creaothceann
27th August 2013, 22:57
fpsden=1001
Gameboy Advance is exactly 60fps though, afaik.

sneaker_ger
27th August 2013, 23:16
Hmm, both 1001 and 1000 seem to be way off, even after I've cut off the first 3 minutes.

Eretria-chan
27th August 2013, 23:18
You could download the emulator movie (http://tasvideos.org/1628M.html), play it back and encode it, e.g. with Lagarith.
Doing that would require getting the game and syncing it. Can't say I have any experience with that. It would probably be a nightmare, too.

Either copy the timecodes from the source or use something like FFVideoSource(Clip, fpsnum=60000, fpsden=1001).
How would I copy timecodes, though?

Gameboy Advance is exactly 60fps though, afaik.
Except this is a DS game.

EDIT: Forcing cbr with x264 from the source causes the same kind of desync. Is it because it's forcing vfr -> cfr that this is happening?

sneaker_ger
27th August 2013, 23:31
How would I copy timecodes, though?

Extract them with mkvtoolnix:
mkvextract timecodes_v2 input.mkv 0:timecodes.txt

You can then use that file in your muxer and/or x264:
--tcfile-in timecodes.txt

Note that not all formats support VFR. (mp4 and mkv support it, Blu-Ray/DVD/AVI don't fully support it)

Forcing cbr with x264 from the source causes the same kind of desync. Is it because it's forcing vfr -> cfr that this is happening?

If you use --force-cfr x264 treats the input file as if it was cfr - it does not actually do anything to keep the sync. If you open it directly (not through AviSynth and without --force-cfr or --fps) it will copy the timecodes.

creaothceann
27th August 2013, 23:44
Except this is a DS game.
OK, this (http://tasvideos.org/2205M.html) movie file then. Still 60fps.

Doing that would require getting the game and syncing it. Can't say I have any experience with that. It would probably be a nightmare, too.
Syncing should be easy, just load the ROM and then the movie into DeSmuME.

Eretria-chan
27th August 2013, 23:49
Hey, will you look at that!
By using x264 to generate the timecodes using --tcfile-out from the original file and then encoding the avs file using the timecode file generated by x264 before, it seems stays in sync!
That's what I needed! Thanks!

(Let's hope the entire file is in sync, too!)