[FFmpeg-trac] #7708(avcodec:new): avcodec_receive_frame - get number of bytes consumed

FFmpeg trac at avcodec.org
Wed Jan 30 12:46:37 EET 2019


#7708: avcodec_receive_frame - get number of bytes consumed
-------------------------------------+-------------------------------------
             Reporter:  jannis_wth   |                     Type:
               Status:  new          |  enhancement
            Component:  avcodec      |                 Priority:  normal
             Keywords:               |                  Version:
             Blocking:               |  unspecified
Analyzed by developer:  0            |               Blocked By:
                                     |  Reproduced by developer:  0
-------------------------------------+-------------------------------------
 There are use cases in which we don't know the exact size of the packet we
 want to decode. For example is if we try to recover a broken mp4, which
 misses its moov atom.
 With ffmpeg it was possible to get the unknown size by looking at how many
 bytes 'avcodec_decode_audio4' consumed, assuming it's an audio packet.
 However 'avcodec_decode_audio4' is now deprecated, and the new
 send/receive API is recommended:
 [https://www.ffmpeg.org/doxygen/4.1/group__lavc__encdec.html]

 The problem is that there seems to be no way to get the number of bytes
 consumed from the packet using this new (or any other non deprecated) API.
 Is this correct? If so, making this number available would be as easy as
 adding following function, provided the user stores the previous size:
 {{{
 int av_get_internal_pkt_size(AVCodecContext *avctx)
 {
     return avctx->internal->buffer_pkt->size;
 }
 }}}
 I understand that this might be an anti-pattern, but since tools like
 ponchio/untrunc depend on this kind of feature I think it would be a shame
 not to add it!


 One additinal Question:
 If we don't have the moov Atom, we have to gues which codec matches the
 current position in the mdat. For example some codecs start their raw
 packets with always the same sequence of bytes, but others codecs are
 harder to match.
 Is there any functionality in ffmpeg which would help deciding which codec
 a given stream of bytes belongs to? Functions like 'av_probe_input_buffer'
 seem to ''not'' match this usecase, is this right?

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7708>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list