[FFmpeg-devel] [PATCH v4 5/8] avcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio

Marton Balint cus at passwd.hu
Tue May 5 10:24:25 EEST 2020



On Tue, 5 May 2020, Andreas Rheinhardt wrote:

> Marton Balint:
>> Signed-off-by: Marton Balint <cus at passwd.hu>
>> ---
>>  Changelog                      |   1 +
>>  doc/bitstream_filters.texi     |  30 ++++++
>>  libavcodec/Makefile            |   1 +
>>  libavcodec/bitstream_filters.c |   1 +
>>  libavcodec/pcm_rechunk_bsf.c   | 220 +++++++++++++++++++++++++++++++++++++++++
>>  libavcodec/version.h           |   2 +-
>>  6 files changed, 254 insertions(+), 1 deletion(-)
>>  create mode 100644 libavcodec/pcm_rechunk_bsf.c
>>

[...]

>> +++ b/doc/bitstream_filters.texi
>> @@ -548,6 +548,36 @@ ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
>>  @section null
>>  This bitstream filter passes the packets through unchanged.
>> 
>> + at section pcm_rechunk
>> +
>> +Repacketize PCM audio to a fixed number of samples per packet or a fixed packet
>> +rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio
>> +filter,ffmpeg-filters} but works on audio packets instead of audio frames.
>> +
>> + at table @option
>> + at item nb_out_samples, n
>> +Set the number of samples per each output audio packet. The number is intended
>> +as the number of samples @emph{per each channel}. Default value is 1024.
>> +
>> + at item pad, p
>> +If set to 1, the filter will pad the last audio packet with silence, so that it
>> +will contain the same number of samples (or roughly the same number of samples,
>> +see @option{frame_rate}) as the previous ones. Default value is 1.
>> +
>> + at item frame_rate, r
>> +This option makes the filter output a fixed numer of packets per second instead
>
> numer

Fixed locally.

[...]

>> +            } else if (s->in_pkt->size > data_size) {
>> +                ret = av_packet_ref(pkt, s->in_pkt);
>> +                if (ret < 0)
>> +                    return ret;
>> +                pkt->size = data_size;
>
> I just wonder: Have you tried av_shrink_packet() and found out that it
> simply zeroes the data after the end of the packet without any regard to
> whether it is writable or not or did you simply just do it the way you
> do it here?

I always did it this way.

[...]

>> --- a/libavcodec/version.h
>> +++ b/libavcodec/version.h
>> @@ -28,7 +28,7 @@
>>  #include "libavutil/version.h"
>>
>>  #define LIBAVCODEC_VERSION_MAJOR  58
>> -#define LIBAVCODEC_VERSION_MINOR  82
>> +#define LIBAVCODEC_VERSION_MINOR  83
>>  #define LIBAVCODEC_VERSION_MICRO 100
>>
>>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>> 
> LGTM apart from that.

Thanks,

Marton


More information about the ffmpeg-devel mailing list