I recently added this to my AVS script to covert my DVD video to what I believe is the correct color space:
But the resulting AVI is now 0.001 seconds shorter, and some of the shots either start 1 frame later or end 1 frame earlier.Code:ConvertToYUY2(interlaced=true)
Is this normal? Or is there something I'm not doing right?
Other software I use in my process:
DVDFab HD Decrypter
DGIndex
Srestore
QTGMC
Xvid
VirtualDub
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 30 of 32
Thread
-
-
Why are you converting, what I am assuming is a commercial DVD, from YV12 to YUY2?
-
You must have done something else to the script. ConvertToYUY2 cannot affect the framecount or duration. The interlaced argument does not make the resulting clip interlaced or not interlaced; it merely affects the chroma resampling. To lose 0.001 second duration means your framerate is 1000 FPS, which is unlikely.
In general, if your script is giving odd results (and it happens to everybody), take a guess at the problem line and add an Info statement just below it. This tells you about the current image size, framerate, duration, etc etc. If the Info is what you expected at that point, try another line. It may take several guesses, but eventually you will find the line that actually caused the problem. -
The problem is more likely in the source filter. Some are not frame accurate on random seeks.
-
-
The millisecond difference in length is probably a rounding error by the program reporting the statistics.
-
It is a commercial DVD. But it's my understanding that VirtualDub doesn't handle interlaced YV12 properly. So shouldn't I be converting it to YUY2?
Is there a more accurate alternative to random seeks?
I have frames I'm trying to hide with typography overlays that I add using the TextSub filter. So even with this small difference, the out of place frames are actually apparent even at regular playback speed because the original typography that I don't want to be visible is usually different enough in appearance so that it can be seen briefly flashing (for 1 frame). -
It depends on what you're using VirtualDub for. If you are performing an inverse telecine in AviSynth (and the tools for that in AviSynth are far better than those in VirtualDub), or otherwise deinterlacing, the final output is progressive YV12 -- fine for VirtualDub. If you need to work with interlaced video in Virtualdub you definitely want to convert toYUY2 or RGB first.
What source filter are you using? The most reliable for MPEG 2 video is DgMpgDec. Build an index file with DgIndex then open that with Mpeg2Source("filename.d2v") in AviSynth. -
I'm working with interlaced video by opening VirtualDub and then loading my AviSynth script.
It is DgMpgDec that I'm using. And I've been using DgIndex just as you say. But when you say to open it in AviSynth, you mean to open the AVS script from VirtualDub when AviSynth is installed, right? That's my exact process.
I'm also using the AVS script to replace the opening sequence with one from a second DVD. -
So maybe the problem is with your subtitling software?
A quick fix might be to simply delay (pos or neg) all subtitle timings by 1 or 2 ms using e.g. SubtitleEdit to account for the small difference.
For me it is also not clear how you measure 1 ms difference. I mean you have your AviSynth script with DgMpgDec (what exactly does AviSynth say via info()?) and VirtualDub and I assume you look in VirtualDub File->File information. But where do you get the value you compare to? I mean frame rates on DVDs are standardized and constant so you could just use a calculator to come up with a correct value down to nanoseconds and then decide whether AviSynth/VirtualDub did some rounding wrong or not. -
You should post your full AviSynth script.
DgMpgDec does have problems with MPEG 2 in some containers. Its MKV parsing is bad, for example. But I've never had an issue with MPG or VOB containers.
If you're using a multithreaded build of AviSynth be sure to run Mpeg2Source() at mode 5:
Code:SetMtMode(5,4) # mode 5, 4 threads Mpeg2Source("filename.d2v") SetMtMode(2) # mode 2 etc()
Last edited by jagabo; 25th Feb 2018 at 08:08.
-
I've been opening the finished AVI in VirtualDub, going to the final frame, and looking at the bottom of the screen where it shows the frame number and timestamp.
How do I do this?
Code:LoadPlugin("C:\DGDecode.dll") clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") clip2.Trim(18,2704)FadeOut(19) + clip1.Trim(2688,0) LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") QTGMC( Preset="Placebo" ) ConvertToYUY2(interlaced=true) Srestore(Frate=23.976)
I've found at least one instance in which not converting to the the YUY2 color space results in a unique frame that is completely missing. I know you said not converting the color space in my case is incorrect, but I thought I'd mention it in case it sounds odd.Last edited by lomaidala; 1st Mar 2018 at 19:59. Reason: I accidentally quoted the wrong person.
-
You're using QTGMC to deinterlace the clip. There's no need for convert to yuy2 for VirtualDub, it's no longer interlaced.
You're inconsistent seeking is caused by SRestore. It does not generate the same sequence of frames upon random seeking. It needs to be run linearly. -
if you're going to use FadeOut like that, you're increasing the framecount by one. If you want to keep the framecount the same, make it FadeOut0. I have no idea how not putting the 'dot' between the Trim and Fadeout affects this as normal scripts always include the dot.
In fact, that whole script looks kind of convoluted to me. I stick all the LoadPlugin and Import lines before the actual script begins. There are other things I'd quibble with but different brains organize things differently.
I test unblending with Yadif(Mode=1) because it's so much faster, and then put on QTGMC or another slower bobber for the encode. As jagabo mentions, seeking doesn't work quite right with SRestore. I 'sneak' up on the place I want to check by advancing from maybe 100 frames earlier, giving SRestore time to lock in the cadence. -
Thanks, that's good to know, but I did some comparisons with random frames, and the video with YUY2 conversion seems to be ever so slightly higher in quality (in the areas with medium dark colors). Plus the resulting file size is smaller (804mb instead of 820mb). While I'm much more concerned with doing things in a way that results in the highest quality at the expense of file size, a smaller file size with higher quality seems like a win win. Although now you have me wondering if there's something I'm missing.
Is there something else happening here I don't know about that I'm doing when I convert to YUY2 in this case? Some loss in quality I haven't noticed?
Is there some other disadvantage to converting to YUY2 in my case?
Also, what about that unique frame I noticed that's missing when I don't do a color space conversion?
How do I run it linearly?
Thanks! I've been manually subtracting a frame to compensate because I knew about the extra frame being added but didn't know about FadeOut0.
I didn't know I was leaving out a dot, thanks! I'll have to run some tests at some point and see if I can spot a difference with or without the dot. So like this, right?
Code:clip2.Trim(18,2704).FadeOut(19) + clip1.Trim(2688,0)
I'm curious what these would be if you feel like sharing. I'm always eager to learn about a potentially better or more efficient way of doing things.
That makes sense. I'll keep this in mind, thanks.
You do this from VirtualDub? And you do it after processing the video, right? -
Converting from YV12 to YUY2 will blur the colors a bit. And if VirtualDub is working in RGB (many VirtualDub filters only work in RGB) you will get further blurring of colors. Converting directly to RGB in AviSynth should give better results in this case.
I think what you interpret as "slightly higher... quality" is really artifacts from ConverToYUY2(interlaced=true). At that point in the script the video is no longer interlaced. So that conversion will be messed up.
ConvertToYUY2 did not cause that. It was SRestore and the way you scrubbed through the video.
Open the script in VirtualDub, encode to a lossless intermediate without any filtering, open that intermediate in VirtualDub for editing.
Yes. But in this case you lucked out and the original script will work. Whenever you don't specify a clip by name the name "last" is used. Your line:
Code:clip2.Trim(18,2704)FadeOut(19) + clip1.Trim(2688,0)
Code:clip2.Trim(18,2704) FadeOut(19) + clip1.Trim(2688,0)
Code:last = clip2.Trim(18,2704) last = last.FadeOut(19) + clip1.Trim(2688,0)
Code:clip1 = MPEG2Source("C:\1\VTS_01_1.d2v").Trim(2688,0) clip2 = MPEG2Source("C:\2\VTS_01_1.d2v").Trim(18,2704)FadeOut(19) clip2 + clip1
Code:clip1 = MPEG2Source("C:\1\VTS_01_1.d2v").Trim(2688,0) clip2 = MPEG2Source("C:\2\VTS_01_1.d2v").Trim(18,2704) last = last.FadeOut(19) clip2 + clip1
-
Ok, thanks! So ConvertToRGB? Do I still need the (interlaced=true) part?
Strange, it looked like less artifacts when I used ConvertToYUY2.
Did I use SRestore incorrectly? Or is this just an inevitable consequence of using SRestore? Or should I be using something else in place of SRestore?
Okay, using a lossless codec as opposed to uncompressed video, I presume.
Thanks for telling me about the automatic "last" naming.
So should I be using the dot and naming my clips manually? Is that what you're suggesting? How would you do it? -
Check to see what colorspace your VirtualDub filters are using. Its Filters dialog will show that if you tick "Show Image Formats".
I already told you: after QTGMC your video is no longer interlaced.
Post a sample. Source video, script, and images.
How many times do you have to be told this? Random seeks when using SRestore may not return the same sequence of frames as when running linearly. If you don't want to make an intermediate file, do what manono suggested. Seek a few hundred frames before the frame of interest and step forward frame by frame until you get to the frame you want. That gives SRestore time to lock into a long term pattern.
There's no alternative.
Uncompressed is fine -- but the files will be 2 or 3 times larger.
Some people like to explicitly name every stream. I usually rely on automatic use of last unless I'm using multiple streams. Even then I usually rely on last for the main stream and name the others (not always). Do whatever you want. Just understand what's going on. -
The thing that isn't clear to me here is how seeking around and stepping frame by frame corresponds to specifying how SRestore functions in my AVS script.
So are you saying that when using filters, the color space the filter indicates determines what color space I should convert to in my AVS script? It says RGB32 for both input and output. Does that mean I shouldn't be putting any color space conversion in my script?
What I meant was what should I be doing to my script? Should I put in (interlaced=false)? Or simply remove that part and leave it as simply ConvertToRGB?
How can I tell whether or not I'm using a multithreaded build of AviSynth?
I wasn't certain my question would lead to an answer that's already been given. When you said it was "the way" I've been doing something that's giving me my results, it was unclear to me whether you were implying that there's "a better way" I could be doing things, or simply that I'm doing things "the right way," and that my results are a normal, expected, and inevitable consequence. The main reason I asked for clarification is because I want to make sure I'm creating the video the right way. -
It doesn't matter if it's clear to you or not. It's for this precise reason why I use Yadif(Mode=1) for testing before using QTGMC or another slow bobber for the actual encode.
So are you saying that when using filters, the color space the filter indicates determines what color space I should convert to in my AVS script? It says RGB32 for both input and output. Does that mean I shouldn't be putting any color space conversion in my script?
Should I put in (interlaced=false)? Or simply remove that part and leave it as simply ConvertToRGB?
bool interlaced = false
If true, it is assumed that clip is interlaced; by default, it is assumed to be progressive.
.
.
.
Note, interlaced=true has an effect only on YV12↔YUY2 or YV12↔RGB conversions.How can I tell whether or not I'm using a multithreaded build of AviSynth? -
Same here. I pretty much only use VirtualDub to view the results of AviSynth scripts. I occasionally might use Neat Video or DeShaker in VirtualDub.
-
I didn't know AviSynth has a TextSub equivalent that's even better. Thank you for telling me!
Thanks. I actually did do a search through http://avisynth.nl, but I didn't find anything that was clear to me.
What do you use to process the video for your AviSynth scripts? -
I usually encode with x264 cli. Them mux audio and video with MKVToolnix.
-
Thanks everyone for your help. I really appreciate it. Can I get some final feedback on my updated script? If anything can be improved, even if it works but just looks funky, please let me know.
Code:LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") ConvertToRGB (clip1) ConvertToRGB (clip2) clip2.Trim(18,2704).FadeOut0(19) + clip1.Trim(2687,0) QTGMC( Preset="Placebo" ) Srestore(Frate=23.976) TextSub ("C:\1.ass")
-
QTGMC and SRestore don't work on RGB. If you want RGB output put ConvertToRGB() at the end (you don't need it here). And, assuming your sources are interlaced , if you needed to use ConvertToRGB where you have it, you would need to use interlaced=true -- because the videos are still interlaced at that point. It's not progressive until after QTGMC.
-
I see there are several equivalents for AviSynth. Which one do you recommend?
Thanks. I've already confirmed my sources are encoded interlaced and have interlaced frames, and that there's field blending.
Do I need to use ConvertToRGB where I have it? Or should I put it at the end? -
My guess is they all work. I think I use the old V2.23. You need the VSFilter.dll and then the TextSub line as you showed in the previous script. If the subs are in the same folder as the rest of the files, you don't need the path. You can just use:
TextSub("1.ass")
Do I need to use ConvertToRGB where I have it? Or should I put it at the end?
About the only time I ever convert to RGB is for the very rare times I need to do some color work using ChannelMixer. -
Maybe you don't understand: in AviSynth video flows from filter to filter, starting at the top and flowing down (when filters are on the same line, explicitly piped or not, the frames pass from left to right). So lets look at what your script does:
Code:clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v")
Code:ConvertToRGB (clip1)
Code:ConvertToRGB (clip2)
Code:clip2.Trim(18,2704).FadeOut0(19) + clip1.Trim(2687,0)
Code:QTGMC( Preset="Placebo" )
Code:Srestore(Frate=23.976)
Code:TextSub ("C:\1.ass")
So your two ConvertToRGB calls have the net effect of doing nothing.Last edited by jagabo; 5th Mar 2018 at 08:21.
-
That's something I've been conscious of, but it's properly executing what I want to do that I have a problem with. Regardless, thanks for confirming that. My only goal with all of this is simple: I just want to cut two DVDs together and create the highest quality video I can using AviSynth and VirtualDub (and redo a few shots of typography with some overlays if I can, hence TextSub).
But last (YV12) from QTGMC also includes Srestore before it is passed to TextSub, even in the case of my previous script you're referencing, right?
Thank you so much for breaking it down like that. That's really helpful. I had no idea how many blunders I had in there. I didn't realize I was overriding streams with "last." I thought I was combining, adding, and accumulating, rather than canceling streams out.
Can I get your feedback again on this update? Please do be critical. I want to improve it if possible.
Code:LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") clip1 = MPEG2Source("C:\1\VTS_01_1.d2v") clip2 = MPEG2Source("C:\2\VTS_01_1.d2v") clip2.Trim(18,2704).FadeOut0(19) + clip1.Trim(2687,0) QTGMC( Preset="Placebo" ) Srestore(Frate=23.976) TextSub("1.ass")
Great, that's the one I've been using and you are right, it is way better than the VDub filter equivalent. I'm very happy with the results, thanks! And thanks for the TextSub tip.
Next stage as in putting it into a DVD format? That doesn't apply to me. As far as I know, there is no next stage. The end result is intended to be an AVI created by loading the AviSynth script in VirtualDub and then processing the video.
As for why I thought I needed ConvertToRGB, it was based on these comments:
If you need to work with interlaced video in Virtualdub you definitely want to convert toYUY2 or RGB first.
Converting directly to RGB in AviSynth should give better results in this case.
Similar Threads
-
Modify Color Space Flag
By chris319 in forum Newbie / General discussionsReplies: 74Last Post: 1st Aug 2017, 22:30 -
Avisynth FFmpegSource2 wrong color space
By Veggav in forum EditingReplies: 3Last Post: 10th Apr 2016, 09:47 -
Video is not YV12... color space
By Mark22 in forum Video ConversionReplies: 3Last Post: 6th Mar 2015, 12:41 -
Automatic Color Timing plugins for Premiere?
By jrodefeld in forum EditingReplies: 6Last Post: 25th Dec 2014, 03:08 -
mencoder -> ffmpeg -> color space mix-up
By Selur in forum Video ConversionReplies: 9Last Post: 12th Jul 2013, 11:23