Log in

View Full Version : Darkened videos


MMrrTT
11th January 2013, 21:42
Hello.

I record videos with PlayClaw and Mirillis Action. Action uses it's own codec FICV and PlayClaw uses Intel MJPEG codec. The problem is that videos recorded by PlayClaw are much darker than ones recorded by Action or Fraps. I've talked with developer asking his if he uses 16-235 dynamic range and he ensured me that the options are set to full dynamic range.
In MPC there's output option which allows to change output from 0-255 to 16-235 which makes the videos a little lighter but still not the same as it should be.

MPC 16-235 http://clip2net.com/clip/m70200/1357934485-clip-422kb.jpg

MPC 0-255 http://clip2net.com/clip/m70200/1357934470-clip-385kb.jpg

Normal http://clip2net.com/clip/m70200/1357934459-clip-410kb.jpg

I could give up and change MPC settings to 16-235 output but there're two problems:
1. other videos become overlighted
2. youtube still makes the videos darker

There's some more - not all encoders make darker videos. For example, MeGUI makes them darker, and VirtualDub (if I'm not mistaked) - not. Then I think it's the question of decoder the software uses. Still if YouTube uses the decoder which makes videos darker there's no way to fix it except converting them with proper software. x264 CLI encodes the videos as darkened.

Actually I don't know if there's any dynamic range difference between these 2 videos or any other settings which could help me to prove developer to pay more attention and change the way PlayClaw encodes in MJPEG. Does anybody know the cause of such darkening and who can fix it - me by choosing the right software or developer by changing MJPEG codec settings? Would appreciate any comments on this topic.

