Lagarith to H264 colors change

Marton wrote on 6/5/2013, 4:00 AM
Hello,

Because internal mpeg4 encoders are not so good in Vegas,
i like to use Handbrake, its a lot faster, and produce much sharper videos at the same bitrate with less artifacts!

But unfortunately Handbrake doesn't support frameserved avi file.
It even cannot read Canopus HQX files. So i choose the lossless Lagarith codec.
I tried different settings: when using YV12 mode, colors are slightly changed (greens to yellows), and i don't like this.
If i use RGB mode, colors remains, but again: Handbrake cannot import the file!

Why? Or how can i preserve the colors in YV12 mode?

thanks in advance

Comments

musicvid10 wrote on 6/5/2013, 8:33 AM
Do you mean the colors are shifted in the Lagarith render from Vegas?
Or in the Handbrake encode from Lagarith?
What is your source on the timeline?

Can you post examples using the Belle Nuit HD chart?
Also the MediaInfo properties of your Lagarith YV12?
Honestly, I didn't think Handbrake accepted anything Lagarith.
Marton wrote on 6/5/2013, 8:44 AM
Yes, Handbrake accept lagarith as long as it's in YV12 format. RGB seems not supported.

But the YV12 lagarith AVI imported back to Vegas is yellower than the original, if i switch between them.
And after the x264 conversion with handbrake there is the levels/gamma issue too :(
Now i made a solution: i place two track fx in Vegas, before exporting to lagarith: levels input start 0.05, so blacks will be blacks in mp4 file, and a secondary CC with rotate hue parameter around 8.
Seems a lot better, than without it.
I know this is not a good solution, just i need a quick, acceptable result. Still search the best method.
In fact i tried DNXHD codec, but i like to export 1280x1440 3D top/bottom full file at 50p, and in dnxhd preset i only found 720p or 1080i/p setting. I can set the resolution manually to 1280x1440, but
handbrake sometimes interpret it as 1920x1080, and the final file has strange alias artifacts.

thanks
musicvid10 wrote on 6/5/2013, 9:25 AM
Right. DNxHD, as a Quicktime wrapper, doesn't like nonstandard file dimensions or anamorphic.

What's going on is a conversion from RGB in the Vegas preview to YV12 in Lagarith to generic YUV in Handbrake ("should" be no change), and finally back to RGB when you bring it back into Vegas' preview. It may be that the shift is happening in the final step rather than in Handbrake. I'll investigate time permitting, since I have all these codecs on my machine.

In the meantime, have you cross-compared the results with UT and Huffy? Both have similar color modes (YUY2).

Also, some tests I ran on lossless codecs sometime back may be of interest, although I see I only tested the three in RGB mode.
http://www.sonycreativesoftware.com/forums/ShowMessage.asp?ForumID=4&MessageID=771326

Now that I know it accepts it, Handbrake should behave the same with Lag YV12 as DNxHD, which uses an almost identical color space.
The levels section in our should apply, with the added advantage of scopes in Vegas Pro.
musicvid10 wrote on 6/8/2013, 5:39 PM
Here is what I think is happening with your Lagarith YV12 files.
Handbrake thinks they are RGB levels and primaries instead of Y'CbCr.
So it's converting both for output, when it shouldn't be doing either.
You can see the huge shift in the Y/G/C axis, but not so much in R/M/B.
Unfortunately, there is nothing you can tell Handbrake that will prevent this.
Only thing you could do is try UT or Huffy with YUY2/YV12. I know they both work with Handbrake as RGB.

Other great codecs for Handbrake are DNxHD and Sony YUV.





Marton wrote on 6/9/2013, 1:39 AM
Exactly what i saw.
My greens are gone, or was yellow :(
So you say i can use UT codec, and handbrake handle it correctly?

big thanks!
musicvid10 wrote on 6/9/2013, 3:48 AM
I have tested UT RGB in Handbrake. Needs 0-255 levels, not 16-235.
I have not tested UT YUV.
pcunite wrote on 9/24/2014, 3:31 PM
I have this same problem (gamma way off). In order to use Handbrake to shrink a video rendered from Sony Vegas 11, I use the "Video for Windows (*.avi)" template and then choose the Sony YUV Codec. I've tried every setting for Lagarith and it does not work. Looks like a contrast issue on my system.

* Project / Render as / Video for Windows / any / Customize Template
Frame Size: Custom (match the video)
Frame Rate: match the video
Video Format: Sony YUV Codec
Interleave (uncheck)
Create an OpenDML (check!)

Note that there is such a thing as "computer SRGB 0-255" while h.264 is "Studio SRGB 16-235". I think this is what is causing this issue.
musicvid10 wrote on 9/24/2014, 3:53 PM
The problems with lagarith and libav in handbrake are now well documented, unlike when this thread began. Don't use it.

RGB is always converted to proper YUV color space in Handbrake, as it should be.

The Vegas Preview displays RGB, not mapped YUV levels, so that is not how the video will play.

SRGB is an ICC Profile, unrelated to video color space.

Hope that clears it up for you.
pcunite wrote on 9/24/2014, 5:18 PM
>> The problems with lagarith and libav in handbrake
>> are now well documented, unlike when this thread began.
>> Don't use it.

Okay, sorry about that. I've been away for awhile. Are you saying to *not* use lagarith? I'm not because I can't get it to work. Also can you point to some info on this subject? Thank you.
musicvid10 wrote on 9/24/2014, 7:10 PM
There have been threads on the Handbrake forum, maybe libav bugreports about lagarith being buggy. Don't belabor the point, it doesn't work, just like a lot of things.

I have tested UT in Handbrake. If you truly want compressed AVI RGB, use that instead That said, many of us are using DNxHD, Sony MXF, XDCAM, etc.
Search these forums, and best of luck. There are literally thousands of posts on the subject.
John_Cline wrote on 9/24/2014, 9:13 PM
I find the UTvideo codec works great as an intermediate between Vegas and Handbrake, I use it all the time.
musicvid10 wrote on 9/24/2014, 9:59 PM
Agreed.
If it wasn't for the file size, I would use it more often.
wwaag wrote on 9/24/2014, 10:17 PM
But unfortunately Handbrake doesn't support frameserved avi file.

It now does thanks to a script written by Marco. See this thread. http://www.sonycreativesoftware.com/forums/ShowMessage.asp?ForumID=4&MessageID=905597

It works very well. Its a big time saver over rendering to an intermediate. Try it.

wwaag

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

musicvid10 wrote on 9/24/2014, 10:28 PM
Here are some render time vs. file size comparisons I ran about three years ago (on a dual core)..



pcunite wrote on 9/24/2014, 10:47 PM
Using the UT code does not fix my issues. Why does only Sony YUV codec prevent the gamma (slightly washed out gray overlay) issue from appearing after using Handbrake? A solid black image was very slightly grayed. What is causing this?

Note, I'm using the Sony Levels "Computer RGB to Studio RGB" preset so that Windows Media Player and VideoLan show the video with the same saturation levels. Turning this off helps, but then the sats look different. What is special about Sony YUV and "Computer RGB to Studio RGB"?
musicvid10 wrote on 9/24/2014, 10:55 PM
I really tried hard to explain this eight posts up.
These AVI codecs are RGB. Expect 0-255.
The h264 output isYUV. Expect 16-235.
Handbrake does the conversion correctly.
Player levels will be the same, by definition, barring unwanted downstream influences (below).
Vegas preview levels will not be the same, because they are RGB.
If you give Handbrake YUV levels, it will output YUV levels. Maybe that's what you should be doing if the normal conversion bothers you.
I have personally run hundreds of hours of tests on a level playing field.

Decoder flags, graphics settings, etc. may affect your results because they are downstream influences.
pcunite wrote on 9/24/2014, 11:03 PM
musicvid10,
Sorry if I seem difficult. I just want to know what to do. :-)

Workflow #1
1. MOV file from a Canon T2i. I think this is (h264 23.976 4:2:0 YUV)
2. Drop into Sony Vegas 11, do some color, edit, etc.
3. Output to something sensible (what?). Then load into Handbrake to shrink.

Workflow #2
1. AVI file from a screen capture program utilizing lagarith codec.
2. Drop into Sony Vegas 11, do some color, edit, etc.
3. Output to something sensible (what?). Then load into Handbrake to shrink.

I've found that to force Windows Media Player and VideoLan to look the "same" I had to add a Sony Levels "Computer RGB to Studio RGB". Another option to make VLC display 16-235 content correctly is to go to "Tools / Preferences / Video" and uncheck "Use hardware YUV-RGB" conversions. But I can't make my customers do that.
musicvid10 wrote on 9/24/2014, 11:14 PM
One documented answer to #1 and #2 uses DNxHD at REC 709 (YUV) levels:


Another approach developed by Nick uses frameserving to MeGUI/Avisynth.

Another approach refined by Laurence uses mpeg-2 in MXF or XDCAM.

Another newer approach by Marco uses a modified frameserver method.

Search.

Yes, you must use the Computer->Studio RGB filter in Vegas to convert RGB luminance to YUV luminance. It does not do it for you!

Always use the Vegas scopes to check for "correct and desired" RGB or YUV levels. Your Canon is capable of full range.

Question #2 does not provide enough information. Is your screen capture Lagarith RGB or Lagarith YUY2/YV12?
pcunite wrote on 9/24/2014, 11:26 PM
>> Is your screen capture Lagarith RGB or Lagarith YUY2/YV12?
Lagarith RGB

Okay ... I'm starting to get what you're saying. Handbrake *always* outputs to the YUV (16-235) color range? Some of the time I've accidently been working in RGB (0-255).

What started all this was how WMP and VLC show saturation very differently. I've found that applying the Levels "Computer RGB to Studio RGB" preset made them very similar. However, what you're saying is that perhaps is was more the codec I used to render BEFORE going into Handbrake?

What is your suggestion for a good workflow? I need to use Sony Vegas to edit the color. Since I know my output will eventually be 16-235 I should still keep using the "Computer RGB to Studio RGB" preset. What then should the codec be (the one that gets read by Handbrake)?

It seems you're saying use a YUV one?
musicvid10 wrote on 9/24/2014, 11:28 PM
"Handbrake *always* outputs to the YUV (16-235) color range?"

No, Handbrake assumes the correct input range and header flags for the type of codec that was used. Given that, the x264 output will be correct for normal playback. Otherwise, it's

GIGO

musicvid10 wrote on 9/24/2014, 11:38 PM
"What is your suggestion for a good workflow?"

Four excellent, refined workflows have already been suggested. Study up (they are all abundantly documented), get your hands dirty, and go with what feels best to you.
That's how the rest of us learned.