Quantcast Preserving color space, YV12 vs. RGB vs. 4:1:1 DV? - digitalFAQ Forum
  #1  
09-06-2017, 01:21 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
Hello, I am new here so please take it easy on me :-) I am trying to transfer my Digital 8 tapes to my PC and I have a few questions that I am hoping to get answers and clarification on. The tapes are NTSC and I am doing this on a Widows 10 64-bit computer. I spent the past few days searching for a concrete answer and that has left me with even more questions. The questions I have are related to color space.

This is the transfer process I am using: Sony HandyCam hooked up to my PC by Firewire and using Sony PlayMemories Home software to transfer the footage. I tried WinDV and while it did work, I figured the Sony software might be better considering Sony is still updating and supporting that software. At any rate, I saw no difference when I tried to transfer the same footage using both programs.

After I transfer the footage from the Digital 8 tape, I am left with a DV-AVI file. From what I understand, this file is using the YUV 4:1:1 color space. I am using VirtualDUB with the Lagarith codec to decompress the file to a lossless one for post processing work. Should I be using the YV12 mode in the Lagarith settings to preserve the color space of the original file? If not, what do I do? I saw mentions of using Avisynth instead of VirtualDUB to do this but I canít for the life of me, find examples of how this is done while preserving color space. I would love to go the better route and donít mind learning. I want to do this right and with the least amount of quality degradation as possible.

I am aware that VirtualDUB works with RGB and I should be avoiding using RGB and then converting back to the original color space.

Any help would be much appreciated. My ultimate goal is to archive the original video and convert that video to a few different formats. Like DVD or h264 for Plex.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
09-06-2017, 02:11 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 2,344
Thanks: 76
Thanked 637 Times in 575 Posts
You're correct in that DV source is 4:1:1 color (which is a flavor of YV12). Lagarith YV12 compression is 4:2:0, which is the same thing but which stores the two chroma pixels in a different databits that 4:1:1 does. They are effectively the same information stored differently.

It's also true that NLE editors and VirtualDub convert to RGB for display (and so does your media players and TV). In VirtualDub's case, you can save a processed DV video as lossless Lagarith or whatever colorspace and codwec you want by using VirtualDub's top "Video" menu:

- Click "Video", then click "color depth...", then in the right-hand dialog choose "4:2:0 planar (YV12)", then close that dialog.
- Click "Video", then click "compression...". In the left-hand dialog choose Lagarith lossless compression. In Lagarith's "configure" menu make sure "YV12" is selected, then close and exit the dialogs. When you save the file it will be losslessly compressed as YV12 with Lagarith.

If you are applying VirtualDub filters, then VirtualDub like any editor with RGB filters will convert the video to RGB for the filtering job, but you can still save the video as losssless YUY2 using the menus above.

The reason Avisynth is suggested for colorspace conversions from YV12 is that VirtualDdub doesn't handle interlaced YV12->RGB conversions as neatly as it should (and neither does Adobe Premiere Pro, for that matter, and with Adobe you're talking big bucks). Avisynth does it more cleanly with interlaced YV12 video, whether or not its DV or other YV12 formats. When a DV-AVI is opened with Avisynth, the video is decoded into uncompressed video. To get to the the proper 4:2:0 from 4:1:1 in Avisynth, simply use these built-in Avisynth commands (change the path and filename to match your file name and location):

Code:
AviSource("drive:\path\to\yourvideo.avi")
ConvertToYV12(interlaced=true)
ConvertToRGB32(interlaced=true,matrix="Rec601")
The first command line function (AviSource) opens and decompresses the video file.
The second line converts from 4:1:1 YV12 to 4:2:0 YV12.
The last line converts to RGB32, if needed.
Avisynth itself outputs uncompressed, unencoded video. Avisynth doesn't recompress. Use VirtualDub or your other editors for compression and encoding.

Avisynth scripts are run in VirtualDub, and the output is saved in VirtualDub with "Save AVI..." as directed earlier.

