VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    All of the players I use (MPC-HC, VLC, and WMP) tend to render MeGUI 10-bit x264 encodes darker than the FRAPS avi originals. By setting the Output Range in MPC-HC to "16-235" I was able to get what seemed like a match. I did notice that the MeGUI encodes, even with very high bit rates, tended to look lighter than the originals in darker scenes. I assumed this was something that happened in the encoding process.

    However, I recently decided to try a lossless x264 encode, and I noticed this same lightness in dark scenes when viewing with MPC-HC. So obviously, if lossless x264 is truly lossless, the issue is with the decoding, not the encoding.

    What program or method can I use to visually compare my FRAPS and MeGui encodes without introducing this brightness issue? I would also like to use this program to take corresponding frame grabs from both videos, something I use the MPC-HC "Save Thumbnails" function for now.

    Any help will be greatly appreciated.

    Thanks.
    Quote Quote  
  2. Adjust your graphics card's video proc amp to get YUV video displaying the same as desktop RGB. YUV video is always converted to RGB for display. Most media players let the graphics card do that. The graphics card driver's default video proc amp settings are often wrong.

    Or you can use an AviSynth script to convert YUV to RGB, controlling exactly how it's done. I like to use a script like:

    Code:
    v1=AviSource("RGB.AVI") # assuming RGB here
    v2=ffMpegSource("h.264.mp4").ConvertToRGB(matrix="rec709")
    Interleave(v1,v2)
    I then open that script in VirtualDub. That way you can easily swab back and forth between frames of the two videos using the left/right arrow keys. Along with a screen magnifier (I use Window's built in magnifier) you can see minute differences.
    Last edited by jagabo; 1st Jun 2014 at 08:05.
    Quote Quote  
  3. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Thanks for the response.

    My FRAPS captures are actually YUV.

    I tried the script you posted, but I'm getting the error:

    script error: there is no function named "ffMpegSource"
    This is my first time working with AviSynth or ffMpeg. So I really have no idea what I need to do to fix this.

    Do you have any suggestions?

    Thanks
    Quote Quote  
  4. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Okay, I've gotten it to work partially. I switched to 32-bit VirtualDUB and I used "ffVideoSource" instead of "ffMpegSource"

    VirtualDUB now opens the script, but the lossless x264 image quality is nothing near what it should be.

    Click image for larger version

Name:	Test.jpg
Views:	214
Size:	737.2 KB
ID:	25507

    The result is the same whether I use Rec.709 or Rec.601.
    Quote Quote  
  5. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    You could try:

    Code:
    Subtract(V1, V2)
    If it's lossless you should just get a blank grey screen. If you see anything at all and it's definitely Lossless x264 then it must have been passed through some kind of filter between the FRAPs file and X264.

    -Edit- or it could be the FRAPS decoder.
    Quote Quote  
  6. Sorry, I wrote that script off the top of my head. I should have written ffmpegsource2() not ffmpegsource(). Or you can use ffvideosource(), like you eventually tried.

    Some issues you might run into using the ffmpeg source filter in AviSynth: Encoding sometimes results in a frame delay so you often have to align the two videos with a Trim(). Random seeking often delivers corrupt frames until you step forward to the next key frame. It's also not always frame accurate -- for example, randomly seeking to frame 1000 might sometimes return frame 999, or 1001, or some other frame.

    If you use Subtract() (pixel by pixel subtract) you're left with a medium grey image when the two images match. Any variation indicates a difference. You can apply a contrast stretch after Subtract() to make the difference more visible. Here's an example where two videos were compared with Subtract, showing the two videos, the result of subtract, and the contrast enhanced subtract:

    https://forum.videohelp.com/threads/319420-Who-uses-a-DVD-recorder-as-a-line-TBC-and-wh...=1#post1978665
    Quote Quote  
  7. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Thanks ndjamena and jagabo! I tried the Subtract method. The difference shown is what should be expected, given the quality of the screenshot I posted.

    jagabo, in your second paragraph, are you implying that one can avoid random seeking either by using trim, or by some other method? If so, how would I go about doing that?

    Also I've considered just re-encoding both videos with lossless codecs inside an AVI container. Is this something that could work, or would it just introduce more opportunity for filters to skew things?

    Thanks.
    Last edited by Pilotwings_64; 4th Jun 2014 at 00:49.
    Quote Quote  
  8. You can improve ffvideosource random seeking using seekmode=0. It will be slower, but more accurate

    You mentioned "YUV" for FRAPS, so you're using the using "regular" recording, not the lossless RGB FRAPS ?

    The decoder chosen will affect how it's being decoded. The FRAPS decoder e.g using AVISource() will convert to RGB, using standard range. Libav , FFMS2, will decode it as full range YUV, so the levels will look different unless you use a PC matrix somewhere in the chain for converting to RGB for display


    lossless x264 is truly lossless at the same bit depth and colorspace. Thus it's not lossless for you because you're using 10bit, and you're probably not encoding full range correctly, or decoding full range correctly . Most media players will not be set up to handle full range YUV, or obey full range flags
    Quote Quote  
  9. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Hi poisondeathray,

    I have a very vague understanding of what you're saying. I don't really have a clear idea of the entire encoding/decoding process, so it's hard to make sense out of it.

    I understand that lossless video will produce the exact same bitstream when decoded as the original when its decoded. So obviously some decoding has to take place before the lossless video can be encoded. However, this would seem to undermine the point of lossless video, or at least make an expert knowledge of video encoding necessary in order to produce a lossless video. Beyond that, I don't understand much about the basic pieces of the chain that takes the original source to a file and then from that file to my screen. I know some, but not nearly enough.

    Can you recommend any tools I can use to accomplish all of the things you mentioned in your post?

    Also, can you comment on my idea to encode both the FRAPS and the x264 videos into lossless AVIs using the same codec, so I don't have these decoding issues?

    Thanks
    Last edited by Pilotwings_64; 4th Jun 2014 at 06:06.
    Quote Quote  
  10. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Also, no, I don't use the lossless RGB option on FRAPS.
    Quote Quote  
  11. Originally Posted by Pilotwings_64 View Post
    jagabo, in your second paragraph, are you implying that one can avoid random seeking either by using trim, or by some other method? If so, how would I go about doing that?
    No. I meant you could use Trim() to align frame numbers if the two videos weren't synchronized. For example, if the encoded video has two extra frame at the start you could use Trim(2,0) to remove them. Poisondeathray's suggesting of using "seekmode=0" will help with random seeking (though it will be slower).

    Code:
    NamedVid = ffVideoSource("filename.ext", seekmode=0)
    Originally Posted by Pilotwings_64 View Post
    I understand that lossless video will produce the exact same bitstream when decoded as the original when its decoded. So obviously some decoding has to take place before the lossless video can be encoded. However, this would seem to undermine the point of lossless video, or at least make an expert knowledge of video encoding necessary in order to produce a lossless video.
    Yes, you need to understand what's going on to produce a truly lossless encoding. For example, if an decoder puts out RGB and you produce a "lossless" x264 encoding in YV12, the result will not be lossless relative to the original RGB. Some losses are caused by the RGB to YV12 conversion.

    Originally Posted by Pilotwings_64 View Post
    Beyond that, I don't understand much about the basic pieces of the chain that takes the original source to a file and then from that file to my screen. I know some, but not nearly enough.

    Can you recommend any tools I can use to accomplish all of the things you mentioned in your post?
    You can use Info() to tell you what colorspace was output by the source filter:

    Code:
    ffVideoSource()
    Info()
    Some encoders allow you to specify what colorspace is used internally. Some source filters allow you to specify what colorspace to output:

    Code:
    AviSource("filename.avi", pixel_type="RGB32")
    Though forcing the colorspace may not be lossless relative to what's in the file. For example, if a video uses YV12 internally but you force RGB32 output that conversion will be lossy.

    You can explicitly convert colorspaces with ConvertToYV12(), ConvertToYUY2(), ConvertToRGB32(), etc. Within those filters you can specify what colormatrix to use, for example ConvertToYV12(matrix="rec709"). But those are mostly lossy conversions. So you can't perfectly compare an RGB video to a YV12 video. The best you could do is convert one of them to the colorspace of the other and then compare. Say you have an RGB source and you want to convert to lossless x264. You could first explicitly convert your source to YV12 and compress that:

    Code:
    AviSource("RGB.AVI").ConvertToYV12()
    Then to compare the source converted to YV12 to the encoded video:

    Code:
    v1=AviSource("RGB.AVI").ConvertToYV12()
    v2=ffVideoSource("x264.mp4", seekmode=0)
    Subtract(v1,v2)
    With that you can verify that x264 lossless was truly lossless given a YV12 input.

    Originally Posted by Pilotwings_64 View Post
    Also, can you comment on my idea to encode both the FRAPS and the x264 videos into lossless AVIs using the same codec, so I don't have these decoding issues?
    You can do that to eliminate sync issues. But if your videos are a mix of colorspaces there's no way to compare them directly.

    Also keep in mind that everything that shows up on the monitor is converted to RGB one way or another. Explicitly by the software or implicitly by the graphics card.

    If your fraps yuv sources are YV12 and you use 8 bit x264 (which work in YV12 by default) you can compare the two directly. I don't know enough about how 10 bit x264 upsamples 8 bit sources to 10 bit to say exactly how you can compare them.
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!