Log in

View Full Version : MJPEG videos appear darker in VD


Killgore
29th December 2014, 18:18
Hello,

I have a little problem with MJPEG videos from my old Canon camera.

In VirtualDub they look noticeably darker than in most other players (I've attached two small samples).

E.g. in Windows Media Player and VLC they look brighter but in MPC-HC - exactly the same as in VirtualDub.
After compressing with Xvid or x264 (fast recompress) they look equally dark in all players.

I tried switching to internal decoder but result is the same.

Then I tried other programs: MediaCoder gave the same results, but XMedia Recode with Xvid codec gave video looking as in VLC. Since XMedia doesn't give me the same amount of control as VD I'd like to get similar results in VD.

MJPEG videos are (according to VLC) in Planar 4:2:2 YUV full scale.

I don't know what is the cause of this anomaly. In players I can change "darkness level" by changing output e.g. in VLC, when I change to OpenGL output video becomes darker (like in VD) and in MPC-HC after changing to madVR video is brighter.
And again: this applies only to my MJPEG avis. When I play any other files I don't see these differences.

On the other hand I've tried selecting different display modes on Display page in VD preferences and it hasn't changed output even one bit.

In MediaCoder changing source to FFmpeg from default MEncoder resulted in brighter ouput, but video became much more pixelated.

It seems to be somehow related to color scale conversion, but i don't know how to fix it.

All programs in their latest versions.

wonkey_monkey
29th December 2014, 18:52
If my memory serves me correctly, this is a bug in some MJPEG codecs. VirtualDub requests RGB from its codecs, unlike most other players, and the codec uses the wrong matrix (TV range instead of PC range, or the other way around, I can never remember which!)

If you don't need to use any VD filters, try setting VD to "Fast recompress" under the Video menu before encoding.

There's also an option to "Prefer internal video decoders over installed third-party codecs (MJPEG and DV)" in Preferences which might work.

Failing that, you could use an Avisynth script to load the AVI (if it is an AVI) and use converttorgb24 with whichever is the correct matrix.

David

Killgore
30th December 2014, 11:34
@davidhorman
As mentioned in my first post I've already tried first two suggestions.
As to AVS, I'll try that and report back results.

Asmodian
30th December 2014, 21:58
MJPEG videos are (according to VLC) in Planar 4:2:2 YUV full scale.

Most video is YUV limited scale so a lot of decoders do not expect full range video and AVI has no in-spec way to identify full-range video.

Using Avisynth 2.6 a simple:
ConvertToRGB24(matrix="PC.601") (http://avisynth.nl/index.php/Convert) should work or ConvertToRGB24(matrix="PC.709") if it is HD.

wonkey_monkey
30th December 2014, 23:47
On further reflection, I think my solution was to do AviSource("source.avi",pixel_type="rgb32")That may have been before I understood about matrixes, and doing that presumably leaves the matrix up to the codec, which may not get it right.

Killgore
8th January 2015, 22:08
Hello,

finally, I've managed to resolve my problem.
First, thank you all for suggestions as they helped me in picking the right direction.

AviSource("file.avi")
ConvertToRGB24(matrix="PC.601")

Above script worked (gave brighter image).
So, I've tried:

DirectShowSource("file.avi")

It also worked (as you see without "convert" command).

So, I could use those scripts, but it would be unwieldy, as I would have to make such script for each converted file.

And I thought: what is the difference between avisource (or VD or MPC-HC) and directshowsource (or VLC or MediaPlayer)?
Different codecs with different settings.

Through a lot of trial and error I've found that if I force MPC-HC to use ffdshow instead of default LAV, and set Output -> RGB Conversion -> Input levels to Auto (from default Standard which is in limited color range) video in MPC-HC looks good.

So, using Codec Tweak Tool -> VFW Codecs -> ffdshow VFW interface -> Decoder -> Codecs I chose libavcodec for MJPEG and chage Input levels as above.

Now VD uses ffdshow for decoding and full range in MJPEG when necessary.