[FFmpeg-user] Remove "DOVI configuration record" from h265 streams

Oliver Fromme oliver at fromme.com
Thu Jun 27 20:01:00 EEST 2024


Oliver Fromme wrote:
 > I've got another question about HDR re-encoding.
 > 
 > There are "hybrid" files that contain both Dolby Vision (DoVi) and
 > HDR10 (or even HDR10+) metadata at the same time.  I don't care about
 > the DoVi metadata, so I just remove it.  I only encode with the HDR10
 > metadata.  The resulting files play fine with mpv.
 > 
 > However, when I look at the resulting file (h265 within mkv) with
 > ffprobe, it still displays a side_data record for the video stream
 > that has the type "DOVI configuration record".  Excerpt of ffprobe
 > for the video stream (JSON format):
 > 
 >   'streams': [
 >     {
 >       [...]
 >       'codec_long_name': 'H.265 / HEVC (High Efficiency Video Coding)'
 >       [...]
 >       'side_data_list': [
 >         {
 >           'bl_present_flag': 1
 >           'dv_bl_signal_compatibility_id': 1
 >           'dv_level': 6
 >           'dv_profile': 8
 >           'dv_version_major': 1
 >           'dv_version_minor': 0
 >           'el_present_flag': 0
 >           'rpu_present_flag': 1
 >           'side_data_type': 'DOVI configuration record'
 >         }
 >       ]
 >       [...]
 >     }
 > 
 > The video is definitely *not* Dolby Vision, it does not contain any
 > BL or RPU data or anything else.  Therefore I would like to get rid
 > of that "DOVI configuration record" because it might confuse certain
 > players.
 > 
 > How to do that?
 > 
 > During my research I noticed that ffmpeg has a multimedia filter
 > named "sidedata".  It's supposed to be able to delete side data from
 > frames.  However, the documentation (manual page) refers to the
 > AVFrameSideDataType enum in libavutil/frame.h that conatins all
 > AV_FRAME_DATA_* values.  But that enum does not contain an entry for
 > DoVi configuration records.  So it must be something else.

Replying to myself ...

I searched the ffmpeg source code up and down, and came to the
conclusion that there is no way to prevent it from copying that
record to the target file.

So I made a quick hack and patched libavformat/matroskaenc.c
where it calls av_packet_side_data_get(..., AV_PKT_DATA_DOVI_CONF).
I simply removed the ``if (!sd)'' line, so it never writes such
data.  A better solution would be to make that behaviour configurable
by an option, of course.

It's also worth noting that libx265 offers an option called
"dolby-vision-profile".  The default is 0, which means disabled.
This setting can be passed with ffmpeg's -x265-params option.
I guess it would make sense to write the "DOVI configuration record"
*only* if the user specified a non-zero dolby-vision-profile.

Best regards
Oliver


More information about the ffmpeg-user mailing list