View Full Version : How to get Canon HV20 MPGs into VirtualDub using AviSynth


Slasrath
18th September 2011, 14:05
I've got a question that I hope you can answer...

I have a Canon HV20, that I use TSReader to extract the .MPG from (as a transport stream). I want to use AviSynth to load it into VirtualDub, because it gets far better compression rates than AnyVideoConverter with better quality and no sound error messages, but my computer has been reformatted/upgraded a few times since and the scripts no longer work. :/ I'm probably not installing something, due to my lack of technical jargon... Does anyone know how to get the file to read in VirtualDub using AviSynth? Any help would be greatly appreciated.


The current error message in VDub is that the file format isn't supported.

Mounir
18th September 2011, 19:08
mediacoder is best for encoding in x264 if that's the end goal.
Otherwise you have to make a .dga file with DGAVCindex of your file.
The script:

v=AVCSource("C:\MyVideo.dga")
a=WAVSource("C:\MySound.wav")
audiodub(v,a)

Yellow_
19th September 2011, 07:44
HV20s are mpeg2 not mpeg4 so DGDecode rather than AVC sorry if not got the names right long time since I used them.

FFmpegSource2 is another option but not version 2.16 it doesn't keep full luma.

For encoding out to mpeg2 there's hcenc 0.25

Ghitulescu
19th September 2011, 12:58
I have a Canon HV20, that I use TSReader to extract the .MPG from (as a transport stream). I want to use AviSynth to load it into VirtualDub, because it gets far better compression rates than AnyVideoConverter with better quality and no sound error messages

You may want to specify also the goal of this compression, because there are several other items to be considered in this respect (deinterlacing, colour conversion to name the most relevant).

And yes, virtualdub is quite old and is not really suitable for HDTV (by the way, are those clips HD or SD?).

Kimmmmm
19th September 2011, 13:51
Thank you for providing this valuable info for those that can use it, but for Matrox RT.X2 users, it seems bit redundant to create a Matrox .avi, then also use the scripts. Simply open a Matrox DV Widescreen project, and Import the Matrox MPEG-2 I-Frame HD file to the timeline. The Matrox hardware offers good quality downscaling in realtime, taking Adobe “out of the equation” in the area of scaling, so the user need only Export to MPEG-2 from Adobe to get clean results at that point.

Perhaps Dan’s scripts will yield even better results, haven’t tried, but the Matrox method does eliminate the scaling issues typically seen from Adobe with HDV to DVD and looks good to me.

Thanks

hello_hello
19th September 2011, 14:35
And yes, virtualdub is quite old and is not really suitable for HDTV (by the way, are those clips HD or SD?).

VirtualDub is still being updated.
To me it sounds like the OP is trying to open the file via AVISynth which means AVISynth would be doing the work and feeding uncompressed video to VirtualDub. From there, VirtualDub can then convert the uncompressed video to Xvid etc regardless of the original video type or resolution. I use VirtualDubMod to convert HD content (MP4s and MKVs) to Xvid/AVI quite regularly by opening the video via an AVISynth script. Well in my case I'm using AutoGK as the encoder GUI but it still opens the video via a script and uses VirtualDubMod to convert it to AVI. Depending on the output format it's still perfectly suitable.

Slasrath, were you using VirtualDub previously or VirtualDubMod? The latter has an automatic function for loading video via AVISynth (using DirectShow or AVISource etc) which may have been what you were doing previously. VirtualDub doesn't have the same ability as far as I know.... you have to create the script manually and then open it with VirtualDub.
It may pay to describe in a little more detail how you were opening the files via AVISynth/VirtualDub previously and which format you're converting them to etc.

Mind you if you want to use a GUI for encoding, then depending on the output format there may be easier options. A program like MeGUI might be a better choise as it'll open a lot of different file types and convert them to x264 or Xvid. If you're converting to Xvid/AVI then AutoGK might still be a good choice. I'm pretty sure it'll open and convert ts files containing mpeg2 video directly and it converts them to Xvid/AVI using VirtualDubMod while letting you know what the quality will be.

