Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st May 2016, 17:37   #3641  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 4,961
I cannot guarantee that ffmpeg can handle 16 bit per component PNG.

If it can, I don't know which command line options are required to convert to 10 bit per component YUV 4:2:0.

But it should be worth discovering if it works, and how.
__________________

German doom9 / Gleitz board
MediaFire shares: x265 | VPx | AOM | Xvid

Rémoulade is spoiled
LigH is offline   Reply With Quote
Old 1st May 2016, 17:51   #3642  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 4,674
Piping is simple. Replace ffmpeg output and x264 input file name with a "-", signal both to use y4m (since they don't have a file name they cannot guess from the file extension) and write the commands in a single line connect with a pipe symbol "|".
Code:
ffmpeg.exe -framerate 24 -i "E:\Sequence\img-%%05d.png" -strict -1 -pix_fmt yuv420p10 -f YUV4MPEGPIPE - | x265.exe --input-depth 10 --uhd-bd --preset slow --crf 18 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --master-display "G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(10000000,1)" --max-cll "0,0" --output "E:\x265\output.hevc" - --y4m
The color thing might indeed not be trivial at all. PNG is RGB not YUV.
sneaker_ger is offline   Reply With Quote
Old 1st May 2016, 17:52   #3643  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
It definitely works and the conversion from 16bit RGB Full range to 10bit YUV 4:2:0 Limited range is flawless.
The Y4M 10bit is properly dithered by ffmpeg and not simply truncated.
A smooth 16bit grey ramp looks absolutely identical after the conversion.

But if you find flaws, this will be informative to us all.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.

Last edited by James Freeman; 1st May 2016 at 17:59.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 17:56   #3644  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
Quote:
Originally Posted by sneaker_ger View Post
Piping is simple. Replace ffmpeg output and x264 input file name with a "-", signal both to use y4m (since they don't have a file name they cannot guess from the file extension) and write the commands in a single line connect with a pipe symbol "|".
Code:
ffmpeg.exe -framerate 24 -i "E:\Sequence\img-%%05d.png" -strict -1 -pix_fmt yuv420p10 -f YUV4MPEGPIPE - | x265.exe --input-depth 10 --uhd-bd --preset slow --crf 18 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --master-display "G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(10000000,1)" --max-cll "0,0" --output "E:\x265\output.hevc" - --y4m
The color thing might indeed not be trivial at all. PNG is RGB not YUV.
You mean I don't have to create a HUGE y4m file before going to x265?
Why that is absolutely PERFECT!

I'm off to try it.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 17:56   #3645  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 4,674
Quote:
Originally Posted by James Freeman View Post
It definitely works and the conversion from 16bit RGB Full range to 10bit YUV 4:2:0 Limited range is flawless.
The Y4M 10bit is properly dithered by ffmpeg and not simply truncated.
But we are not just talking about range and dithering. You want bt.2020. You want HDR. You want non-mpeg2-chroma position. I highly doubt this is achieved with your simple ffmpeg command.
sneaker_ger is offline   Reply With Quote
Old 1st May 2016, 18:19   #3646  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
The PNG images are already in 2020 and HDR, they are exported from After Effects with Color space and range conversion with official Rec.2020 ST.2084 (PQ) profiles and edited with 1000 nit in mind.
Think of the PNG files as though I just graded a movie on a Rec.2020 ST.2084 monitor.

I don't know about chroma position but it looks right to me on default settings.

EDIT:
The pipe works perfectly, you saved me a lot of effort, thank you!
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.

Last edited by James Freeman; 1st May 2016 at 18:57.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 19:13   #3647  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 453
Quote:
Originally Posted by James Freeman View Post
mp4box.exe -add E:\X265\output.hevc -new E:\X265\output.mp4
Correct entry:
mp4box.exe -new -info -add E:\X265\output.h265:mpeg4:noedit:trailing:xps_inband E:\X265\output.mp4
or
mkvmerge.exe --ui-language en --fourcc 0:HEVC --cues 0:iframes "E:\X265\output.h265" --track-order 0:0 --disable-track-statistics-tags --output "E:\X265\output.mkv"
Jamaika is offline   Reply With Quote
Old 1st May 2016, 19:32   #3648  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
I had to add "-vf colormatrix=bt601:bt709" to ffmpeg so the RGB -> YUV color conversion will be correct.
Now it looks and measures 1:1 to the RGB.

EDIT Important!
The "-vf colormatrix=bt601:bt709" should be changed to "-vf scale=out_color_matrix=bt709" because the colormatrix command is only 8bit and it dithers down to 8bit.
While the scale=out_color_matrix=bt709 command bypasses any conversion while retains correct chroma values between RGB to YUV conversion.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.

Last edited by James Freeman; 2nd May 2016 at 12:05.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 19:37   #3649  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 4,674
Quote:
Originally Posted by Jamaika View Post
mkvmerge.exe --ui-language en --fourcc 0:HEVC --cues 0:iframes "E:\X265\output.h265" --track-order 0:0 --disable-track-statistics-tags --output "E:\X265\output.mkv"
Don't give people funny ideas on how to use mkvmerge. A simple "mkvmerge -o output.mkv input.hevc" is totally fine. I hope your mp4box example is better, I don't know enough about mp4box to judge it.
sneaker_ger is offline   Reply With Quote
Old 1st May 2016, 19:45   #3650  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
Okay I run a single batch file that does everything in one click:
Code:
ffmpeg.exe -framerate 24 -i "E:\x265\Sequence\%%05d.png" -strict -1 -pix_fmt yuv420p10 -vf colormatrix=bt601:bt709 -f YUV4MPEGPIPE - | x265.exe --input-depth 10 --uhd-bd --preset slow --crf 18 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --master-display "G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(10000000,1)" --max-cll "0,0" --output "E:\x265\output.hevc" - --y4m
mp4box.exe  -add E:\X265\output.hevc -new E:\X265\output.mp4
pause
Thanks sneaker_ger.

EDIT Important!
The "-vf colormatrix=bt601:bt709" should be changed to "-vf scale=out_color_matrix=bt709" because the colormatrix command is only 8bit and it dithers down to 8bit.
While the scale=out_color_matrix=bt709 command bypasses any conversion while retains correct chroma values between RGB to YUV conversion.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.

Last edited by James Freeman; 2nd May 2016 at 12:05.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 19:53   #3651  |  Link
surami
Registered User
 
Join Date: May 2014
Location: Hungary
Posts: 64
James, please write your post into to the 4K HDR encoding topic too and post the example files.

Ps.: As I have time I will try this with Cineform RGBA 12bit files (instead of pngs), I read somewhere that ffmpeg supports them already... but if somebody knows more please say something.
surami is offline   Reply With Quote
Old 1st May 2016, 19:56   #3652  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
Alright surami.

Basically What I need now is the smallest high bitdepth Image file that After Effects will render the fastest.
Cineform RGBA 12bit is smaller that PNG 16bit?
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 20:06   #3653  |  Link
surami
Registered User
 
Join Date: May 2014
Location: Hungary
Posts: 64
I need to test too what you did, what was your exact visual source, settings, etc., let's continue in the other topic, if that is good for you and so poeple could follow there the process.

Last edited by surami; 1st May 2016 at 20:08.
surami is offline   Reply With Quote
Old 1st May 2016, 20:10   #3654  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
Alright moving there, I'll reserve the x265 HEVC question to this thread.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 20:36   #3655  |  Link
Jamaika
Registered User
 
Join Date: Jul 2015
Posts: 453
Quote:
Originally Posted by sneaker_ger View Post
I hope your mp4box example is better, I don't know enough about mp4box to judge it.
MP4Box recently is more stable. Although HEVC codec without command ":xps_inband" has a black screen. Player reads it as 8bit.
I use .h265 in MP4Box because of .hevc I had problems previously.
Quote:
Originally Posted by James Freeman View Post
I had to add "-vf colormatrix=bt601:bt709" to ffmpeg so the RGB -> YUV color conversion will be correct.
For what purpose?

Last edited by Jamaika; 1st May 2016 at 20:57.
Jamaika is offline   Reply With Quote
Old 1st May 2016, 20:46   #3656  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
Actually everything is A OK with the mp4box I'm using with the very basic settings.
Right image and 10bit.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 21:36   #3657  |  Link
James Freeman
Registered User
 
Join Date: Sep 2013
Posts: 909
After few tests, OpenEXR sequence is actually smaller and faster to render than PNG, and it is in floating point too.
And most importantly ffmpeg can work with EXR.

Quote:
Quote:
I had to add "-vf colormatrix=bt601:bt709" to ffmpeg so the RGB -> YUV color conversion will be correct.
For what purpose?
Without this command the last few steps of Chroma are clipped (shifted).
I read somewhere that ffmpeg treats RGB as 601 so this conversion has to occur for the colors to be right in 709.
After encoding I compared with the original RGB image and indeed the colors are accurate 1:1 which is important when creating calibration/measurement patterns.
http://forum.videohelp.com/threads/3...122&viewfull=1

EDIT Important!
The "-vf colormatrix=bt601:bt709" should be changed to "-vf scale=out_color_matrix=bt709" because the colormatrix command is only 8bit and it dithers down to 8bit.
While the scale=out_color_matrix=bt709 command bypasses any conversion while retains correct chroma values between RGB to YUV conversion.
__________________
System: i7 3770K, GTX660, Win7 64bit, Panasonic ST60, Dell U2410.

Last edited by James Freeman; 2nd May 2016 at 12:04.
James Freeman is offline   Reply With Quote
Old 1st May 2016, 22:49   #3658  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 4,961
If you have an ffmpeg with included libx265, you may not need to pipe to a separate x265 encoder, not even create a raw *.h265 video first. But anyway, remultiplexing to a complete MP4 container using MP4Box or L-SMASH is still recommendable, I am not sure how complete the MP4 container created by ffmpeg is (it used to be adversely arranged, due to its "filter" / FIFO behaviour: attributes only known at the end of the conversion have to be written to the end of the output).
__________________

German doom9 / Gleitz board
MediaFire shares: x265 | VPx | AOM | Xvid

Rémoulade is spoiled
LigH is offline   Reply With Quote
Old 1st May 2016, 23:05   #3659  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 2,401
Quote:
Originally Posted by James Freeman View Post
Alright surami.

Basically What I need now is the smallest high bitdepth Image file that After Effects will render the fastest.
Cineform RGBA 12bit is smaller that PNG 16bit?
I would stay away from an RGBA codec if at all possible, since that'll force another two color transforms. I'd want to render in 32-bit float to a YUV color space. There's no reason not to render to 10-bit if you're already in PQ space with 2020 primaries. You only need 12-bit if targeting Rec. 2020 12-bit HDR. Note both 12-bit 2020 and HDR-10 require non-gamma luma curves, and I'm not sure how to get the Adobe products to do those natively.

Looking at what Adobe Media Encoder supports, high quality options include:
  • DNxHR
  • Cineform YUV 10-bit
  • JPEG 2000 MXF OP1a YUV 4:2:2 10-bit

Blackmagic v210 certainly works as well, although is huge.

If you can get native OpenEXR to work as you describe, with the correct luma curve, that seems pretty optimal to me.

In practice, the best HDR-10 mezz format is likely a high quality HEVC, as that's the only bitstream format that can include all the HDR-10 metadata, including MaxFALL and MaxCLL. And it can do chromaloc 2, if you can find a tool that'll actually do the 0.25 pel chroma sample vertical offset. That might require a whole new color space format in ffmpeg.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Instant Video

My Compression Book

Amazon Instant Video is hiring! PM me if you're interested.
benwaggoner is offline   Reply With Quote
Old 2nd May 2016, 00:28   #3660  |  Link
Magik Mark
Registered User
 
Join Date: Dec 2014
Posts: 490
Guys,

Can you help me with my ghost problem. Maybe a missing switch? Doing x265 10bit 2pass via staxrip

__________________
Asus X99 Sabertooth - Xeon E5 2695 - Asus Strix GTX 960 4G - DDR4 16GB Predator - Pioneer KRP 600M (isf calibrated) - Yamaha A3030 - Windows 10 x64 - Kodi with DSplayer - Lav - MadVR - XYsubtitle
Magik Mark is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.