VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. Ive been struggling with this for quite some time now and made some progress but not quite there yet.

    I have two videos generated with Autodesk Maya. The original one (1) "test_scene_GUI.mov" is the one with the correct visual appearance in colors and gamma. It is the one im using as reference.

    The other one: (2) "batch_playblast_test_scene_yuv420p.mov" is the one that im trying to figure out how to convert so it looks exactly like (1).


    GAMMA CORRECTION TEST
    ------------------------------

    The first thing i noticed was a change in the gamma so i applied this ffmpeg command:

    Code:
    ffmpeg.exe -i batch_playblast_test_scene_yuv420p.mov -vf eq=gamma=2.2 -y batch_playblast_gamma_corrected.mov
    The resulting video is ALMOST quite there in colors and gamma as the (1) but it looks still a little bit washed out, so i thought there might be a problem with the color space.

    COLORSPACE CONVERSION TEST
    -------------------------------------

    So, going back to (2) and inspecting it with ffprobe it says that
    color_range=pc
    color_space=bt470bg

    And since the (1) was obtained in Maya in bt709/sRGB color space i tried to apply the following conversion:

    Code:
    ffmpeg.exe -i batch_playblast_test_scene_yuv420p.mov -c:v libx264 -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709 -y test_scene_converted_from_bt470bg.mov
    but the resulting video apparently has no difference at all with the input.

    Im kind of lost right now. The (2) was obtained playblasting in standalone in Maya and i was quite convinced the problem was only the gamma but it is not.
    What are the steps needed to convert (2) into (1) look?
    Image Attached Files
    Quote Quote  
  2. I think the second video only needs a limited range (TV) to full range (PC) adjustment. Note that all commercial and streaming video is limited range. So you may want to do it the other way around.
    Quote Quote  
  3. So i tried this as well:

    Code:
    ffmpeg.exe -i batch_playblast_test_scene_yuv420p.mov -c:v libx264 -vf scale=out_color_matrix=bt709:in_range=limited:out_range=full,eq=gamma=2.2 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -y test_scene_converted_from_bt470bg_color_range.mov
    being the "in_range=limitedut_range=full" the filter that apparently converts the color range from TV to PC. But it does nothing. The result is the same.

    So still lost...
    Quote Quote  
  4. One thing ive noticed is that if you check the following screenshot which shows both .mov files opened with MrViewer.

    "test_scene_converted_from_bt470bg_no_gamma.mo v" (shown in "linear" space) and the "test_scene_GUI.mov" (shown in "sRGB" space) look practically identical if you rely on the pinkish tones and violets and forget about the background.
    _
    Which is making me think that the only thing i need to do with "test_scene_converted_from_bt470bg_no_gamma.mo v" is convert from sRGB to linear, so that when i open it in MrViewer it matches the original one when set to "sRGB" in the viewing options. I used to think the only difference between linear and sRGB was the gamma 2.2 correction but it seems there is something else.

    Ive searched the web for sRGB to linear conversion with ffmpeg and havent found anything useful.
    Image Attached Thumbnails Click image for larger version

