VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. Hi,
    I am wondering if it is possible to convert raw mjpg video file to a compressed form without the video losing color? I tried h264/AAC, Theora and flash video codecs, but every one of them produce the same washed out/tarnished colors when used...
    can someone please recommend some solution or a computer software? I just want the compressed media to be playable on computer. I am currently using Xmedia recode for conversion...
    thanks for any help in advance
    Quote Quote  
  2. Member Krispy Kritter's Avatar
    Join Date
    Jul 2003
    Location
    St Louis, MO USA
    Search Comp PM
    post the file specs using a tool like mediainfo
    Google is your Friend
    Quote Quote  
  3. I also had that same problem after encoding a x264 movie to mpeg4

    the colors was turned into a bluey shade and it changes every 5-10 minutes
    Quote Quote  
  4. mjpg normally uses full range luminance levels (0-255). most "normal" video (ie mpeg) generally uses limited range luminance levels (16-235). PC monitors use full range levels so mpeg video would normally be "expanded" from 16-235 to 0-255 on playback (mjpg wouldn't need to be expanded). There's lots of places things can go wrong in respect to the levels and to be sure where it's going wrong you need to ensure you're always viewing the video with the correct levels. ie ensuring the "washed out" look isn't happening during playback rather than during encoding. It's possible you're generally viewing video using the wrong levels on your PC but the source and encoded version look the same because the levels normally aren't converted when encoding and the same levels are used on playback. In the case of re-encoding mjpg, you might be able to see a difference you normally don't because it's one time you're viewing the source (mjpg) with the correct levels.

    I've not used XMediaRecode but if you post a small sample of the original video, I (or someone) could try using XMediaRecode to convert it and let you know if it's converting the levels as it probably should. There's also a possibility your mjpg files don't use full range levels as they normally would, and XMediaRecode is converting the levels as it probably should, but if that's the case you'd need to tell it not to if you can.......

    Step one might be to find a "normal" video with black borders (ie a video on DVD with letterboxing). Are the black borders black or dark grey? If it's the latter, you need to fix the playback levels. What player are you using? Try viewing the encoded video using something other than your PC, such as a Bluray player or standalone player. They'd normally expect limited range levels so you might find the encoded version doesn't look washed out on your TV as it does when viewing it on a PC monitor.

    Here's a quick example of the difference you might see when the levels are wrong. The first pic is correct and the second one is "washed out". It might be a playback rather than an encoding problem though, and if that's not the sort of difference you're seeing, maybe I'm on the wrong track.....

    Name:  1.jpg
Views: 18886
Size:  8.2 KB

    Name:  2.jpg
Views: 12669
Size:  7.6 KB

    For MPC-HC you should be able to ensure correct playback levels for most video by going into it's options and changing the renderer to Enhanced Video Renderer (custom presenter) under "Playback/Output". Restart the player and the levels should then be correct, but you can check under the menu: "View/Renderer Settings/Output Range" and ensure the "0-255" option is checked. If the options there are greyed out, you're probably using the wrong renderer (and the levels could be wrong). That should ensure MPC-HC is displaying your encoded video with the correct levels for a PC monitor. Hopefully the mjpg video will look the same.
    Last edited by hello_hello; 27th Dec 2014 at 01:38.
    Quote Quote  
  5. Thank you hello_hello for your most detailed explanation! The difference between the two screenshots you provided was EXACTLY how I meant the colors were "washed out". I went through the many options XMediaRecode provided for video conversion with the H.264 codec, but have found nothing like "luminance levels". Could you please suggest a converter that has the mentioned feature? Also, my MPC-HC settings are exactly how you wrote they should have been, so I guess the problem is not there...

    Thank you for your reply, again
    Quote Quote  
  6. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    You might want to take a look at the lut filters in ffmpeg. With those you can control how the RGB (0..255) to YUV (16..235) conversion is performed. Cannot give you exact, working values but it might be your fix.

    https://www.ffmpeg.org/ffmpeg-filters.html#lut_002c-lutrgb_002c-lutyuv

    With my GUI for ffmpeg you can easaly add filters to adjustment Color balance and Hue/Saturation/Brighness - this could also be your fix. The lut filters are not directly supported in FFQueue yet but you can use them as a custom filter.
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  7. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Originally Posted by hello_hello View Post
    Here's a quick example of the difference you might see when the levels are wrong. The first pic is correct and the second one is "washed out". It might be a playback rather than an encoding problem though, and if that's not the sort of difference you're seeing, maybe I'm on the wrong track.....

    Image
    [Attachment 29278 - Click to enlarge]


    Image
    [Attachment 29279 - Click to enlarge]

    I realize that you use those pictures to demonstrate the difference but I don't think the second one looks much worse than the first one. While the second one's blacks are brutally capped the first one is simply too dark.

    Think about it, inside a home at daytime, when does the back of a shirt looks almost pitch-black?
    Quote Quote  
  8. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    Well...no, the two pics don't look all that different, the difference being mostly in the darks and brights. Actually the back of the shirt doesn't look "almost pitch black" in either pic. Looks darkish blue in both. In the darker picture the average RGB values on back of the jacket are from 12 to 16, with elevated blue. In the lighter pic on the bottom the average values are twice as bright at average RGB 24 to 32 or so (So, yeah, the darks are cut short a bit in the lower pic, and so are the brights). At full size in a running video you'd certainly see more of a difference.

    IMO
    - My sister Ann's brother
    Quote Quote  
  9. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Originally Posted by LMotlow View Post
    Well...no, the two pics don't look all that different, the difference being mostly in the darks and brights. Actually the back of the shirt doesn't look "almost pitch black" in either pic. Looks darkish blue in both. In the darker picture the average RGB values on back of the jacket are from 12 to 16, with elevated blue. In the lighter pic on the bottom the average values are twice as bright at average RGB 24 to 32 or so (So, yeah, the darks are cut short a bit in the lower pic, and so are the brights). At full size in a running video you'd certainly see more of a difference.

    IMO
    The brights are not cut, there aren't many brights in the first place to be cut.

    Do a threshold at 128 and you will see that there are only a few spots over 128.
    Quote Quote  
  10. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    The older guy's bright hair highlights are ~15 RGB points brighter than in the lower pic. The upper pic also has a wider contrast range. Flipped back and forth in Photoshop layers, used pixel samplers, etc., that's what I'm getting. Remember also that the pics are converted YUV-RGB.
    - My sister Ann's brother
    Quote Quote  
  11. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Originally Posted by LMotlow View Post
    TThe upper pic also has a wider contrast range.
    Both pictures are too dark, there are hardly midtones let alone highlights.

    Probably needed gamma correction, something like this (and yes that should have been done before encoding as now can see many more artifacts):

    Name:  img2.png
Views: 6343
Size:  29.4 KB

    Original:
    Originally Posted by hello_hello View Post
    Last edited by newpball; 15th Jan 2015 at 12:01.
    Quote Quote  
  12. Regardless of what people think it should "look" like, hello_hello is basically correct in terms of ffmpeg and mjpeg handling. mjpeg is stored 0-255 YUV. Some decoders clamp the output, some clip the output, some convert to RGB and produce RGB output.

    For ffmpeg, mjpeg is decoded at full range YUV 0-255 (aka "yuvj420p", not "yuv420p", the "j" designating full range) . Most "video" formats will use normal range YUV. So you have to clamp the YUV output to 16-235 to have it look normal on most setups. It's the safest thing to do.

    Unfortuantely, for all the gazillion filters and switches that ffmpeg has - it doesn't even have a basic levels filter!

    To do this in ffmpeg you currently need to use the -vf scale filter , specifying the input and output range

    e.g

    Code:
    ffmpeg -i INPUT.ext -pix_fmt yuv420p -vf scale=w=-1:h=-1:in_range=pc:out_range=tv -c:v libx264 -c:a copy OUTPUT.mp4

    The critical switches are

    -pix_fmt yuv420p , sets destination format in normal range
    -vf scale . The "-1" for height and width, mean copy the source height & width . The in and out range signify the PC to TV conversion
    Quote Quote  
  13. Member
    Join Date
    Jul 2014
    Location
    Denmark
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Code:
    ffmpeg -i INPUT.ext -pix_fmt yuv420p -vf scale=w=-1:h=-1:in_range=pc:out_range=tv -c:v libx264 -c:a copy OUTPUT.mp4
    This is a beautifull example of KISS (Keep It Simple, Stupid) in effect! This was very educational, now I know a filter-implementation in ffq to upgrade - thanks
    I'm the developer behind FFQueue. My posts might reflect this! ;-)
    Quote Quote  
  14. Originally Posted by newpball View Post
    Originally Posted by hello_hello View Post
    Here's a quick example of the difference you might see when the levels are wrong. The first pic is correct and the second one is "washed out". It might be a playback rather than an encoding problem though, and if that's not the sort of difference you're seeing, maybe I'm on the wrong track.....

    Image
    [Attachment 29278 - Click to enlarge]


    Image
    [Attachment 29279 - Click to enlarge]

    I realize that you use those pictures to demonstrate the difference but I don't think the second one looks much worse than the first one. While the second one's blacks are brutally capped the first one is simply too dark.

    Think about it, inside a home at daytime, when does the back of a shirt looks almost pitch-black?
    I just opened an AVI DVD re-encode I had handy (very likely AutoGK), but I didn't touch the levels when encoding. The second pic is the same frame converted back to TV range with a MPC-HC pixel shader. Either that or I disabled the video card's expansion of the levels while MPC-HC saved pic 2. I can't remember. Same result either way (for the purpose of the exercise). The difference is definitely PC and TV levels. The alternative would be for pic 2 to be correct, even though it looks washed out to me, but if it's correct it'd mean a PC to TV levels conversion would result in a very over-the-top washed out image.

    To be honest I don't think the first pic looks too dark. I'm just using my CRT at the moment but compared to "black" the shirt's many shades of grey away. I opened the second pic with Irfanview and had a quick look with it resized fullscreen. I'm not seeing any crushed blacks. I'm seeing Xvid blocking, but I think that's all it is. It's been resized down and back a couple of times now but I'm pretty sure the flat areas are courtesy of Xvid.

    For the record, it's from StarGate SG1. They're in a bunker inside a mountain.
    Quote Quote  
  15. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Originally Posted by hello_hello View Post
    For the record, it's from StarGate SG1. They're in a bunker inside a mountain.
    Good point, context matters!
    Last edited by newpball; 15th Jan 2015 at 16:20.
    Quote Quote  
  16. Originally Posted by LMotlow View Post
    Well...no, the two pics don't look all that different, the difference being mostly in the darks and brights. Actually the back of the shirt doesn't look "almost pitch black" in either pic. Looks darkish blue in both. In the darker picture the average RGB values on back of the jacket are from 12 to 16, with elevated blue. In the lighter pic on the bottom the average values are twice as bright at average RGB 24 to 32 or so (So, yeah, the darks are cut short a bit in the lower pic, and so are the brights). At full size in a running video you'd certainly see more of a difference.
    Now I'm a bit confused.....
    Don't forget the first pic is the original video with expanded levels to display correctly on a PC monitor. So it'll display correctly as a jpg. It should be PC levels, yes? If nothing in the first pic is black and the lowest value is 12, doesn't that make sense, given 0 is now black and it's now full range?

    I checked and pic 2 must have been saved by disabling the video card's expansion of the levels. Converting with a pixel shader had no effect on the image MPC-HC saved. MPC-HC obviously doesn't expand the levels when saving images. If it's washed out on the monitor, the saved image looks the same.

    So..... pic one is displaying with the same levels as the video on the monitor. The levels have been expanded by the video card.
    jpg = fullrange levels. The jpg displays with correct levels. Pic one is how it should look, artistic and video production criticisms aside.
    Pic two, no levels expansion, original limited range levels, jpg = full range levels, jpg looks washed out.

    Now that's finally sorted..... anything not to taste should be blamed on the accuracy of the video card's levels expansion, Xvid, resizing, jpg compression, Xvid, the entire film production crew and their immediate families, artistic choice, the DVD transfer process, not me, and possibly also Xvid.
    Quote Quote  
  17. Originally Posted by poisondeathray View Post
    Regardless of what people think it should "look" like, hello_hello is basically correct in terms of ffmpeg and mjpeg handling. mjpeg is stored 0-255 YUV. Some decoders clamp the output, some clip the output, some convert to RGB and produce RGB output.

    For ffmpeg, mjpeg is decoded at full range YUV 0-255 (aka "yuvj420p", not "yuv420p", the "j" designating full range) . Most "video" formats will use normal range YUV. So you have to clamp the YUV output to 16-235 to have it look normal on most setups. It's the safest thing to do.
    I think I'm having a stupid day.
    If the video is looking washed out, doesn't that mean it requires a TV to PC conversion, and if that's already happening correctly on playback, wouldn't that mean it requires the same conversion when encoding? The OP has a washed out encode, so isn't TV->PC the direction in which to convert to "unwash" it. ie make it darker? Unless the washed out version is technically correct, and we haven't ruled that out (no pics or samples provided yet). Or am I losing the plot?

    Anyway, I guess he's got to specify a conversion in one direction or the other. I can't think of a GUI off the top of my head that has a built-in levels conversion setting. Any suggestions for cnaeus if he needs a GUI?
    Quote Quote  
  18. Yes, you're right with that description hello_hello.

    Normally you see the opposite with mjpeg and ffmpeg (The typical mjpeg conversion will look blown as both ends are clipped upon display - because YUV is full range, yet gets converted to RGB for display using a "limited" range matrix).

    Some ffmpeg GUI's allow you to enter custom command entries. I think winff, tencoder , not sure ?
    Quote Quote  
  19. I suspect cnaeus's might be looking at the the wrong way, and the "washed out" version is correct. It's easy to become accustomed to video looking a particular way, and to fresh eyes the "unwashed" version might look over-saturated etc, but if you're used to it that way, the correct levels might look "washed out". If the encode is displaying correctly I assume it means the original video isn't (too dark) but I can't quite get my head around why that'd happen either. Unless the player is expanding the levels for the mjpg video when it shouldn't be. I don't know..... I'm easily confused. It'd be nice to see some screenshots or maybe a sample of the original video.
    Last edited by hello_hello; 16th Jan 2015 at 02:27.
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!