Log in

View Full Version : Encoding a DCP


FranceBB
26th July 2019, 18:49
Hi,
as a broadcast encoder, I face new challenges everyday.
This time, they asked us to make a DCP out of one of our original production in order to be displayed at cinema.
I gotta be fair, I'm really new to DCP and the Senior Encoder who was working with DCP is now retired, so... I have no clue.
I checked the specifications of the format and it seems that they wanna have a JPEG2000 encoded with the Digital Cinema profile, 4:4:4 12bit progressive at 24fps.

I decided to make a test with one of our commercial/promotion video in order to make sure I was doing the right thing.

First things first. Let's start with Avisynth:

#Indexing
video=FFVideoSource("HNS.mxf")
ch1=FFAudioSource("HNS.mxf", track=1)
ch2=FFAudioSource("HNS.mxf", track=2)
audio=MergeChannels(ch1, ch2)
AudioDub(video, audio)

#Slow-down from 25p to 24p
AssumeFPS(24, 1, true)
ResampleAudio(48000)

#Bringing everything to 16bit planar
ConvertBits(16)

#From yv16 planar to RGB
ConvertToPlanarRGB()

#From linear BT709 SDR to DCI XYZ
Cube("C:\Programmi\AviSynth+\LUTs\BT709_to_DCI_XYZ.cube", cpu=1, fullrange=false)


Then I encoded it with ffmpeg which basically got each and every frame from Avisynth and encoded each one in a single image (.tiff).
After this, I used OpenDCP to make it encode in JPEG2000 D-Cinema 2K, 250 Mbit/s, 4:4:4 12bit.

Although I've got the file with the right codec and metadata (I think), when I opened with NeoDCP, I wasn't able to play it with the right XYZ->YUV conversion, so I have no idea whether I made my LUT in the right way or not. Don't get me wrong, I think that I did it correctly, but I'm really not sure as I have nothing to check it, so... may I ask you to check it and tell me whether it's correct or not?


Source:

https://i.imgur.com/WObxYQI.png


Encode:

https://i.imgur.com/kpbjxiS.png


A few Screenshots:


Source BT709 yv16 planar 8bit:

https://i.imgur.com/iqncGin.png

Encode DCI XYZ 4:4:4 planar 12bit:

https://i.imgur.com/QvRGMMW.png

Source BT709 yv16 planar 8bit:

https://i.imgur.com/Wqvm6ZT.png

Encode DCI XYZ 4:4:4 planar 12bit:

https://i.imgur.com/oQTbV9u.png

Source BT709 yv16 planar 8bit:

https://i.imgur.com/iyqBvUH.png

Encode DCI XYZ 4:4:4 planar 12bit:

https://i.imgur.com/0DrlmJp.png

Source BT709 yv16 planar 8bit:

https://i.imgur.com/mem7cXi.png

Encode DCI XYZ 4:4:4 planar 12bit:

https://i.imgur.com/Nr0Dydz.png

Source BT709 yv16 planar 8bit:

https://i.imgur.com/gi1NPFn.png

Encode DCI XYZ 4:4:4 planar 12bit:

https://i.imgur.com/jkXxjlS.png



Here you'll find the download link:

