Discussion:
[FFmpeg-user] Full to studio levels
Rio Kierkels
2013-12-23 22:18:33 UTC
Permalink
Hey everyone,

I've been stuck with a level scaling problem. I'm trying to generate
broadcast compliant HD mxf files so they have to adhere to the BT.709 spec.
Meaning BT.709 primaries with a 2.4ish power function and "studio" luma
levels meaning black starts at 16 and white peaks at 235.

My sources are full scale BT.709 dpx files. And to force the output to
BT.709 primaries I have to add a colormatix filter from bt601 to bt709
strangely enough. It does work however.

The only thing I just cant seem to get working is the luma scaling. I've
tried the scale filter with the in_range and out_range options. And I've
tried the -color_range option on both the in and output files.
That does change the pix_fmt indication from yuv420p to yuv420p(tv) but it
doesn't change the picture.

I've built ffmpeg v 2.1.1 for this project.
I hope you guys can help and in time I can help out the project!

Rio
Carl Eugen Hoyos
2013-12-24 06:05:18 UTC
Permalink
Post by Rio Kierkels
I've been stuck with a level scaling problem.
Please provide your failing command line together
with the complete, uncut console output.

Carl Eugen
Rio Kierkels
2013-12-24 08:28:14 UTC
Permalink
Oh sure, sorry about that. This is the command I used last:

----------------------
ffmpeg -y -nostdin -i "/Path/To/Source/video.%4d.dpx" -i
"/Path/To/Source/audio.wav" -map 0:0 -c:0:0 mpeg2video -b:0:0 50M
-filter:0:0
"scale=in_range=full:out_range=tv:w=1920:h=1080:in_color_matrix=bt601:out_color_matrix=bt709,setdar=1.77777777778"
-flags +ildct+ilme -top 1 -map 1:a:0 -map_channel 1.0.0:0.1 -map 1:a:0
-map_channel 1.0.1:0.2 -map 1:a:0 -map_channel -1:0.3 -map 1:a:0
-map_channel -1:0.4 -c:1:0 pcm_s24le -b:1:0 240000 "/Path/To/out.mxf"
----------------------

And Here is the output

----------------------
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Dec 23 2013 14:19:36 with gcc 4.4.6 (GCC) 20120305 (Red Hat
4.4.6-4)
configuration: --prefix=/Portal/ffmpeg/build/ --enable-gpl
--enable-version3 --enable-nonfree --disable-ffplay --disable-ffserver
--enable-libx264 --enable-libvpx --enable-libopenjpeg --enable-libtheora
--enable-libvo-aacenc --enable-libvorbis --enable-libmp3lame
--extra-cflags=-I/Portal/ffmpeg/build/include
--extra-ldflags=-L/Portal/ffmpeg/build/lib
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, image2, from '/Path/To/Source/video.%4d.dpx':
Duration: 00:00:04.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: dpx, gbrp10le, 1920x1080 [SAR 1:1 DAR 16:9], 25
tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from '/Path/To/Source/audio.wav':
Duration: 00:00:03.95, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo, s16, 1536 kb/s
-map_channel is forwarded to lavfi similarly to -af pan=0x4:c0=c0.
[pan @ 0x2514460] This syntax is deprecated. Use '|' to separate the list
items.
[pan @ 0x2514460] Pure channel mapping detected: 0
-map_channel is forwarded to lavfi similarly to -af pan=0x4:c0=c1.
[pan @ 0x2628800] This syntax is deprecated. Use '|' to separate the list
items.
[pan @ 0x2628800] Pure channel mapping detected: 1
-map_channel is forwarded to lavfi similarly to -af pan=0x4.
[pan @ 0x263f3c0] Pure channel mapping detected: M
-map_channel is forwarded to lavfi similarly to -af pan=0x4.
[pan @ 0x264d660] Pure channel mapping detected: M
Output #0, mxf, to '/Path/To/out.mxf':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: mpeg2video, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9],
q=2-31, 50000 kb/s, 25 tbn, 25 tbc
Stream #0:1: Audio: pcm_s24le, 48000 Hz, mono, s32, 1152 kb/s
Stream #0:2: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Stream #0:3: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Stream #0:4: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (dpx -> mpeg2video)
Stream #1:0 -> #0:1 (pcm_s16le -> pcm_s24le)
Stream #1:0 -> #0:2 (pcm_s16le -> pcm_s16le)
Stream #1:0 -> #0:3 (pcm_s16le -> pcm_s16le)
Stream #1:0 -> #0:4 (pcm_s16le -> pcm_s16le)
frame= 100 fps=4.9 q=2.0 Lsize= 5004kB time=00:00:03.96
bitrate=10351.8kbits/s
video:3211kB audio:1666kB subtitle:0 global headers:0kB muxing overhead
2.609146%
----------------------

I've tried variations on the above command, including different options for
in and out_range like, pc, mpeg, jpeg, tv, full and switching them around.
I've also tried not doing it through the scale filter but via the
-color_range flag on the in and output files.

And can somebody clarify why I have to put a color transform from BT.601 to
BT.709 in there to retain my primaries while my source already is BT.709?

Thanks
Post by Carl Eugen Hoyos
Post by Rio Kierkels
I've been stuck with a level scaling problem.
Please provide your failing command line together
with the complete, uncut console output.
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
--
42
Carl Eugen Hoyos
2013-12-26 15:24:50 UTC
Permalink
Post by Rio Kierkels
Stream #0:0: Video: dpx, gbrp10le, 1920x1080
Do you know the dynamics of your input frames?
Is black 0x00 and "white" 0x3FF?