MPEG2, DVD, BluRay, AVCHD, 4K formats, and other h.264 encodes are 4:2:0 YV12.
Reply With Quote
The following users thank sanlyn for this useful post: davidi (09-06-2017), lordsmurf (09-10-2017)
  #3  
09-06-2017, 06:43 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
Thank you for your reply sanlyn! That helped me out a great deal, I appreciate it. Just to make sure I have this correct:

1. Transfer the Digital 8 tape using the method above.
2. Open the DV-AVI in VirtualDub using the following .avs script (I will only use the ConvertToRGB32 in the avs script if I need it.):

Code:
 
AviSource("drive:\path\to\yourvideo.avi")
ConvertToYV12(interlaced=true)
3. Go to File->Save AVI (without touching any other setting in VDub) & let Avisynth & VDub do its thing.
4. Open the newly created file in VDub for further post processing work (such as the resizing method found
here How to Properly Crop the Overscan in VirtualDub [GUIDE])
5. Using the method you mentioned above to process the AVI:

Quote:
- Click "Video", then click "color depth...", then in the right-hand dialog choose "4:2:0 planar (YV12)", then close that dialog.
- Click "Video", then click "compression...". In the left-hand dialog choose Lagarith lossless compression. In Lagarith's "configure" menu make sure "YV12" is selected, then close and exit the dialogs. When you save the file it will be losslessly compressed as YV12 with Lagarith.
6. Open this newly created file in whatever encoder/program I need to output a final file for whichever format I need.

Does it matter what dvsd codec I use for decoding the file when I feed it to Avisynth in Step 2? Currently, I am using Cedocida.
Reply With Quote
  #4  
09-06-2017, 09:34 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 2,344
Thanks: 76
Thanked 637 Times in 575 Posts
Your procedures look correct to me, but allow me to clarify one issue.

The overscan procedure you link to does not resize the video. It masks over (completely covers) parts of he image. Referring to picture borders as overscan is incorrect -- they are borders, not overscan, and it's TV overscan that usually hides those borders. As far as I've seen, DV source fills the entire picture frame and has no visible black borders or bottom-border head-switching noise as seen in VHS, so there's no need for the so-called oversacn procedure.

Even if you do have black or uneven borders, I don't care for obscuring picture areas that originally belong there. Black borders simply become part of the black background in media players and on TV, there's no need to remove them. If you have uneven borders or border noise that you want to get rid of, it's better to crop the offending area and add new black pixels rather than mask over and obscure parts of the image, IMO.

If you have a border problem of some kind, I can show you how to handle it with built-in functions in Avisynth, which won't obscure any part of the original image content. You can make a direct copy of a sample frame in VirtualDub by using "Video" -> "copy source frame to clipboard". Then open a graphics program and paste the frame capture as a new image, then save it as a jpg or png image (png is sharper). A free program that lets you make the image is Windows Paint. You can attach the image to a post in the forum.

Or you can use whatever method you want, but there shoudn't be an "overscan" problem with DV originals.
Reply With Quote
The following users thank sanlyn for this useful post: davidi (09-06-2017), lordsmurf (09-10-2017)
  #5  
09-06-2017, 10:05 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
I attached a sample image. The only reason I wanted to follow that guide was because I noticed that there is this grey bar at the bottom of the transferred video. After searching, I read that, that bar is actually just noise in the overscan area and I can crop it out. When I started searching for cropping methods, I came across that guide that said don't crop, do this instead. That bar does not show if I hook up my camcorder to the TV and play the video that way. It only shows when I transfer the video to my PC through Firewire. I've tried multiple tapes, same thing.

So, its safe to assume that it doesn't matter what dvsd codec I use to decode the video?


Attached Images
File Type: png Sample.png (386.9 KB, 3 downloads)
Reply With Quote
  #6  
