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:
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.Code:ffmpeg.exe -i batch_playblast_test_scene_yuv420p.mov -vf eq=gamma=2.2 -y batch_playblast_gamma_corrected.mov
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:
but the resulting video apparently has no difference at all with the input.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
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?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 19 of 19
Thread
-
-
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.
-
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
So still lost... -
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. -
This worked for me:
Code:ffmpeg -i input.mov -vf scale=in_range=limited:out_range=full output.mov
-
-
It works for me. The result is near perfect aside from the additional blurring from the YV12 chroma subsampling.
yuy2 jpeg source:
[Attachment 53500 - Click to enlarge]
yv12 after levels adjustment:
[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.
-
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 original
[Attachment 53501 - Click to enlarge] -
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
-
this is how i flagged the metadata:
[Attachment 53503 - Click to enlarge]
but it still shows wrong........ shouldnt it be bt709?? -
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. -
That file is limited range 601.
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)) -
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
- 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
- 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
[Attachment 53506 - Click to enlarge]
Still some doubts:
- the ffprobe command output shows "color_range=tv" even after applying theCode:"in_range=limited:out_range=full"
- 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?Last edited by Drinkitrinki; 25th May 2020 at 13:59.
-
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)
[Attachment 53509 - Click to enlarge]
So to sum up, i still dont know where the problem is........ -
Similar Threads
-
ffmpeg yuv colorspace is BT.601 or BT.709?
By colibri in forum Newbie / General discussionsReplies: 13Last Post: 22nd Dec 2019, 01:00 -
Trying to match original format in Vegas
By click_one in forum Newbie / General discussionsReplies: 10Last Post: 22nd Aug 2019, 14:38 -
Apply Yadif using complex filter in FFmpeg
By panzerIV in forum EditingReplies: 4Last Post: 5th Jul 2016, 04:14 -
ffmpeg does not apply parameters with libx265
By z-machine95 in forum Video ConversionReplies: 15Last Post: 19th Aug 2015, 04:29 -
ffmpeg do not apply parameters with libx265
By z-machine95 in forum Video ConversionReplies: 1Last Post: 28th Jun 2015, 16:57