[FFmpeg-trac] #10158(avcodec:new): bsf 264_metadata removes stuffing bytes from NAL units - destroys original bitrate

FFmpeg trac at avcodec.org
Thu Feb 2 18:18:02 EET 2023


#10158: bsf 264_metadata removes stuffing bytes from NAL units - destroys original
bitrate
-------------------------------------+-------------------------------------
             Reporter:  emcodem      |                    Owner:  (none)
                 Type:  enhancement  |                   Status:  new
             Priority:  normal       |                Component:  avcodec
              Version:  git-master   |               Resolution:
             Keywords:  bsf          |               Blocked By:
  264_metadata H264 filtering        |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Comment (by emcodem):

 Just for info, i had a talk to mkver about this. He proposed to just
 append zeros to the pkt instead of remembering the trailing bytes on a per
 NALu basis. I played with this about 2 weeks but it was really too hard
 for me to find a way add the trailing bytes per nalu. I was not able to
 store any size modification of the nalu or the packet in
 h264_metadata_update_fragment method (h264_metadata_bsf.c). I guess mostly
 because of my missing understanding about how the ref stuff works.

 Storing and restoring the trailing bytes on a per nalu base would probably
 be what everyone expects from the bsf (not actually modify anything else
 than it's instructed to modify) but for my usecase, it should be fine when
 i just append zeros to the packet which hopefully leads to the last IDR
 SLice NALu containing all the trailing bytes that have been removed by cbs
 and it's unit de and re-composition.

 What i do for testing (if it works of course in production :D) is a simple
 hack in cbs.c ff_cbs_write_packet method; remember the original pkt size
 before updating it and right before return 0:

 if (original_size > pkt->size)
   av_grow_packet(pkt,original_size - pkt->size);
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10158#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list