09-07-2017, 02:42 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 2,344
Thanks: 76
Thanked 637 Times in 575 Posts
For the sample posted, things don't get too complicated. Using either the VirtualDub method or doing it in Avisynth, you'll crop 8 pixels off the bottom of the image, then add 4 new pixels of black on the bottom and 4 on the top, which is a slight letterbox effect that centers the image vertically. As far as colorspace is concerned, VirtualDub will do it in RGB. In AVisynth, remember that this is interlaced YV12, so horizontally you can crop in multiples of 2 but vertically you must crop in multiples of 4 (there is a way around that, which is to convert to YUY2 temporarily, then crop, and go back to YV12 in Avisynth alone).

Doing the same thing in YV12 in Avisynth:
Code:
Crop(0,0,0,-8).AddBorders(0,4,0,4)
The placement of numbers in the Crop() and AddBorders() functions is in this sequence: (left,top,right,bottom).

It gets a little more complicated when you're working with oddball numbers like uneven left ad right borders. Or the frequent problem in some captures of a top border with a broken half-line of black horizontal pixels that flutters on and off because of interlacing (remember, you can't just remove 1 line horizontally, you must work in two's in both directions). Or in this case you have a bright vertical blemish along the left border, so you'd have to remove 10 left-side pixels to clean that up. To save as much of the picture as possible, you'll have to go to RGB to end up with perfectly even centering horizontally unless you're willing to lose a pixel or two on the left or right side. A purist would fight and scream at doing so, but most viewers would wonder what the fuss is about. On the other hand if you're doing color correction in RGB anyway (which is usually necessary, both in YUV first for levels correction, and in RGB second for specific color range corrections) -- then you might just as well convert to RGB in Avisynth and do the crop/border thing there, or convert to RGB in Avisynth and do the crop/border thing in VirtualDub.

In short, you can handle these problems either way. I stay in YV12 or YUY2 and/or avoid colorspace changes when I can, but sometimes you can't avoid it.
Reply With Quote
The following users thank sanlyn for this useful post: davidi (09-07-2017), lordsmurf (09-10-2017)
  #7  
09-07-2017, 09:17 AM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
Ahhh, I get it now. That makes sense. I will have to play around with it to see which method I prefer. While trying it in VDub, I liked the fact I could see a visual of what was happening. But then again, loading the avs script in VDub will show me what happens to the video in the output pane. Just preference at this point I guess.

So basically, I could reduce the number of steps I do and keep the same color space if I just use this in the avs script (and modify the crop and borders numbers as needed):

Code:
AviSource("<path to file>\test.avi")
ConvertToYV12(interlaced=true)
Crop(0,0,0,-8).AddBorders(0,4,0,4)
That bright vertical line is barely noticeable while viewing, so I am not going to worry about it. Which is odd for me because I am a perfectionist and a purist when it comes to stuff like this lol But, even I realize as I get older, you have to have some tradeoffs. Plus, it doesn't appear to be in every tape I've transferred so far either, or if it is, its very faint.

One more quick question, after I use the .avs script, the resulting file is in a 3:2 ratio format instead of preserving the 4:3 ratio of the original. Why? Am I missing something? My authoring software complained about the file.
Reply With Quote
  #8  
09-08-2017, 03:22 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 2,344
Thanks: 76
Thanked 637 Times in 575 Posts
Lossless AVI files have no imbedded display aspect ratio in their metadata. 720x480 is indeed a 3:2 aspect ratio, but that's the raw anamorphic frame proportions. Your encoder should encode the 3:2 frame for a 4:3 display aspect ratio, which will be a standard encode DAR (Display Aspect Ratio) for DVD/Standard-def BluRay. If you had a PAL lossless AVI instead of NTSC, the 720x576 PAL AVI frame would show a proportion ratio of 5:4. If you didn't encode for a correct DAR, your authoring program won't accept it for DVD.