DCP Attempt 1 + Source: Link (https://we.tl/t-kMBCvVY9ua)
Experimental matrices of linear transformation (LUTs): Link (https://we.tl/t-Qp95x0AXt8)

(Inside you'll find a .zip with the DCP created with Avisynth, ffmpeg and OpenDCP and the original source file in BT709 yv16 8bit planar).
(Note: please note that the source file is 25fps progressive flagged as interlaced)

Please let me know whether I did something terribly wrong or not.

Thank you in advance,
Frank

real.finder
27th July 2019, 12:45
with this

ffms2("HNS.video.mxf",colorspace="RGBP16") #don't know why it not output RGBP in first place! since XYZ more close to RGB than YUV! and why not accept RGBP12!
ConvertToRGB64.ConvertXYZtorgb #another don't know why not accept RGBP! or even RGB48!


the color kinda back to normal but the brightness and the contrast changed!

FranceBB
27th July 2019, 13:35
I see...
So I must have done something wrong when I was creating the LUT as the contrast changed when bringing it back to YUV.
Rather than making a brand new LUT, I'm gonna try to encode like this:

FFVideoSource("C:\Users\bucciantinif\Desktop\DCP_attempt1\Source.mxf")

ConvertToRGB32()

ConvertRGBtoXYZ()

so that ffmpeg will extract the .tiff and OpenDCP will encode to JPEG2000. I'll let you know about my second attempt soon.

real.finder
27th July 2019, 13:39
I see...
So I must have done something wrong when I was creating the LUT as the contrast changed when bringing it back to YUV.
Rather than making a brand new LUT, I'm gonna try to encode like this:

FFVideoSource("C:\Users\bucciantinif\Desktop\DCP_attempt1\Source.mxf")

ConvertToRGB32()

ConvertRGBtoXYZ()

so that ffmpeg will extract the .tiff and OpenDCP will encode to JPEG2000. I'll let you know about my second attempt soon.

since avs+ don't support XYZ and deal with it as RGB, I think you need to tell ffmpeg that the output of avs+ is XYZ not RGB, don't know how that can be done though

FranceBB
27th July 2019, 14:10
It's not such a big deal as it doesn't really matter whether it flags .tiff as RGB or XYZ as long as it doesn't make any conversion (so it doesn't screw up anything), 'cause OpenDCP is "dumb" and will ignore any metadata and take as granted that .tiff are in XYZ.
I'll let you know, though.

Jamaika
28th July 2019, 07:58
I found the libraw program.
The problem is that if you don't have Adobe, you will not resize, change bitdepth or hard to keep colorspace XYZ by converting it to j2K.

dcraw_emu.exe -v -F -o 5 -mem -6 -T RAW_CANON_EOS_5DS.cr2
Camera2RGB matrix:
1.9176 -1.0691 0.1516
-0.1750 1.6879 -0.5129
0.0375 -0.5628 1.5254

XYZ->CamRGB matrix:
0.6250 -0.0711 -0.0808
-0.5153 1.2794 0.2636
-0.1249 0.2198 0.5610

Derived D65 multipliers: 2.299029 0.928817 1.404652
Writing file RAW_CANON_EOS_5DS.cr2.tiff

convert.exe RAW_CANON_EOS_5DS.cr2 -verbose -alpha off -color-matrix "1.9176 -1.0691 0.1516 -0.1750 1.6879 -0.5129 0.0375 -0.5628 1.5254" -set color-matrix "0.6250 -0.0711 -0.0808 -0.5153 1.2794 0.2636 -0.1249 0.2198 0.5610" -gamma 2.2 -evaluate pow 4.5 -depth 12 -resize 2048x1080! dci-xyz.tiff

Don't conversion RGB->YCC (no Multiple Component Transform)
copenjpeg2000.exe -i dci-xyz.tiff -o XYZ(444).j2k -F 2048,1080,3,12,u@1x1:1x1:1x1 -mct 0 -cinema2K 24 -r 6 -C ""

FranceBB
28th July 2019, 16:06
Alright, I tried to convert using Avisynth from YUV to XYZ, but the resulting DCP encoded in JPEG2000 is wrong.

If I try to convert it back with Avisynth, I get the wrong colors: Img1 (https://i.imgur.com/06il75A.jpg) - Img2 (https://i.imgur.com/ITRTwzV.jpg)
This basically means that although Avisynth did it correctly, either ffmpeg or OpenDCP screwed up the levels.
I bet it's ffmpeg 'cause it's interpreting the Avisynth XYZ output as RGB and it's encoding it in the wrong way.

DCP Attempt 2: Link (https://we.tl/t-FgkBk2eekd)

By the way, I'm also trying to make a brand new LUT just because I don't know how to tell ffmpeg what Avisynth is frameserving to ffmpeg, so perhaps with a LUT I can let ffmpeg apply it and flag it correctly, I think.

This is my brand new LUT (I still have to encode with this new one): Link (https://we.tl/t-Kagd1oAtpy)

Jamaika
28th July 2019, 19:55
ffmpeg.exe -y -i "Source.mxf" -ss 7.500 -an -f image2 -frames 1 -vf scale=2048:1080:in_color_matrix=bt709:in_range=limited,format=bgr48,lutyuv=clipval:clipval:clipval -strict -1 111.tiff

convert.exe 111.tiff -verbose -alpha off -depth 16 -gamma 2.2 -color-matrix "1.9176 -1.0691 0.1516 -0.1750 1.6879 -0.5129 0.0375 -0.5628 1.5254" -colorspace XYZ -set colorspace XYZ dci-xyz.tiff

copenjpeg2000.exe -i dci-xyz.tiff -o XYZ(444).j2k -F 2048,1080,3,12,u@1x1:1x1:1x1 -mct 0 -cinema2K 24 -r 6 -C "Jamaika"

ffplay.exe XYZ(444).j2k
Stream #0:0: Video: jpeg2000 (JPEG 2000 digital cinema 2K), xyz12le, 2048x1080, 25 tbr, 25 tbn, 25 tbc

https://i.imgur.com/Tdcly9R.jpg?1

SeeMoreDigital
28th July 2019, 21:27
Hi,
as a broadcast encoder, I face new challenges everyday.
This time, they asked us to make a DCP out of one of our original production in order to be displayed at cinema.
I gotta be fair, I'm really new to DCP and the Senior Encoder who was working with DCP is now retired, so... I have no clue.
I checked the specifications of the format and it seems that they wanna have a JPEG2000 encoded with the Digital Cinema profile, 4:4:4 12bit progressive at 24fps.I wonder if VirtualDub2 can be configured to generate a DCP JPEG2000 image sequence...

Emulgator
31st July 2019, 18:14
Hi FranceBB,
Here I throw 16bit TIFFs at OpenDCP.
RGB to XYZ done, JPEG2000 Encoding done, muxing done, folder and aux file generation done.
The resulting DCPs have been tested on Doremi under HFS+, NTFS, and Ext2.
Projected ok in Berlin Cinemas and around.
It just works beautifully, thanks Terrence Meiczinger !!!

kolak
1st August 2019, 10:38
And if it was 2K you could just use free Resolve and have rather hassle free workflow :)