Log in

View Full Version : avisynth broken output, from xvid AVI input


halsboss
25th February 2009, 09:26
edit: see http://forum.doom9.org/showthread.php?s=&threadid=80430 "MPEG-4 B-frames in AVI/VFW hackery description".

This post is part FYI and part seeking suggestions from anyone else who has solved it.

XVID inside AVI using any VFW based application like AVISynth or VirtualDub, returns occasional out-of-sequence frames when going backward. This means probable broken results when processing with some filters including temporal processing and possibly setMTmode. I wondered for ages what was going on. non-VFW applications seem to work ok.

Here's threads describing the issue and the journey.
http://forum.videohelp.com/topic363395.html
http://forum.doom9.org/showthread.php?t=144713

Notionally, using packed-bitstream type AVIs for xvid content can fix it. But not always. mpeg4modifier can unpack/pack xvid AVIs. mpeg4modifier of itself was a good idea while it lasted. A packed bitstream xvid in .AVI (clip extract below) turned out to be a little odd. Unpacked with mpeg4modifier and repacked with it, and still had problems with it.

The only reliable way I found to get around it and have confidence in AVIsynth getting/using the right frames was a combination of mpeg4modifier and the latest ffmpeg -
(1) unpack it with mpeg4modifier
(2) convert to a lossless ffv1 .AVI (ffmpeg handles xvid's b-frames in AVI OK by the looks, though only from non-packed-bitstream AVIs)
(3) then process the ffv1 AVI with avisynth.

Command lines :-
"C:\SOFTWARE\MPEG4Modifier\mmcl.exe" --unpack --always-write "input.avi" "input-unpacked.avi"
"C:\SOFTWARE\ffmpeg\ffmpeg.exe" -y -i "input-unpacked.avi" -f avi -vcodec ffv1 -an "input-ffv1.avi"

It uses a bit of disk space. Anyone got an easier or more usable solution ? (eg maybe some tool to extract/copy the xvid directly from the .AVI into an .MP4 so it can be opened with DirectShowSource)

Here's a couple of clips to open in the latest Virtualdub
http://rapidshare.com/files/202285381/clip-packed-bitstream.avi
packed bitstream 400k
1. jump to frame 123
2. single-step through to frame 128 observing each frame
...frame 126 is the scene change and the door in the background opens smoothly
3. backward single-step through to frame 123 observing each frame
...at frame 126 notice at frame the door does a backflip for 1 frame
...frame 124 is where the scene change occurs

http://rapidshare.com/files/202285382/clip-ffv1.avi
ffv1 (not quite the same frames clipped, but contains the same sequence) 3Mb
1. jump to frame 25
2. single-step through to frame 35 observing each frame
...frame 30 is the scene change and the door in the background opens smoothly
3. backward single-step through to frame 25 observing each frame
...the movements and scene-changes stay the same

squid_80
25th February 2009, 09:41
Always use packed bitstream with avi and use xvid to decode instead of ffdshow. If the problems persist I will be very surprised.

Dark Shikari
25th February 2009, 09:45
Haven't people realized yet that the combination of B-frames and VFW is a bad idea?

squid_80
25th February 2009, 10:23
That's why the band-aid known as packed bitstream exists.

halsboss
25th February 2009, 12:19
Always use packed bitstream with avi and use xvid to decode instead of ffdshow. If the problems persist I will be very surprised.Ah, will try that. I'd thought ffdshow would have been the be-all and end-all. Will give that a try. Any particular version of xvid codec ?

Haven't people realized yet that the combination of B-frames and VFW is a bad idea?
I don't think they have. It (xvid/avi) is ubiquitous and avisynth and virtualdub are oh-so-good. Is there a way to make avisynth non-VFW ?

Dark Shikari
25th February 2009, 12:25
I don't think they have. It (xvid/avi) is ubiquitous and avisynth and virtualdub are oh-so-good. Is there a way to make avisynth non-VFW ?Avisynth only uses VFW if you use AviSource...

halsboss
25th February 2009, 12:46
Always use packed bitstream with avi and use xvid to decode instead of ffdshow. If the problems persist I will be very surprised.Well, you won't be surprised to read that it works ! Unticking decoding xvid in ffdshow (both vfw and non-vfw) and installing the latest xvid makes the problem go away. Thankyou, oh thankyou so much.

Avisynth only uses VFW if you use AviSource...Pity. I'd hoped ffmpegsource V2 would do the trick but it had issues when I tried it ... is that vfw too ? Maybe this will fix that as well; but then, why use it if AVIsource works ?

Dark Shikari
25th February 2009, 12:53
Pity. I'd hoped ffmpegsource V2 would do the trick but it had issues when I tried it ... is that vfw too ? Maybe this will fix that as well; but then, why use it if AVIsource works ?FFmpeg, given the name, uses ffmpeg ;)

halsboss
1st March 2009, 00:15
A tid bit, as prompted from the thread on videohelp to test ffdshow settings.

I had to uninstall xvid for ffdshow to be used again. Anyway, tried all 3 ffdshow settings :-

1. disabled = virtualdub had no codec to decode, as expected
2. libavcodec = the anomalous behaviour described
3. Xvid = "good behaviour"

Anyway, decided to go back to install Xvid and disable ffdshow's xvid, just to be on the safe side.


edit: see http://forum.doom9.org/showthread.php?s=&threadid=80430 MPEG-4 B-frames in AVI/VFW hackery description

halsboss
21st August 2009, 11:33
Hmm, is there any commandline switch to force ffmpeg to create an AVI with packed-bitstream ?