I don't know what encoder you used, but it should encode for either 4:3 or 16:9 DAR. Authoring programs are not encoders, except those that are combination encoder/authoring apps or editors that include encoding and authoring features. It sounds as if you have an unencoded losssless AVI that you're feeding to an authoring-only app that doesn't have an encoder, or else you didn't encode for a 4:3 DAR.
Reply With Quote
The following users thank sanlyn for this useful post: lordsmurf (09-10-2017)
  #9  
09-08-2017, 07:14 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
Ahh I see. I am using AVStoDVD. Works pretty good, it just complained when I added the video. I did a test run and everything looks good. It asked me if I wanted to force 4:3 and I said yes. I want to thank you again for all of your help. Everything is looking great so far :-)

A couple more quick questions...

I came across a tape where the horizontal line on the left is pretty bad. I tried to follow your directions; I also read about crop and addborders function for Avisynth, but I am not completely understanding the relationship with the two. Here is what I tried and the video came out funny looking:

Code:
AviSource("<path>\test.avi")
ConvertToYV12(interlaced=true)
Crop(12,0,-6,-8)
AddBorders(4,4,4,4)
I do understand that crop is setup like this: "Crop(left,top,-right,-bottom)" as far as negative and positive values go. This will remove the blemish from the left horizontally, clean up the right side a bit and remove the grey line at the bottom. What I do not understand is, how do you calculate the values for addborders based on the numbers from the crop? Is there even a relationship between the crop and addborders numbers or I am reading way too much into it?

I am trying to stay within Avisynth because I do not want to switch colorspaces too much. If I do this fix in Vdub, the resulting file is YUV 4:2:0 colorspace, which from what I understand is different from YV12 4:2:0. Are they indeed the same?
Reply With Quote
  #10  
09-09-2017, 03:42 PM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 6,178
Thanks: 573
Thanked 899 Times in 807 Posts
Quote:
Originally Posted by davidi
...
The important thing to remember is that colorspace conversion isn't evil, bad, or something to be avoided at all costs. It's just a fact of video life.

I've seen where some video purists (color space purists, in this case) shun certain helpful software or filters because it uses RGB, or even YV12. Well, that's dumb. If the filter does what is needed ... use it. Colorspace space isn't going to make your video suddenly turnwhite people turn green, or sprout rainbows, or some other silly notion. It just moves from one space to another.

There is a decades-old argument in digital photo, with AdobeRGB(1998) vs. sRGB vs. others. Each has merits, downsides, and targeted uses. Video is no different. In fact, video tends to be easier, as the colorspace conversion is not so drastic as it is with the stills. With the photos, you sometimes have to counteract the loss (example: magenta tuning), which is something I've never had to do in video conversions. Add CMYK vs. RGB, and conversions, to make it more complicated for printing.

The general rule is this: video isn't a ping pong ball. Don't go back and forth needlessly. Yes, it's that easy.

Avoid going down in YUV 4:4:4. For example, 4:1:1 to 4:2:2 is fine, but avoid too many steps down, going from 4:2:2 to 4:2:0, and pretty much never going to 4:1:1 after having been better. 4:2:0 is better than 4:1:1 in NTSC due to how the siting is done. 4:1:1 is once quartered, while 4:2:0 is merely halved twice. In PAL, DV was 4:2:0, and looks great. Native-shot DV isn't the issues -- the problem is with analog conversions, and even software down-converting.

sanlyn has gone into great detail for you, and looks to be fine advice.