hello_hello
19th September 2011, 14:53
Slasrath, do not use VirtualDub, learn the avisynth language. You can make almost any thing with perfect quality here. Using VirtualDub you will get quality loss, because VirtualDub has video processing on RGB color - you may lose some visual "seamlessness", also any conversion may destroy full range color areas, if your video has it.

I don't think there's necessarily going to be conversion to RGB just because you're using VirtualDub. Doesn't it depend on the processing mode when you're converting the video and/or the VirtualDub plugins you're using?

Slasrath
19th September 2011, 15:32
Hello, thanks for your quick replies.:thanks:

mediacoder is best for encoding in x264 if that's the end goal.

I might look into MediaCoder and see if that is a decent alternative... But the method I used simply involved DirectShowSource, with some possible driver installation that I am forgetting. My end goal, is probably .avi or .mpeg. Something easily shareable cross-platform and loadable into VLC.

Slasrath, do not use VirtualDub, learn the avisynth language. You can make almost any thing with perfect quality here. Using VirtualDub you will get quality loss, because VirtualDub has video processing on RGB color - you may lose some visual "seamlessness", also any conversion may destroy full range color areas, if your video has it.

I'd like to but I barely know the terminology I'm no doubt tripping over as I describe the problem to you folks. Honestly I'd like to stick with what I know has worked in the past and wasn't too difficult to manage.

You may want to specify also the goal of this compression, because there are several other items to be considered in this respect (deinterlacing, colour conversion to name the most relevant).

And yes, virtualdub is quite old and is not really suitable for HDTV (by the way, are those clips HD or SD?).

Mostly reduction in filesize, if that wasn't a problem, i'd just use the original .mpeg. VDub has the deinterlace/resize function i need as well as a couple of others (though I would like to do that slow motion trick you can do with interlaced video at times, not sure that VDub can pull that off). My HV20 is set up for HD video (60 min/tape)


Slasrath, were you using VirtualDub previously or VirtualDubMod?

I've tried both versions, neither seem to work. There's definitely something I'm not doing to get the file viewable.

Robert Martens
19th September 2011, 16:35
I don't think there's necessarily going to be conversion to RGB just because you're using VirtualDub. Doesn't it depend on the processing mode when you're converting the video and/or the VirtualDub plugins you're using?

As long as you don't use any VDub filters, the conversion to 32 bit RGB isn't automatic anymore. From the VirtualDub help file (under Processing->The pipeline):

"In previous versions of VirtualDub, enabling full processing mode would always force a conversion to 32-bit RGB. This is no longer the case — if no video filters are used, this conversion step is omitted and the video is directly converted to the output format as in Normal Recompress mode."

"Fast recompress" still at least prevents you from accidentally choosing incorrect options in the Video color depth dialog, and disables the filtering capabilities of VirtualDub altogether, so it provides a bit of extra protection against something going wrong by mistake, but the conversion to RGB32 in "Full processing" mode is no longer a guarantee.

hello_hello
19th September 2011, 16:59
hello_hello, I use VirtualDub for preview and Deshake. My source files are full-range 0-255. I get a truncate. To use VirtualDub correctly I must to convert colors of my video to VT range first. I don't like it, because I must convert them twice, also on 16-bit color plugins.

I don't know why your method forces you convert to TV range and back again, but 99% of people converting video would be converting video which uses the 16-235 range anyway.
Does converting the range necessarily mean converting to RGB and back again also? Can't you convert from full to TV range and back again without ever having converted to RGB?

hello_hello
19th September 2011, 17:22
I've tried both versions, neither seem to work. There's definitely something I'm not doing to get the file viewable.

Without knowing what you are doing exactly, I'd only be guessing as to what it might be you're not doing. No doubt you're correct though, it's got to be something. ;)
Obviously you're not trying to open the video with VirtualDub directly because you said you were trying to load it via AVIsynth, but I've no idea how you're attempting to do that.

