[FFmpeg-devel] [PATCH 3/9] avformat/daudenc: force 2000 sample packet size with a bsf

Stefano Sabatini stefasab at gmail.com
Wed Mar 6 16:24:32 EET 2024


On date Tuesday 2024-03-05 23:51:41 +0100, Marton Balint wrote:
> The samples I found all have 2000 sample packets, and by forcing the packet
> size with a bsf we could automagically make muxing work for packets containing
> more than 3640 samples.
> 
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
>  configure                     |  1 +
>  libavformat/daudenc.c         | 11 +++++------
>  tests/ref/fate/dcinema-encode | 31 +++++++++++--------------------
>  3 files changed, 17 insertions(+), 26 deletions(-)
> 
> diff --git a/configure b/configure
> index bbf1a70731..4ac8758a03 100755
> --- a/configure
> +++ b/configure
> @@ -3525,6 +3525,7 @@ caf_demuxer_select="iso_media"
>  caf_muxer_select="iso_media"
>  dash_muxer_select="mp4_muxer"
>  dash_demuxer_deps="libxml2"
> +daud_muxer_select="pcm_rechunk_bsf"
>  dirac_demuxer_select="dirac_parser"
>  dts_demuxer_select="dca_parser"
>  dtshd_demuxer_select="dca_parser"
> diff --git a/libavformat/daudenc.c b/libavformat/daudenc.c
> index 37c20618bd..a995838351 100644
> --- a/libavformat/daudenc.c
> +++ b/libavformat/daudenc.c
> @@ -25,6 +25,7 @@
>  static int daud_init(struct AVFormatContext *s)
>  {
>      AVCodecParameters *par = s->streams[0]->codecpar;
> +    int ret;
>  
>      if (par->ch_layout.nb_channels != 6) {
>          av_log(s, AV_LOG_ERROR,
> @@ -40,17 +41,15 @@ static int daud_init(struct AVFormatContext *s)
>          return AVERROR(EINVAL);
>      }
>  
> +    ret = ff_stream_add_bitstream_filter(s->streams[0], "pcm_rechunk", "n=2000:pad=0");
> +    if (ret < 0)
> +        return ret;
> +
>      return 0;
>  }

Cannot really comment about the implication of adding an automatic bsf
a the muxer level, but if this is acceptable probably you can also
simplify the doc/muxers/daud documentation (also I think we have a
ticket about this issue), since this lift the need to use setnsamples.

[...]


More information about the ffmpeg-devel mailing list