Quote:
Originally Posted by sanlyn View Post
Referring to picture borders as overscan is incorrect -- they are borders, not overscan, and it's TV overscan that usually hides those borders.
Shorthand. As in "in the overscan" (head-switching noise, closed captions, etc -- "borders" isn't correct), which is just shortened to "the overscan". I do this all the time, and have for years.

The alternative is "TV safe area", which I think sounds really stupid and non-technical. It reminds me of TV nannying against George Carlin's "7 dirty words", as in we need a "safe area" for TV viewing. Sort of like "safe spaces" in modern colleges; dumb!

Quote:
As far as I've seen, DV source fills the entire picture frame and has no visible black borders or bottom-border head-switching noise as seen in VHS, so there's no need for the so-called oversacn procedure.
The frame edges are often rough. Encoders can do poorly at frame edges. I often find myself masking 2-3 pixels on all sides.

Quote:
crop the offending area and add new black pixels rather than mask over and obscure parts of the image, IMO.
Cropping and adding back black is the same as masking.

Quote:
Or you can use whatever method you want, but there shoudn't be an "overscan" problem with DV originals.
Rarely a problem, no. You are correct here.

- Did my advice help you? Then become a Premium Member and support this site.
- Find television shows, cartoons, DVDs and Blu-ray releases at the TVPast forums.
Reply With Quote
The following users thank lordsmurf for this useful post: davidi (09-10-2017)
  #11  
09-09-2017, 05:25 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
Ahh I got it. The reason I am so concerned with video color space changes is because of the digital photo color space arguments lol I figured they have to be very similar and I don't want the colors to be 'off', if you know what I mean.

I've worked with stills way more than I have with video and due to the work (and time) involved with video editing, I would rather do it right the first time without any ill effects introduced by my limited knowledge.

Sanlyn has went into great detail. He has helped me a lot and I'm very thankful for him taking the time to help.

I see what you are saying Lordsmurf and I get it. I won't worry as much as long as people don't come out turning green lol Thank you, you color space explanation actually made some stuff 'click', if you know what I mean.

After encoding a sample video, I wanted to clean up the edges some more because it just looked weird with the rough black edges. I prefer the cleaner edge look that Vdub gives after I use the resize filter to crop and mask.
Reply With Quote
  #12  
09-10-2017, 03:16 PM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 6,178
Thanks: 573
Thanked 899 Times in 807 Posts
I wanted to reiterate that
Code:
ConvertToYUY2(interlaced=true)
ConvertToYV12(interlaced=true)
ConvertToRGB32(interlaced=true,matrix="Rec601")
are extremely important in your Avisynth scripting, as sanlyn pointed out.
If you convert the colorspace without specifying interlace, you'll ruin the video.

- Did my advice help you? Then become a Premium Member and support this site.
- Find television shows, cartoons, DVDs and Blu-ray releases at the TVPast forums.
Reply With Quote
The following users thank lordsmurf for this useful post: davidi (09-10-2017)
  #13  
09-10-2017, 11:24 PM
davidi davidi is offline
Free Member
 
Join Date: Sep 2017
Posts: 7
Thanks: 5
Thanked 0 Times in 0 Posts
I will make note of that. I honestly figured that trying to deinterlace would not be good. That is better left to the TV or player to handle.

At any rate, I want to thank you two again for the help. I attached a frame from a cleaned up video that I worked on based mainly off of the information from this thread. To me, it looks good! Way better than the image I posted earlier in this thread

I have a few more or Digital8 tapes to transfer and play with. Next, VHS tapes! lol I honestly might just contact your company to see how much it would cost for your services to do those. Anyway, that's a separate topic. I don't want to change the topic here.


Attached Images
File Type: png final.png (426.8 KB, 1 downloads)
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Color space problem when capturing M-JPEG YUY2 hysteriah Capture, Record, Transfer 22 02-20-2015 04:17 PM
Preserving 120 years of U.S. cultural history DeeSeven General Discussion 4 07-18-2014 07:49 PM
Color calibrating your monitor? (Seeing "true" color of your video captures) baywatch242000 Project Planning, Workflows 4 04-09-2014 01:30 PM
Converting to AVI: best option for preserving sound quality? Reading Bug Digital Devices 6 01-14-2011 03:04 PM
DV color space harmful to analog color quality? Verify? DeXeSs Capture, Record, Transfer 6 06-27-2010 01:48 AM

Thread Tools



 
All times are GMT -5. The time now is 09:37 PM  —  vBulletin Copyright © Jelsoft Enterprises Ltd