DPX EXPORT

Questions and answers on how to get the most out of FFAStrans
Post Reply
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

DPX EXPORT

Post by andrezagato »

Hello, me again! Quick question. Would it be possible to export a DPX image sequence ?
emcodem
Posts: 1749
Joined: Wed Sep 19, 2018 8:11 am

Re: DPX EXPORT

Post by emcodem »

Heyho, always good to hear from you :D

Sounds pretty simple, how about something like that in a cmd processor?

Code: Select all

"%s_ffmpeg%" -i "%s_source%"  c:\temp\%05d.dpx
%05 means prepend zeros to filename e.g. 00001.dpx. If it was %02 it would be 01.dpx. %d.dpx would not prepend zeros e.g. 1.dpx.
emcodem, wrapping since 2009 you got the rhyme?
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: DPX EXPORT

Post by andrezagato »

Hey emcodem.
I was checkin the forum and saw this message that I left hanging..
The thing is that I don't remember why I wanted to do that! But since we are on the topic. What about specs of the dpx ? like bit depth ? could ffmpeg do that ?

Thanks anyway for the help.
User avatar
FranceBB
Posts: 258
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: DPX EXPORT

Post by FranceBB »

Yes it can, bit depth can be changed using the pix_fmt command (which you should avoid in any case), for instance, if you want 8bit planar, you can do something like:

#8bit

Code: Select all

%comspec% /c ""%s_ffmpeg%" -i "%s_source%" -pix_fmt rgb24 -c:v dpx -y "c:\temp\%05d.dpx""

Code: Select all

General
Complete name                            : /home/FranceBB/Share Windows Linux/temp/NAS/00001.dpx
Format                                   : DPX
Format version                           : Version 1.0
File size                                : 1.19 MiB
Writing library                          : Lavc60.3.100

Image
Format                                   : DPX
Format version                           : Version 1.0
Compression                              : Raw
Format settings                          : Little / Packed
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 16:9
Color space                              : RGB
Bit depth                                : 8 bits
Compression mode                         : Lossless
Stream size                              : 1.19 MiB (100%)
Writing library                          : Lavc60.3.100

#16bit

Code: Select all

%comspec% /c ""%s_ffmpeg%" -i "%s_source%" -pix_fmt rgb48 -c:v dpx -y "c:\temp\%05d.dpx""

Code: Select all

General
Complete name                            : /home/FranceBB/Share Windows Linux/temp/NAS/00001.dpx
Format                                   : DPX
Format version                           : Version 1.0
File size                                : 1.19 MiB
Writing library                          : Lavc60.3.100

Image
Format                                   : DPX
Format version                           : Version 1.0
Compression                              : Raw
Format settings                          : Little / Packed
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 16:9
Color space                              : RGB
Bit depth                                : 8 bits
Compression mode                         : Lossless
Stream size                              : 1.19 MiB (100%)
Writing library                          : Lavc60.3.100


By standard, DPX are RGB Full Range, therefore if your input is some kind of YUV, you'll have to convert to RGB and expand the levels from Limited to Full Range.
Of course, FFMpeg does this for you automatically once you specify -pix_fmt rgb as it knows that YUV is assumed to be limited and rgb is assumed to be full, so it performs the conversion... badly.
Same goes for potential chroma resizing: you may have a yv12 as your input or a yv16 (so 4:2:0 or 4:2:2) and you may not have a 4:4:4 source to begin with, which means that the resolution of the luma isn't the same as the resolution of the chroma, which means that you'll have to upscale the chroma.
(for the sake of being clear, here "badly" means that I'm a perfectionist and I want to specify the resizing kernel myself, but 90% of the population probably couldn't tell nor care and would be more than happy with the output of pix_fmt).
So... if you're a perfectionist like me and you hate the default resizing kernels like Bilinear and Bicubic, what can we do?

Well... Avisynth to the rescue, of course.
We can use Spline64, one of the most sharp resizing kernel which uses sqrt(64) so 8 resampling points to fit a cubic spline across while being aware of the surrounding points.
If you're curious about that, you can check my post here: https://forum.doom9.org/showpost.php?p= ... tcount=215

Anyway, we can go easily with a custom Avisynth Script of course and get far better results:

#The following assumes BT709 Limited TV Range input and Full PC Range BT709 RGB output

Code: Select all

#You'll have to populate the path to avsresize yourself once you download it
LoadPlugin("avsresize.dll")

#Screw frame properties
PropClearAll()

#RGB 16bit full range high quality conversion
m_clip=z_ConvertFormat(m_clip, pixel_type="RGBP16", colorspace_op="709:709:709:limited=>rgb:709:709:full", resample_filter_uv="spline64", dither_type="error_diffusion", 
use_props=0)
You can find avsresize here: http://avisynth.nl/index.php/Avsresize

and then we use our command execution:

Code: Select all

%comspec% /c ""%s_ffmpeg%" -i "%s_source%" -c:v dpx -y "c:\temp\%05d.dpx""
andrezagato
Posts: 43
Joined: Tue Jun 09, 2020 4:07 pm

Re: DPX EXPORT

Post by andrezagato »

Very cool!
I will test it out!!
Thanks!
Post Reply