Can I suggest you give AutoGK a try for converting ts files to avi? It'll worry about the de-interlacing and cropping etc for you, all you have to do is pick the output resolution, the output audio type, desired quality (or file size) and then let AutoGK do it's thing. It uses AVIsynth and VirtualDubMod etc. for the encoding.
Just select the "Target Quality" encoding mode and you're done. The default of 75% is about the optimum quality/file size ratio for Xvid. Alternatively you can pick the desired file size, leave the output resolution and audio type in "auto" mode and let AutoGK sort it out for maximum quality.
AutoGK is about as simple as it gets but that doesn't stop it from producing good quality encodes. As long as the TS streams do actually contain mpeg2 video then the type of encoding you're doing..... that's exactly what AutoGK was designed to do. I still use it regularly.
http://www.autogk.me.uk

It might save you a lot of time trying to work out what that something you're not doing might be.

pvann
20th September 2011, 04:00
I have a Canon HV20 and get *.m2t files to my computer by copying using HDVSlpit. The following script opens the video file in AVISynth

DirectShowSource("filename.m2t")


for processing in AVISynth and subsequent opening that in VirtualDub (I think I have Virtualdub Mod) or various encoding programs that take AVISynth files.

2Bdecided
20th September 2011, 06:09
I don't know why your method forces you convert to TV range and back again, but 99% of people converting video would be converting video which uses the 16-235 range anyway.Not the OP - like most consumer camcorders, the HV20 stores 16-255.

2Bdecided
20th September 2011, 06:11
You can't really reduce the filesize without reducing quality. Equivalent quality efficient x264 is quite challenging to decode, so not reliably portable.

But a start would be to use DGIndex, the trick to auto-create AVIsynth scripts, then encode using MeGUI.

You might choose to deinterlace, and you might choose to downsize to 1280x720.

Cheers,
David.

smok3
20th September 2011, 08:14
I have a Canon HV20, that I use TSReader to extract the .MPG from (as a transport stream). Does anyone know how to get the file to read in VirtualDub ...

this might work
http://home.comcast.net/~fcchandler/Plugins/MPEG2/
(skipping avisynth completely)

Slasrath
20th September 2011, 15:39
this might work
http://home.comcast.net/~fcchandler/Plugins/MPEG2/
(skipping avisynth completely)

Nope...

Error Message: The audio has a custom format that cannot be supported.

And after that, it didn't load.

It also took a LOOOOONG time to get through an interleaving process. The other way, using Avisynth in some fashion didn't have this problem.

hello_hello
20th September 2011, 17:12
It also took a LOOOOONG time to get through an interleaving process. The other way, using Avisynth in some fashion didn't have this problem.

So I guess you're not going to try to explain your process for opening the files previously and just keep us guessing?

You've been given a couple of suggestions for basic AVIsynth scripts to open the file with VirtualDub, did you try either of them?

AutoGK will do what you're wanting to do using VirtualDubMod and AVIsynth. Did you consider trying it?

Use VirtualDubMod, not VirtualDub.
From the top menu: File-Open.
In the window which opens select "All Types" in the "Files of Type" drop down box.
At the bottom of the window there's another drop down box labelled "Use AVIsynth Template". Select "DirectShowSource".
Try opening the file.

Slasrath
21st September 2011, 06:23
Ok, looks like AutoGK does seem to work... although it has some memory problems. And it only takes the entire 60 minute tape, i can't seem to cut out only certain time segments. I can't reopen the program after I've done a conversion. Still it's better than not getting any compression so thanks for the suggestion.

My AviSynth scriptfile was just using DirectShowSource(filename). Nothing else. One line. And I didn't have VirtualDubMod installed, just regular 1.9.10. This USED to work. But now it doesn't, and I can't figure out why. I have updated the new location of the files (the external drive is now internal so the letter changed, but that's it.) That's what I came here to find, I'd rather just install the proper driver or configuration I've not done and just do it the way I'm used to, if that's possible :(

