[FFmpeg-trac] #9271(avdevice:open): Get color information from source device
FFmpeg
trac at avcodec.org
Tue Jun 1 14:43:04 EEST 2021
#9271: Get color information from source device
-------------------------------------+-------------------------------------
Reporter: Diederick | Owner: (none)
Niehorster |
Type: enhancement | Status: open
Priority: normal | Component: avdevice
Version: git-master | Resolution:
Keywords: dshow | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by Diederick Niehorster):
Seems i failed to attach the updated patch, sorry. I have attached a new
one where I also convert chroma location (one unknown to me there, DV PAL,
which is horizontally and vertically cosited: http://www.adamwilt.com/pix-
sampling.html, https://docs.microsoft.com/en-us/windows/win32/api/dxva2api
/ne-dxva2api-dxva2_videochromasubsampling).
I also added the "newer" color spaces/trcs. They are not in DirectShow,
one needs to use mediafoundation for those. Stupid since DirectShow isn't
going anywhere... I did note that the enum values provided by both
DXVA_VideoTransferFunction and MFVideoTransferFunction (and also
DXVA_VideoPrimaries and MFVideoPrimaries) match and that the bitfields in
DXVA_ExtendedFormat are sufficiently large to contain the additional
values in the MFVideoxxx enums. Interestingly, MS even presents example
code that wholesale plops the MFVideo values into a DXVA struct:
https://docs.microsoft.com/en-us/windows/win32/api/dxva2api/ns-dxva2api-
dxva2_videodesc. So perhaps thats unofficially supported, and maybe some
devices use it. I see it used in the wild in software at least:
https://github.com/Nevcairiel/LAVFilters/blob/ddef56ae155d436f4301346408f4fdba755197d6/decoder/LAVVideo/Media.cpp#L752.
So i have just included those values too, in the worst case they do
nothing. Can you check what i have added?
>> But also see here: https://docs.microsoft.com/en-
us/windows/win32/api/dxva2api/ne-dxva2api-dxva2_videoprimaries BT.470-2
System M; EBU 3212 (sic, non-existant 3212 spec, funny, should be 3213)
Yeah indeed, https://docs.microsoft.com/en-us/windows/win32/api/dxva2api
/ne-dxva2api-dxva2_videoprimaries seems to suggest it should be
AVCOL_PRI_BT470M, not AVCOL_PRI_BT470BG. But lets assume the docs are
wrong on that point too, besides what you pointed out?
I have also added determination of color space, using VideoTransferMatrix,
and falling back on a guess if VideoTransferMatrix is not known, but
VideoPrimaries is.
Lastly, the discovered info is now exposed through the stream's codecpars,
so it can actually be used.
Thanks for the help!
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9271#comment:4>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list