View Full Version : Searching AviSynth script to play WMV file in VirtualDub
mike23
5th May 2006, 23:11
I want to play a WMV movie in VirtualDub (in order to re-encode it with DivX). I would appreciate it if I am not forced to re-invent the wheel.
Is there an AviSynth script which does the job (if possible with resolution parameter)?
Thank you
tedkunich
5th May 2006, 23:25
I want to play a WMV movie in VirtualDub (in order to re-encode it with DivX). I would appreciate it if I am not forced to re-invent the wheel.
Is there an AviSynth script which does the job (if possible with resolution parameter)?
Thank you
Uhmm... try opening it with the avisynth template in VD.
foxyshadis
6th May 2006, 04:30
That's VDMod, VD doesn't have templates. You'd have to use the DirectShowSource template, too. Another option though, is to VD-MPEG2, which can directly read many wmvs (but the parser is old and flakey and may not work entirely).
jay_jay
12th May 2006, 17:35
i think wmv can be open directly in vdub versions like 1.6.11.
redfordxx
12th May 2006, 18:15
Well I have similar problem and wanted to ask, but here is what I know so far:
1) VD-MPEG2 can open wmv, I believe the new VDM can't
2) Opening wmv directly in VD-MPEG2 shows slightly different colors than wmv-->directshowsource-->avs-->VD* (observe with fast switching two instances VDM2), dunno which are the *correct ones*
3) Opening wmv in VD* via avs or directly has variable framerate problem
Look in the file information window at the framerate info. When you see something different than standard framerates (23.976, 25, 29.97 etc...) you can expect audio synch or other problems after recoding.
Solution I don't know....
fccHandler
12th May 2006, 22:05
Another option though, is to VD-MPEG2, which can directly read many wmvs (but the parser is old and flakey and may not work entirely).
No, this parser is actually very new. But it may have problems with damaged streams because there is almost no error handling capability at all.
WMV files don't require the frame rate to be fixed, but AVIs do. So if you're converting a WMV with a variable frame rate into an AVI you will always have sync problems.
redfordxx
12th May 2006, 23:00
WMV files don't require the frame rate to be fixed, but AVIs do. So if you're converting a WMV with a variable frame rate into an AVI you will always have sync problems.
As for me, I don't want to put vfr into avi. I want to change it into cfr, but stay in sync.
IIRC, I tried it via DSS in AviSynth and I got 2 second out of sync audio. Not sure, whether I tried to encode directly from VDM2.
When I open wmv directly in VDM2 and encode it inlo cfr with some framerate adjustment settings, would it be OK and in sync? Which settings?
I'd be very happy, if that works, I am already decided to devote the harddrive space for lossless compression and then go to AviSynth.
foxyshadis
12th May 2006, 23:26
Hey, VD MPEG2 was updated. Thanks, fcc! And thanks for clarifying, I thought it was the crappy old 1.3c parser.
Is it easy to parse timecodes out of wmv with your newer parser? ie, would it be possible to save a timecode file for vfr muxers?
fccHandler
13th May 2006, 00:03
As for me, I don't want to put vfr into avi. I want to change it into cfr, but stay in sync.
Honestly I have no idea how to do that. :(
When I open wmv directly in VDM2 and encode it inlo cfr with some framerate adjustment settings, would it be OK and in sync?
That all depends on how the WMV was created. You'll just have to try it and see.
Sync problems can also appear if the WMV has a VBR audio track. If you allow it to process the movie strictly from the beginning without interruption then it's usually OK, but if you do any editing or seeking on the timeline it often loses sync.
fccHandler
13th May 2006, 00:12
I thought it was the crappy old 1.3c parser.
It still is for the most part, but I've updated it to conform to the latest ASF specification (http://www.microsoft.com/windows/windowsmedia/forpros/format/asfspec.aspx). The original was totally reverse engineered by Avery Lee, and I don't think he had decent specs to work with back then.
Is it easy to parse timecodes out of wmv with your newer parser? ie, would it be possible to save a timecode file for vfr muxers?
Easy, no, but certainly possible. What exactly is the contents of a "timecode file"?
foxyshadis
13th May 2006, 00:34
Matroska timecodes are used in several vfr filters and can be used to mux mkv or generate 120 fps avis, and hopefully in the future mp4box will support them.
v1 defines ranges, like:
# timecode format v1
Assume 29.970000
0,11,23.976000
77,548,23.976000
554,729,23.976000
780,783,23.976000
819,1846,23.976000
2544,2571,9.99
2572,12805,23.976000
14826,15229,23.976000
v2 outputs the timecode in ms of every frame:
# timecode format v2
0
333
375
417
458
500
533
567
600
633
667
700
734
767
800
834
867
900
934
967
1001
1034
1067
v3 and v4 aren't really that important, but they're all defined on the mkvmerge man page (http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge.html).
fccHandler
13th May 2006, 00:40
Timecode format v2 should be very possible. I might mess around with this tonight... ;)
foxyshadis
13th May 2006, 00:46
Thanks! That would help out a lot, sometimes.
fccHandler
13th May 2006, 08:43
Well, instead of incorporating this into VirtualDub-MPEG2 (which would be a pain), I've decided to just make a simple command-line utility to dump the time codes from a WMV file.
I have the program working now, but I'm not quite sure how to test it. Do you know where I can get some variable frame rate WMV files? I don't see any way to make such a thing with Windows Media Encoder 9...
redfordxx
13th May 2006, 10:19
Well, instead of incorporating this into VirtualDub-MPEG2 (which would be a pain), I've decided to just make a simple command-line utility to dump the time codes from a WMV file.
I have the program working now, but I'm not quite sure how to test it. Do you know where I can get some variable frame rate WMV files? I don't see any way to make such a thing with Windows Media Encoder 9...I can test a little....WinXP
fccHandler
13th May 2006, 21:50
Here you go:
http://fcchandler.home.comcast.net/WMVTIMES.exe
redfordxx
13th May 2006, 23:23
In general, it works.
Strange, does not start with zero (starts e.g. 20000) but seems to be shifted, not trimmed...
I calculated the length of frames... usually two numbers occur
file 1: 41,42
file 2: 33,50 wierd???
In the beginning of the file 1 tit was wilder...
# timecode format v2
20000
20125
20166
20291
20333
20666
20708
21541
21583
21625
21666
21916
21958
22000
22041
22083
22125
22166
22208
I reinstalled comp recently and have wmv3 codec problem, so can't explore more. I will come back later.
foxyshadis
13th May 2006, 23:36
41 matches 23.976 fps
40 matches 25 fps
33 matches 29.970 fps
(Try extracting the timecodes of some mkvs, you'll see what I mean.)
fccHandler
14th May 2006, 00:34
Strange, does not start with zero
I've begun to notice that too. Most of my WMVs don't start at zero for some reason. The numbers do come straight from the WMV, but I'll probably need to adjust the times to be zero-based for this program to be useful. Or better yet, bias them to be relative to the start time of the audio stream.
fccHandler
14th May 2006, 02:40
Hmm... I've discovered that these nonzero start times seem to match the "preroll" value stored in the WMVs file header. So far this has been true of all the WMVs I've checked, and logically it makes sense, so I've fixed the program to simply subtract the preroll value from all time codes.
http://fcchandler.home.comcast.net/WMVTIMES.exe
zambelli
14th May 2006, 07:47
I have the program working now, but I'm not quite sure how to test it. Do you know where I can get some variable frame rate WMV files? I don't see any way to make such a thing with Windows Media Encoder 9...
Create a source AVI that's structured something like this:
00:00 - 00:05 motion video
00:05 - 00:10 still frame
00:10 - 00:15 motion video
Then encode it to WMV. WMV encoder should detect the middle 5 seconds as being a still frame and encode it as a single unique frame, whereas in the source AVI those middle 5 seconds would be encoded as 5 x FPS unique frames, completely wasting space. So the resulting WMV will effectively have a variable framerate because there won't necessarily be a new frame encoded every 1/FPS of a second.
fccHandler
14th May 2006, 09:14
Thanks! I'll try that. :cool:
redfordxx
14th May 2006, 10:23
41 matches 23.976 fps
40 matches 25 fps
33 matches 29.970 fps
(Try extracting the timecodes of some mkvs, you'll see what I mean.)
Yes I understand it...
and 50ms matches 20fps
but the series 50,33,50,33,50,33 is wierd.. like switching between 20fps and 30fps every frame...
fccHandler
14th May 2006, 22:16
Zambelli's suggestion worked. I captured some TV and used VirtualDub's "mask selected frames" function to freeze about 20 seconds of the video in the middle. When I encoded it to WMV, the effective frame rate dropped to near zero at that point. If anyone's interested, that video is here:
http://fcchandler.home.comcast.net/Brady3.wmv (2 MB)
Of course, it's wildly out of sync in VirtualDub-MPEG2. So then I used WMVTIMES to dump its time codes, and mkvmerge to remux the video + timecode file + audio into a Matroska file. The result looks correct, so I guess my tool has done its job.
Something I had to ask myself though as I jumped through all these hoops... What really is the point of extracting VFR WMV and muxing it into MKV? For me, it was just a challenge to prove it can be done, but I can't imagine ever wanting to do this in real life.
foxyshadis
14th May 2006, 23:12
Well, processing it in avisynth, which at this point is fairly difficult because it requires cfr video. I've had a few people come to me asking for cleanup and dvd conversion of their home videos, in wmv.
zambelli
14th May 2006, 23:37
Well, processing it in avisynth, which at this point is fairly difficult because it requires cfr video. I've had a few people come to me asking for cleanup and dvd conversion of their home videos, in wmv.
I've actually never had problems reading WMV in AviSynth using DirectShowSource(fps=xx). Was I just lucky?
fccHandler
15th May 2006, 00:07
DirectShowSource("Brady3.wmv", fps=23.976)
Doesn't really work with the video I posted. It starts out fine, but b0rks after about 30 seconds.
Wilbert
15th May 2006, 10:33
I've actually never had problems reading WMV in AviSynth using DirectShowSource(fps=xx). Was I just lucky?
If your video is vfr, the syntax above will always result in out of sync video. In that case, you need to extract the timecodes using fccHandler proggy, and use
DirectShowSource("Brady3.wmv", fps=..., convertfps=true)
process it and use those timecodes to get a vfr wmv/mkv back, or make new ones if needed. (Of course you don't need to extract any timecodes if you want to keep it as cfr.)
edit typo :)
fccHandler
16th May 2006, 01:46
Do you mean "DirectShowSource("Brady3.wmv", fps=23.976, convertfps=true)"? This actually works very well, although it's not exactly the same as how WMP presents the video. It does stay in sync though.
Thanks for pointing it out, because I never knew about that feature of DirectShowSource. Furthermore, this could be the solution to redfordxx's problem of converting VFR to CFR.
redfordxx
16th May 2006, 16:44
Do you mean "DirectShowSource("Brady3.wmv", fps=23.976, convertfps=true)"? This actually works very well, although it's not exactly the same as how WMP presents the video. It does stay in sync though.
Thanks for pointing it out, because I never knew about that feature of DirectShowSource. Furthermore, this could be the solution to redfordxx's problem of converting VFR to CFR.
No, it is not, tried before:
DirectShowSource with fps=23.976
DirectShowSource with fps=23.962 or something like that (this was framerate reported by VDM2)
DirectShowSource without fps parameter.
Always out of sync. Strange thing, I realized that in the recoded clip, the audio started with the video, then after short time it was 2sec shifted and then remained 2sec shifted till the end. So I could shift it and the out of sync part would be only in the beginning.
So the way for me would be to get all the frames and mux timecodes (thru Matroska or AviSynth, I don't know).
I only wonder, that there was no difference in timecodes in the beginning. 50,33,50,33,50,33 all the time, sometimes 50 twice etc...
Wilbert
16th May 2006, 16:48
Could you upload such a wmv clip (~50 frames) for me?
redfordxx
16th May 2006, 17:26
Could you upload such a wmv clip (~50 frames) for me?
OK, but it will take few days... I am not home now and then I have to install codec and/or some cutting tool.
(Because I have reinstalled Win twice beause AviSynth stopped to work... and I didn't know that the only reason was bug in a nonused avsi in plugin dir... I was mad:-)))))
Anyway, thanks much for concern in advance.
@redfordxx,
The DirectShowSource() in 2.57 Alpha 3 now has a logfile option. In the logfile is the timecodes for each audio and video sample along with much other diagnostic information.
Can you please download and install this release. Then load and play your script from the beginning upto just after where the audio jumps 2 seconds out of sync. Then send me the logfile. I will then see what can be done to improve said sync.DirectShowSource("blah.wmv", ...., logfile="blah.log", logmask=-1)
....
Here is a version of WMVTimes that works on Win98 (non-unicode)
redfordxx
28th May 2006, 14:13
Here it is... I guess the shift happens in first 45 seconds.
Thanks
@redfordxx,
Your blah.wmv file has a 2 second discontinuity around frame 732. My guess is 1. your capture app wrapped it's ring buffer and dropped around 100 frame. or 2. Your capture app is using the crappy 18.2Hz legacy clock (hence the 33, 50, 34, ... timecode steps) and glitched about 2136 milliseconds.
If case 1 the audio will fall behind at frame 732, DirectShowSource("blah.wmv", ConvertFPS=True) should correct this. Please report in detail what happens with this option.
If case 2 the audio will jump ahead at frame 732, sorry I can't help with this.
Also the average time per frame reports as 417014 x 100ns which translates as 23.98001026344 fps which is quite a bit different from an expected value of 23.976 or 417083 x 100ns which could lead to about 0.5 secs per hour drift. (0.2 secs error makes noticable lip sync)
Cyber Akuma
21st August 2006, 06:38
Sorry for resurrecting an old thread, but since im having a similar problem I thaught it would be better to reply here than to start a new topic.
I had an WMV file I coudlent determine the FPS of, so I tried WMVTIMES, but the resulting txt file started with 0 and kept constntly increasing until it ended with 97997, this dosent really seem to make much sense.
foxyshadis
21st August 2006, 08:02
Try adding an "# timecode format v2" at the top and run it through liisa-chan's timecode v2->v1 tool. See the new containers forum.
Cyber Akuma
21st August 2006, 10:02
Alright, it says "Assume 29.970" at the top, but theres still a lot of numbers below it that I don't understand what they are supposed to mean.
foxyshadis
21st August 2006, 10:45
If they're all close to 29.97 it's probably just noise. If (most likely) they're whole fractions of 29.97 (like 14.985, 9.99, etc) the wmv has skip frames, and will have to be opened via directshow (dss with convertfps=true) to keep sync, but it's still 29.97. If there's all kinds of 17.this and 24.that, well, your video has no single framerate, and has to be quantized to something, which means jerkiness.
Cyber Akuma
21st August 2006, 14:15
Theres 3 sets of numbers, im not sure what the first two are for but the 3rd ones are all negatives, save for one in the middle and two near the end. The last one is is 14.195 but the others are 28.971 and 21.978. Other than those, its filled with -21453.
IanB
22nd August 2006, 02:49
@Cyber Akuma,
Maybe going back to first principles will help.
The output from WMVTIMES.EXE is a list of timestamps in milliseconds. Each timestamp is the time that the associated frame is intended to be displayed.
So for a 29.97 fps stream the number would go something like :-
0
33
67
100
133
etc
As WMV support variable frame rate, VFR, the numbers may not be uniformly increasing.
The number of frames in your video is equal to the number of lines in the WMVTIMES output file. The total duration is approximatly the value of the last timestamp, 97.997 seconds in your case (it's actually 1 average frame duration longer). If your video were 29.97 fps, with a constant framerate, I would expect 2937 lines in your WMVTIMES output.
Cyber Akuma
22nd August 2006, 05:53
Oh I see, so the numbers in the V2 were just the time at wich that particular frame is to be displayed.
There were 2240 lines according to msword, so I guess that means that the video has 2240 frames in it right?
What are the three numbers used in the V1 converted text file for then?
The first and second numbers seem to stay the same for any negative value in the 3rd number on a line, but they are slightly different when an actual FPS is displayed.
Im guessing for the ones where they first and second numbers are different and a framerate is displayed, they mean thats the fps for frames XXX through XXX?
But I don't understand the negative numbers in the 3rd colum.
For the V1, it starts with "Assume 29.970", has a "869,870,28.971" a little past the halfway point, and has "2227,2231,21.978" and "2235,2238,14.985" near the end.
Does this mean that it starts at 29.970 FPS, has 1 frame at 28.971 in the middle, 4 frames at 21.970 and then 3 frames at 14.985 at the end?
Or does it mean that once I hit that 28.971 mark itll continue being at 28.971 until it hits the 21.978 mark?
I am hoping its not the latter, since I heard that converting the FPS causes the video to appear blurry and/or choppy on areas where the fps different greately from the one used in the avs file.
foxyshadis
22nd August 2006, 11:25
Some of the numbers are probably just rounding errors because a few frames don't cleanly match 14.985 or 29.97, so it translates a clump of them into something halfway when they're really some of both, you don't want to match your video back up to that. 14.x means that every other frame was skipped for the duration.
In other words, you have 30p with a few skipped frames, and don't seem to have any 24p. Opening it while converting to 29.97 in dss should give you a perfect cfr result.
The negative numbers are very strange, though, I can't imagine why they'd show up unless it's a bug in wmvtimes or in the v1 converter.
Cyber Akuma
23rd August 2006, 00:23
Well, I tried it with an AVS that contained the following:
directshowsource("file.wmv", fps=23.976, convertfps=true)
But the avi that VirtualDubMod produced isnt that good. There are many parts where it seems to pause for about a second then just suddenly jumps to the frame its supposed to be on after the pause is over.
IanB
23rd August 2006, 01:22
Okay to stop us all pratting around guessing in the dark, post the output of WMVTIMES so we can analyse it!
The very original source may have had lumps of drop frames and there is nothing that can be done to rescue it. Until we see the time index list we just don't know.
In the meantime, a little bit of maths to sooth the soul :-
Length = 97997ms
Frames = 2240
Average FPS = (2240-1)/(97997/1000) = 22.848
Therefore as this is NOT one of the nice frame rates we can assume that it is probably VFR. Also as the V1 output has an entry 28.971 the original CFR source has to be at least this or greater. And given the V1 output said Assume 29.970 it's probably a fair safe bet.
So
directshowsource("file.wmv", fps=29.97, convertfps=true)
might have been a more logical starting point.
Cyber Akuma
23rd August 2006, 02:11
Ok, here are the V2 and V1 times I got from analyzing the file.
IanB
23rd August 2006, 03:14
Okay, it's fundametally 29.97 fps. Most of the delta times are 33 or 34 milliseconds.
BUT! there are great chunks with frozen frames. i.e.Frame 0 333ms
Frame 78 334ms
Frame 80 100ms
Frame 84 868ms
Frame 85 967ms
Frame 86 634ms
Frame 147 1401ms
Frame 151 1101ms
etcNow either the source material has very low motion in these regions and the encoder has done some gross temporal compression. Or the original source capture had problems with drop frame big time.
Motion interpolation could put back a couple of frames but 1.4 seconds, no way.
Also looks like the V1 program has a bug.
Cyber Akuma
23rd August 2006, 03:59
The motion is slightly low, actually, I think theres some periods where theres supposed to be practically no motion for a few split seconds.
I got this video file off an Xbox game I bought, it was an old game where they were still using .wmv formatted movies before they switched to the closed .xmv format, but it played fine on my pc so I assumed it there wasnt anything strange about it.
The frozen frames would explain why the encoded version skipped like that, there were supposed to be brief pauses before the video continued.
L.H.V.F.
23rd February 2014, 23:20
Hi,
I've followed some Forums in my intention looking for some WMV synchrony, and I have found FFmpegSource (https://github.com/FFMS/ffms2), and the technique of use some hack to synchronize with Timecodes, and in middle of the way, I have found in another Forums of Audio/Video the reference of the "WMVTIMES.exe", created by fccHandler developer, that I have met at Unofficial VirtualDub Forums. The fccHandler developer have vanished your presence of the web, since aproximately end of 2012, and he was never encountered again after this happening. Then, I haven't the possibility of to communicate with him, about the License and distribution of the program that he have made. The site of fccHandler is unavailable for some years, and I have a copy of the WMVTimes archived on my stuff:
https://drive.google.com/file/d/0B2P9tmmpSwF-MlZ3OE52UDRqWmc/edit?usp=sharing (https://drive.google.com/file/d/0B2P9tmmpSwF-MlZ3OE52UDRqWmc/edit?usp=sharing)
Note: The another copy of the WMVTimes, is the WMVTimesAnsi, and it was designed to have possibility of to run in windows 98, and this last is attached in some post of this Thread. The Wayback Machine (http://archive.org/web/) had not a copy in snapshot of the WMVTimes. Hope not to bump in some license issue.
Thanks for the attention.
Best regards,
L.H.V.F. .
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.