I'm still looking through some of the other methods but I don't have a lot of time in front of the PC like I used to, but thank you for your ideas.

hello_hello
21st September 2011, 12:55
If you have AutoGK installed you should have VirtualDubMod installed. AutoGK installs it inside it's own installation directory.
Try opening your usual script with it or let VirtualDubMod create the script as per my instructions in my previous post.

As I don't work with ts files much I just recorded one to have a play. VirtualDub happily opened the AVISynth file, but the Haali splitter was used when opening it, so maybe..... try installing the Haali Media Splitter (http://haali.su/mkv/MatroskaSplitter.exe) to see if that helps. I also discovered VirtualDub was happy to open the TS file directly, but after a little experimenting I discovered that's because VirtualDub was using the DirectShow input plugin (http://forums.virtualdub.org/index.php?act=ST&f=7&t=15093&) to do so, so you'll need to download it and stick it in the plugins folder if you want to bypass using an AVIsynth script.
Installing the Haali splitter may be the simple answer. I was using ffdshow to do the decoding.

Maybe the problem is with your TS file? You could try remuxing it with tsmuxer (http://www.videohelp.com/tools/tsMuxeR). I don't know anything about tsreader so don't know if it might have created a "problem" ts file.

Failing the above.... given AutoGK is working and therefore you can open the file via AVIsynth after it's been indexed (instead of using DirectShow).... here's a way you can have your cake and use AutoGK too.
AutoGK uses DGDecode to index the ts file so it sounds like the file will open once it's indexed. Rather than worry about trying to do it manually....

-Open the ts file using AutoGK. Select a single pass (quality) encode. Select Advanced Settings and select your desired resolution (or leave it on Auto). Set the Audio type to MP3 (CBR 128 MP3 should be fine). Start the encode. AutoGK will index the file, convert the audio to MP3 and then start encoding. -When it gets to the point where it's encoding, stop the encode.
-Navigate to the AutoGK temp folder called "agk_temp" (it's located in the AutoGK output directory). Inside it you'll find the AVISynth script AutoGK created. Open it with VirtualDub. The video should display as it's already been indexed. Then from the Audio Menu at the top, select "Audio/Audio from other file". Navigate to the AutoGK temp folder and add the MP3 file AutoGK created. Check the name of the MP3 audio. If it includes a delay value at the end of it's name (a positive or negative number other than zero) you need to manually add the delay. From the Audio Menu again, select "Interleaving". Enter the delay value in the audio track delay box. Hit okay.

Now you've opened the video AutoGK indexed for you with VirtualDub, and added the MP3 file AutoGK created, from there you should be able to edit the video as you normally would, and I'm fairly sure if the video needs cropping or de-interlacing etc, AutoGK will have already added it to the script so you don't need to worry about it. Just make your cuts and save the video to an AVI using your normal encoding method.

PS. You can also let AutoGK encode the whole file, then edit it later. You can open the AVI AutoGK created with VirtualDub, make your cuts, then resave it as a new AVI after selecting Direct Stream Copy from the video menu. The only limitation....
In order not to re-encode a second time you have to make the cuts on keyframes (using the navigation buttons with the key icon on them to jump to keyframes). This means you can't always cut the video exactly where you want to, but usually you can get pretty close.

2Bdecided
21st September 2011, 17:52
re-compressing footage from the HV20 before you've even edited it seems a very bad idea if you're going to edit it later from those re-compressed versions. you should always work from the highest quality version you have, which is what came straight out of the camera.

hello_hello
21st September 2011, 18:05
2Bdecided,
Are you referring to my post, because if so you might want to read it again.

2Bdecided
27th September 2011, 17:14
No, post 9.

Cuts only editing is a little restrictive. Whereas HDV has smart rendering in some editors, giving best of both worlds: no quality loss + high speed where possible, and full flexibility where needed.

Cheers,
David.