AVCHD decoding: wrong video levels

200 views
Skip to first unread message

priitp

unread,
Aug 12, 2011, 12:10:01 PM8/12/11
to ffmbc-discuss
Footage from popular Canon D5 camera in QuickTime container. 25fps.
Running ffmbc on Windows.

When I convert to PNG sequence or MPEG-2 (I-Frame only) the luminance
levels are not correct.
It looks like dark grey areas are black and possibly there is issues
in the light grey areas too.
Saving TGA or video files from QuickTime Pro results to proper levels.

May be it is 16-235 vs. 0-255 problem, may be it is Yuvj420p -> RGB
conversion problem.
Googled whole day and saw a lot of similar problems but no solution.
It seems the problem is originated from ffmpeg (and possibly from
libavcodec).

Have somebody found the solution?

Thanks
Priit

Baptiste Coudurier

unread,
Aug 12, 2011, 1:34:03 PM8/12/11
to ffmbc-...@googlegroups.com, priitp
Hi,

Use -vf colormatrix and please report if that fixed the issue.
If it didn't fix the issue the problem comes from something else.

--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org

priitp

unread,
Aug 12, 2011, 4:25:18 PM8/12/11
to ffmbc-discuss

> Use -vf colormatrix and please report if that fixed the issue.
> If it didn't fix the issue the problem comes from something else.
>
> --
> Baptiste COUDURIER

Baptiste,
thanks for the replay.

Unfortunatelly I don't know how to use "-vf colormatrix" and can't
find any documentaion on this filter.
There is "--colormatrix" on x264 encoding but to my knowledge not on
decoding.

If someone wants to test the issue the files are here:
ftp://ftp.stuudio.ee/ffmpegProblem

The script I used:
"H:\ffmpegProblem\ffmbc.exe" -i "H:\ffmpegProblem\MVI_7209.MOV" -f
image2 "H:\ffmpegProblem\MVI_72090_%06d.png"

There is also a file saved via QuickTime Pro and this one has right
levels.

Thanks
Priit Poldmaa

Baptiste Coudurier

unread,
Aug 12, 2011, 5:38:17 PM8/12/11
to ffmbc-...@googlegroups.com, priitp
On 08/12/2011 01:25 PM, priitp wrote:
>
>> Use -vf colormatrix and please report if that fixed the issue.
>> If it didn't fix the issue the problem comes from something else.
>>
>> --
>> Baptiste COUDURIER
>
> Baptiste,
> thanks for the replay.
>
> Unfortunatelly I don't know how to use "-vf colormatrix" and can't
> find any documentaion on this filter.
> There is "--colormatrix" on x264 encoding but to my knowledge not on
> decoding.

"usage: <src>:<dst>"
"possible options: bt709,bt601,smpte240m,fcc"

In that case, you should use
-vf colormatrix=bt709,bt601

Rens Dijkshoorn

unread,
Aug 13, 2011, 7:35:50 PM8/13/11
to ffmbc-discuss
Hi

using raw as an intermediate format make a difference if you are using

YUV420P

ffmbc -i Canon_60D/MVI_7209.MOV -vf
crop=1920:1080,colormatrix=bt709:bt601 -vcodec rawvideo -f rawvideo
pipe: \
| ffmbc -f rawvideo -r 25 -s 1920:1080 -pix_fmt yuv420p -i pipe: -
vcodec png -r 25 -f image2 CM_YUV420_%06d.png

YUVJ420P

ffmbc -i Canon_60D/MVI_7209.MOV -vf
crop=1920:1080,colormatrix=bt709:bt601 -vcodec rawvideo -f rawvideo
pipe: \
| ffmbc -f rawvideo -r 25 -s 1920:1080 -pix_fmt yuvj420p -i pipe: -
vcodec png -r 25 -f image2 CM_YUV420J_%06d.png


While direct conversion won't show any difference between the 2
commands.

ffmbc -i Canon_60D/MVI_7209.MOV -vf
crop=1920:1080,colormatrix=bt709:bt601 -pix_fmt yuv420p -vcodec png -r
25 -f image2 CM_NO_RAW_YUV420_%06d.png
ffmbc -i Canon_60D/MVI_7209.MOV -vf
crop=1920:1080,colormatrix=bt709:bt601 -pix_fmt yuvj420p -vcodec png -
r 25 -f image2 CM_NO_RAW_YUV420J_%06d.png

May this is of any use for you, but nothing seems to match your TGA
picture !!

Regards Rens



On Aug 12, 11:38 pm, Baptiste Coudurier <baptiste.coudur...@gmail.com>
wrote:

priitp

unread,
Aug 15, 2011, 4:49:34 PM8/15/11
to ffmbc-discuss
Thank you Baptiste and Rens for the help.
Everything is fine now.
I was parking under wrong tree.

Last few days I was messing up with pipes, lut filters, different
flags,
reading countless threads about 0-255 in YCbCr ,
lurking in the source code and converting, converting, converting...
Always geting different result than with QuickTimePro or
Main Concept Refernece application.
(I have some extra dark sample files from past to test the process)

Then noticed that I can grade my results very close to QT or Main
Concept results.
The difference was minimal and is possibly result of diffrent rounding
used or noise applied.
Just my picture is darker but no information was lost in near the
black or near the white.
Yes, results were different but no way there is lost 16 levels in both
sides.

My mistake was that with some earlier ffmpeg version we used in house
the result converted with ffmpeg was darker and blacks/whites were
limited.
Now seeing the darker picture I atomatically tought the same.
Actually the info is there now.
I quess may be it was the Baptiste's "video_full_range_flag patch"
doing the magic.

Again, many thaks to Baptiste and Rens.

Priit
Reply all
Reply to author
Forward
0 new messages