Carl Eugen
Rio Kierkels
2013-12-27 14:29:51 UTC
Permalink
Yes I'm sure. I've built some colorbars using the ARIB STD-B28 spec (
http://www.arib.or.jp/english/html/overview/doc/6-STD-B28v1_0-E1.pdf) in
linear 32bit exr and transformed it to BT.709 primaries in a dpx container.
I could send a zip with the sequence I'm using if you'd like
Post by Carl Eugen Hoyos
Post by Rio Kierkels
Stream #0:0: Video: dpx, gbrp10le, 1920x1080
Do you know the dynamics of your input frames?
Is black 0x00 and "white" 0x3FF?
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
--
42
Rio Kierkels
2014-02-03 10:27:46 UTC
Permalink
Post by Rio Kierkels
Yes I'm sure. I've built some colorbars using the ARIB STD-B28 spec (
http://www.arib.or.jp/english/html/overview/doc/6-STD-B28v1_0-E1.pdf) in
linear 32bit exr and transformed it to BT.709 primaries in a dpx container.
I could send a zip with the sequence I'm using if you'd like
Post by Carl Eugen Hoyos
Post by Rio Kierkels
Stream #0:0: Video: dpx, gbrp10le, 1920x1080
Do you know the dynamics of your input frames?
Is black 0x00 and "white" 0x3FF?
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
--
42
Apparently I'm the only one with this issue so I'm starting a new thread
with more comprehensive material and commandline output to work with.
I hope maybe then we'll get a solution.
Carl Eugen Hoyos
2014-02-03 10:32:40 UTC
Permalink
Post by Rio Kierkels
Apparently I'm the only one with this issue so
I'm starting a new thread with more comprehensive
material and commandline output to work with.
I suspect a sample will be needed.
Sorry if you feel I should have explicitely asked
for one; it is usually impossible to fix issues
without samples.
(That is not exactly true but it certainly makes
things easier and shows some interest from your
side.)

Carl Eugen
Rio Kierkels
2014-02-03 10:35:58 UTC
Permalink
Post by Carl Eugen Hoyos
Post by Rio Kierkels
Apparently I'm the only one with this issue so
I'm starting a new thread with more comprehensive
material and commandline output to work with.
I suspect a sample will be needed.
Sorry if you feel I should have explicitely asked
for one; it is usually impossible to fix issues
without samples.
(That is not exactly true but it certainly makes
things easier and shows some interest from your
side.)
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Thanks Carl, I realize this is difficult without a sample.
However a lot of the material I handle has copyright so it is a pain to
distribute.

How are samples and usually shared on a mailing list?
Right now I'm uploading them to a google drive share.
--
42
Carl Eugen Hoyos
2014-02-03 10:40:46 UTC
Permalink
Post by Rio Kierkels
However a lot of the material I handle has copyright so
it is a pain to distribute.
Maybe you should encode a b/w checkboard?
Post by Rio Kierkels
How are samples and usually shared on a mailing list?
Right now I'm uploading them to a google drive share.
That is fine, alternatives are http://www.datafilehost.com/
or you read http://ffmpeg.org/bugreports.html (there is no
hard filesize limit).

Carl Eugen
Rio Kierkels
2014-02-03 10:55:32 UTC
Permalink
Thanks I'll, check it out!
Post by Carl Eugen Hoyos
Post by Rio Kierkels
However a lot of the material I handle has copyright so
it is a pain to distribute.
Maybe you should encode a b/w checkboard?
Post by Rio Kierkels
How are samples and usually shared on a mailing list?
Right now I'm uploading them to a google drive share.
That is fine, alternatives are http://www.datafilehost.com/
or you read http://ffmpeg.org/bugreports.html (there is no
hard filesize limit).
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
--
42
Phil Rhodes
2014-02-03 12:38:31 UTC
Permalink
Rio,

I can basically confirm your impression that this isn't quite so easy to get right. 

You're not the only person to ever have hit this - it has been discussed for quite some time (years). A friend of mine had to write custom software using the ffmpeg libraries mainly because he could never figure out a way to handle certain luma scaling issues.

As you've found, there appears to be a few automatic behaviours which are a bit unhelpful, which I suspect you're somehow switching off with your filter selections.

Be prepared for the possibility that there is no lossless way to fix this from the commandline.

P
Rio Kierkels
2014-02-03 13:36:23 UTC
Permalink
Post by Phil Rhodes
Rio,
I can basically confirm your impression that this isn't quite so easy to
get right.
You're not the only person to ever have hit this - it has been discussed
for quite some time (years). A friend of mine had to write custom software
using the ffmpeg libraries mainly because he could never figure out a way
to handle certain luma scaling issues.
As you've found, there appears to be a few automatic behaviours which are
a bit unhelpful, which I suspect you're somehow switching off with your
filter selections.
Be prepared for the possibility that there is no lossless way to fix this
from the commandline.
P
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Thanks Phil,

I was afraid it would be something like that. As we speak I'm writing a
huge post with sample material to use just to try to clarify the situation.
Hopefully a lot of people will chime in and contribute in some way or
another.

Great to see you here, It's always nice to read your RedShark articles.
I hope you can share some of your insights with this one as well.

Rio
--
42
Continue reading on narkive:
Loading...