Name:	Captura3.PNG
Views:	7
Size:	508.9 KB
ID:	53497  

    Image Attached Files
    Quote Quote  
  5. This worked for me:

    Code:
    ffmpeg -i input.mov -vf scale=in_range=limited:out_range=full output.mov
    Quote Quote  
  6. Originally Posted by jagabo View Post
    This worked for me:

    Code:
    ffmpeg -i input.mov -vf scale=in_range=limited:out_range=full output.mov
    That doesnt color correct the video, already tried.
    Quote Quote  
  7. It works for me. The result is near perfect aside from the additional blurring from the YV12 chroma subsampling.

    yuy2 jpeg source:
    Image
    [Attachment 53500 - Click to enlarge]


    yv12 after levels adjustment:
    Image
    [Attachment 53502 - Click to enlarge]


    I converted to RGB here assuming pc.601 levels (JPEG is normally full range 601).

    I think you have an issue of how the downstream software displays the videos. I recommend you flag the colormatrix and range in the output files to increase your chance or proper playback.
    Last edited by jagabo; 25th May 2020 at 10:25.
    Quote Quote  
  8. Originally Posted by jagabo View Post
    It works for me. The result is near perfect aside from the additional blurring from the YV12 chroma subsampling. I think you have an issue of how the downstream software displays the video.
    Might be this the issue. Im not very familiar with MrViewer.... tried to open with Quicktime by default and the result is still wrong.
    Both show the file darker than the originalImage
    [Attachment 53501 - Click to enlarge]
    Quote Quote  
  9. Try adding the matrix and range options:

    Code:
    ffmpeg -y -i input.mov -vf scale=out_range=full -x264opts colormatrix=bt470bg:fullrange=on output.mov
    Again, I'm assuming the JPEG mov is full range 601, so I'm creating a full range 601 x264 video. If you want a more traditional limited range rec.709 video you should convert the source and flag it as such.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    It works for me. The result is near perfect aside from the additional blurring from the YV12 chroma subsampling.

    yuy2 jpeg source:
    Image
    [Attachment 53500 - Click to enlarge]


    yv12 after levels adjustment:
    Image
    [Attachment 53502 - Click to enlarge]


    I converted to RGB here assuming pc.601 levels (JPEG is normally full range 601).

    I think you have an issue of how the downstream software displays the videos. I recommend you flag the colormatrix and range in the output files to increase your chance or proper playback.
    this is how i flagged the metadata:
    Image
    [Attachment 53503 - Click to enlarge]


    but it still shows wrong........ shouldnt it be bt709??
    Quote Quote  
  11. As I understand it jpeg use full range 601. https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion


    Maybe the "colormatrix=bt470bg" should be "colormatrix=smpte170m"
    Quote Quote  
  12. Originally Posted by jagabo View Post
    As I understand it jpeg use full range 601. https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion


    Maybe the "colormatrix=bt470bg" should be "colormatrix=smpte170m"
    yep if you are using the first file "batch_playblast_test_scene.mov" it is encoded with Photo JPEG and the colorspace ist bt470bg.

    I was using the other source file "batch_playblast_test_scene_yuv420p.mov".

    Tried to flag with different values, but none of them seems to be recognized by the player.

    So basically it can all be sorted out with proper video metadata flagging......this is what you are saying right?. but this is again a headache.
    Quote Quote  
  13. Originally Posted by Drinkitrinki View Post
    I was using the other source file "batch_playblast_test_scene_yuv420p.mov".
    That file is limited range 601.


    Originally Posted by Drinkitrinki View Post
    Tried to flag with different values, but none of them seems to be recognized by the player.

    So basically it can all be sorted out with proper video metadata flagging......this is what you are saying right?
    Yes and no. Many players do not respond to the flags. They may always use rec.601 or rec.709. Or always assume limited range or full range. Some players will use rec.601 for SD, rec.709 for HD (unfortunately, you video's frame size is in the undefined are in between 720x480/576 and 1280x720). Or they may change depending on the codec.

    If your goal is to create an AVC video for general distribution I'd recommend it be converted and encoded as limited range rec.709, and flagged as such.
    Quote Quote  
  14. Originally Posted by jagabo View Post
    Originally Posted by Drinkitrinki View Post
    I was using the other source file "batch_playblast_test_scene_yuv420p.mov".
    That file is limited range 601.

    I know i did the convert to full range as you mentioned.

    Originally Posted by Drinkitrinki View Post
    Tried to flag with different values, but none of them seems to be recognized by the player.

    So basically it can all be sorted out with proper video metadata flagging......this is what you are saying right?
    Yes and no. Many players do not respond to the flags. They may always use rec.601 or rec.709. Or always assume limited range or full range. Some players will use rec.601 for SD, rec.709 for HD (unfortunately, you video's frame size is in the undefined are in between 720x480/576 and 1280x720). Or they may change depending on the codec.

    If your goal is to create an AVC video for general distribution I'd recommend it be converted and encoded as limited range rec.709, and flagged as such.
    My goal is to match the same visual look of video (1) in video (2).

    At this moment, i think ive understood when the full range conversion must be applied, but to be honest, at this point i still dont know if the video mismatch is due to a shift in the gamma only (which i dont think according to the tests i did (see first post)), a shift in the colorspace not being the same or the problem relies in the viewer options (the colorspace that is applying the viewer when loading the video.. (which i also dont think so because i tried opening it in quicktime, mr viewer and vlc and the overall look in all of them is quite dark as well still, that is wrong))
    Quote Quote  
  15. So, here is what ive done so far and apparently im quite there, i would say almost.

    Code:
    ffmpeg.exe -i batch_playblast_test_scene.mov -vf scale=in_range=limited:out_range=full:out_color_matrix=bt709,eq=gamma=2.2 -pix_fmt yuv420p -crf 18 -y batch_playblast_test_scene_all_in_one.mov
    explanation of the different flags:

    - in_range=limitedut_range=full allows for a full range conversion which is present in the bt470bg original file but not after the conversion to bt709 which is HDTV broadcast limited range. So i need to go back to full range
    - out_color_matrix=bt709 applies the color space conversion to HDTV
    - eq=gamma=2.2 applies the correct gamma which according to multiple sources is the main difference between sRGB and rec709/bt709 color spaces. Apparently they both share the same primaries.

    Here are the two videos original and after conversion
    Image Attached Files
    Quote Quote  
  16. Originally Posted by Drinkitrinki View Post
    So, here is what ive done so far and apparently im quite there, i would say almost.

    Code:
    ffmpeg.exe -i batch_playblast_test_scene.mov -vf scale=in_range=limited:out_range=full:out_color_matrix=bt709,eq=gamma=2.2 -pix_fmt yuv420p -crf 18 -y batch_playblast_test_scene_all_in_one.mov
    explanation of the different flags:

    - in_range=limitedut_range=full allows for a full range conversion which is present in the bt470bg original file but not after the conversion to bt709 which is HDTV broadcast limited range. So i need to go back to full range
    - out_color_matrix=bt709 applies the color space conversion to HDTV
    - eq=gamma=2.2 applies the correct gamma which according to multiple sources is the main difference between sRGB and rec709/bt709 color spaces. Apparently they both share the same primaries.

    Here are the two videos original and after conversion
    Resubmitting the two videos with same proper width/height and few comments:

    Code:
    ffmpeg.exe -i batch_playblast_test_scene.mov -vf scale=in_range=limited:out_range=full:out_color_matrix=bt709,eq=gamma=2.2 -color_primaries bt709 -colorspace bt709 -color_trc bt709 -pix_fmt yuv420p -crf 18 -y batch_playblast_test_scene_all_in_one_2048.mov
    Added flags:
    - color_primaries bt709 -colorspace bt709 -color_trc bt709: these flags are only useful to set the metadata of the video file. They dont actually perform any conversion.

    The following line:
    Code:
    ffprobe.exe -show_streams batch_playblast_test_scene_all_in_one_2048.mov
    provides as output:
    Image
    [Attachment 53506 - Click to enlarge]


    Still some doubts:
    - the ffprobe command output shows "color_range=tv" even after applying the
    Code:
    "in_range=limited:out_range=full"
    scale video filter. Dont know if this is actually this way or it is just a matter of the wrong flag in the metadata.
    - Also another thing that is puzzling me is the huge difference in file size: the original one is 5.97MB and ffmpeg converted one is 55.5KB. Maybe there is something still wrong here?
    Image Attached Files
    Last edited by Drinkitrinki; 25th May 2020 at 13:59.
    Quote Quote  
  17. And back to your suggestion JAGABO,
    here are the two original videos:

    (1) test_scene_GUI.mov

    (2) batch_playblast_test_scene.mov

    with any ffmpeg conversion.

    So maybe here the only problem is a matter of the viewing software, because (2) in LINEAR is almost identical to (1) in sRGB. (see screen capture)
    Image
    [Attachment 53509 - Click to enlarge]


    So to sum up, i still dont know where the problem is........
    Image Attached Files
    Quote Quote  
  18. Many players do not respond to the flags. They may always use rec.601 or rec.709. Or always assume limited range or full range.
    I now use ffplay for any critical video measurements so I can specify the range. Many players force 16 - 235 to 0 - 255 and this drives me nuts.
    Quote Quote  
  19. Originally Posted by Drinkitrinki View Post
    Still some doubts:
    - the ffprobe command output shows "color_range=tv" even after applying the
    Code:
    "in_range=limited:out_range=full"
    scale video filter. Dont know if this is actually this way or it is just a matter of the wrong flag in the metadata.
    It's because it's not flagged.

    Originally Posted by Drinkitrinki View Post
    - Also another thing that is puzzling me is the huge difference in file size: the original one is 5.97MB and ffmpeg converted one is 55.5KB. Maybe there is something still wrong here?
    It's what you expect going from JPEG to x264 at the medium preset.
    Quote Quote  



Similar Threads