Here are my samples.
Action video (https://www.youtube.com/watch?&v=24rSOccw9io) + Action original (https://www.dropbox.com/s/jq7lodq47xl92u5/trine2_action.avi)
PlayClaw video (https://www.youtube.com/watch?v=yOJguYBIOmw) + PlayClaw original (https://www.dropbox.com/s/wnzzx043xwn5wmi/trine2_32bit-muxed.avi)

hello_hello
12th January 2013, 09:46
I know nothing about recording video games but logically it's mainly a levels difference, and looking at your MPC 16-235 pic it could also be a colorimetry difference. It's a bit hard to tell given the screenshots aren't exactly the same.
It sounds not so much like the encoders are darkening the video as such (they'd just encode it "as is") but it's recorded using PC (0-255) levels originally and the levels aren't being converted to TV levels when you re-encode it, so the encoded version is played back under the assumption it uses TV (16-235) levels as pretty much all video does. The player expands the video it assumes is TV levels to PCs levels for display on a PC monitor but as it's already using PC levels it looks too dark. I guess it's something along those lines.

The second capture program probably converts the video to TV levels as it records it, and when that video is re-encoded it's still re-encoded without changing the levels but the assumption on playback that the encoded version uses TV levels is correct.

Then there's the method used for converting the colors when capturing/encoding which can also be different on playback. If the wrong combination is used the colors can look a little "off". Reds get darker while greens and blues get brighter.... or the other way around. There's mainly two methods used for converting the colors to RGB on playback. BT.709 for HD and BT.601 for SD. As a rule of thumb, 1024x576 resolutions or less (PAL DVD display dimensions) should be converted to RGB on playback by a PC using BT.601, and resolutions from roughly there onwards should use R.709. There's a bit of a grey area between 480p and 720p though, so for "inbetween" resolutions there's no guarantee which a player will use.
The upshot of all that is if you encode the original HD video at 720p or up, then encode it a second time at 480p, the two encodes won't display using the same colorimetry on playback. For whichever one is wrong, you'll need to convert the colors.

So for the one you're having problems with it being too dark after encoding, stick this at the end of your MeGUI script:

ColorYUV(Levels="PC->TV")

If "colour correction" is enabled in MeGUI's script creator disable it to see if that fixes any remaining colour issues. It uses the colormatrix AviSynth plugin for automatically correcting the colours when converting DVDs, but it's never actually necessary and I think it could "correct" the colours when it shouldn't under some circumstances. Always leave "colour correction" disabled in the script creator. Hopefully it'll be removed one day. Chances are though it's not the problem and you'll have to try converting the colours manually.
You'll need to change the path according where it's installed on your PC, but you'd add something like this to the end of your script:

LoadPlugin("C:\Program Files\MeGUI\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(mode="Rec.709->Rec.601", clamp=0)

Or if that makes it worse, do it the other way around:

LoadPlugin("C:\Program Files\MeGUI\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(mode="Rec.601->Rec.709", clamp=0)

When converting "normal" HD video to SD, the first method should always be used. (Not so long ago I suggested to the MeGUI developer he include a HD to SD check box in the script creator which will add it automatically. Maybe one day soon.....)
The colormatrix plugin as I've described above should only be used on progressive video. If it's interlaced, the de-interlacing in the script needs to be before it. It has a mode for interlaced video which you can find here (http://avisynth.org.ru/docs/english/externalfilters/colormatrix.htm).

If the source video isn't YV12 and MeGUI decides it needs to add "ConvertToYV12() (http://avisynth.org/mediawiki/ConvertToYV12)" to the script when you add the encoding job to the job queue (I don't think it will though) you might need to add ConvertToYV12() to the script yourself instead, before adding the levels and color conversion, but hopefully you won't have to worry about that.

Anyway.... I think for the dark encodes adding the PC to TV levels conversion to the script, followed by colorimetry conversion in one direction or the other if need be will fix it.

PS. I think x264 cli can fix the levels when encoding if you tell it what the input level is and the output level you want. You can probably tell it which colorimetry to use under some circumstances (depending on the type of source video) but I can't remember details. The x264 settings wiki (http://mewiki.project357.com/wiki/X264_Settings) should have more info.

MMrrTT
12th January 2013, 13:28
This means I'm thinking in competely wrong direction. I thought PlayClaw records at 16-235 and I see it dark, but it turns out the program records at 0-255 and I see it darker. If I understood right PlayClaw must record at 16-255 to be normal on YouTube and my MPC?

Action uses 0-255 for sure - there's a speacial option in it (http://clip2net.com/clip/m70200/1357992638-clip-59kb.jpg). But still its videos are good. That is what confused me.

With ColorYUV(Levels="PC->TV") the picture became a little out of colors (MeGUI (http://clip2net.com/clip/m70200/1357993196-clip-256kb.jpg) + Original (http://clip2net.com/clip/m70200/1357993226-clip-225kb.jpg)). I can't use or disable Colour Correction as I use .avi source.

Yes, my videos are not YUV12 and MeGUI add every time convertion lite by itself. Thank you. Now I'll test the given options.

I will try with x264 wiki after that.

UPD1: That was very strange. I've just managed to encode with ColorMatrix(mode="Rec.601->Rec.709", clamp=0) and ColorMatrix(mode="Rec.709->Rec.601", clamp=0) settings and now it shows an error (http://clip2net.com/clip/m70200/1357994439-clip-25kb.png).
Here's a video with ColorYUV(Levels="PC->TV") (http://youtu.be/beso_RYdvZ8) setting. Before I've tried ConvertToYV12(matrix="Rec709") but it was not very successful.

UPD2: I've encoded in x264 CLI and I think I found the solution. I tried 4 variats and one worked fine.
--input-range PC (http://youtu.be/CD0JTKbNb_Y)
--input-range TV (http://youtu.be/S8qO248bsl0)
--input-range PC --range TV (http://youtu.be/-UFLO4fPcfI)
--input-range TV --range PC (http://youtu.be/MJQi54nBqV8)

I've just added --input-range PC --range TV and it was converted ideally as I can see. hello_hello, thank you very much, you're the only one who told me the problem is inversed! :)

hello_hello
12th January 2013, 21:00
This means I'm thinking in competely wrong direction. I thought PlayClaw records at 16-235 and I see it dark, but it turns out the program records at 0-255 and I see it darker. If I understood right PlayClaw must record at 16-255 to be normal on YouTube and my MPC?

Yeah it can take a little bit to get your head around it but if you think of it in terms of black.... "16" is black for TV levels, "0" is black for PC levels. So when playing video on a PC monitor using it's original TV levels, "16" which should be black is displayed by the monitor as dark grey unless the levels are expanded.
In your case the original PC video probably used PC levels ("0" = black) and was encoded that way, while on playback the player assumes for the video "16" would be black and expands the levels so "16" becomes "0", but so does everything below "16". The video ends up with dark greys also displaying as black and the end result is video that's too dark.

Action uses 0-255 for sure - there's a speacial option in it (http://clip2net.com/clip/m70200/1357992638-clip-59kb.jpg). But still its videos are good. That is what confused me.

The option seems to be to specify the input level and I'd assume it aims to always output TV levels, so if you tell it 0-255 is going in, it'll convert to 16-235. If you tell it the input is already 16-235 it'll leave the levels alone. At least that's what I assume happens.
Pretty much all video uses 16-235 so regardless of the source it should be encoded that way. I doubt it's any different for YouTube.
The 0-255 setting in MPC-HC (if it's the one under renderer settings in the right click menu) converts the TV levels of video to the PC levels the monitor expects. Hence without it video looks washed out. It only works when using the EVR renderer (I think). Other players/renderers may or may not expand the levels..... but most video cards have a setting in their control panel for video levels where you can tell the video card to expand the levels (just for video). Nvidia describe it as ignoring the player settings and letting the video card decide. I use the video card to do it as then the levels are expanded regardless of the player. It shouldn't matter if the player is also set to output PC levels, they shouldn't be expanded twice.

Yes, my videos are not YUV12 and MeGUI add every time convertion lite by itself. Thank you. Now I'll test the given options.

YV12 is the colorspace used for most video and not related to PC vs TV levels (it can use either). MeGUI automatically adds the conversion to the script if the input video is something else and chances are that's the problem you're having converting the levels/colors in the script. If you manually add ConvertToYV12() to the script before the levels conversion and before colormatrix I think that'll fix your problem. The colormatrix plugin only supports YV12 & YUY2 colorspaces. If the input is something else such as RGB it won't work unless you convert the colorspace first.

I've just added --input-range PC --range TV and it was converted ideally as I can see. hello_hello, thank you very much, you're the only one who told me the problem is inversed! :)

I've always added it to the script myself but as long as it's now correct one way or another....... :)