From: Marton Balint <cus@passwd.hu>
To: ffmpeg-devel@ffmpeg.org
Cc: Marton Balint <cus@passwd.hu>
Subject: [FFmpeg-devel] [PATCH v2 3/9] avformat/daudenc: force 2000 sample packet size with a bsf
Date: Fri, 8 Mar 2024 01:53:27 +0100
Message-ID: <20240308005333.12416-3-cus@passwd.hu> (raw)
In-Reply-To: <20240308005333.12416-1-cus@passwd.hu>
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@passwd.hu>
---
configure | 1 +
doc/muxers.texi | 16 +++++-----------
libavformat/daudenc.c | 11 +++++------
tests/ref/fate/dcinema-encode | 31 +++++++++++--------------------
4 files changed, 22 insertions(+), 37 deletions(-)
diff --git a/configure b/configure
index 05f8283af9..525902cf10 100755
--- a/configure
+++ b/configure
@@ -3517,6 +3517,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/doc/muxers.texi b/doc/muxers.texi
index 2104cc4a95..5b63eec552 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1387,23 +1387,17 @@ D-Cinema audio muxer.
It accepts a single 6-channels audio stream resampled at 96000 Hz
encoded with the @samp{pcm_24daud} codec.
-In addition, each muxed packet size must not be greater than 65535 bytes.
-
@subsection Example
Use @command{ffmpeg} to mux input audio to a @samp{5.1} channel layout
resampled at 96000Hz:
@example
-ffmpeg -i INPUT -af aresample=96000,pan=5.1,asetnsamples=3640 slow.302
-@end example
-
-The @samp{asetnsamples} filter is used to reduce the number of samples
-of each audio packet, with a size computed according to the formula:
-@example
-65535 / (@var{channels} * @var{encoded_sample_size}) = 655535 / (6 * 3) = 3640
+ffmpeg -i INPUT -af aresample=96000,pan=5.1 slow.302
@end example
-The @var{encoded_sample_size} = 3 factor is due to sample size of the
-@samp{pcm_24daud} encoder.
+For ffmpeg versions before 7.0 you might have to use the @samp{asetnsamples}
+filter to limit the muxed packet size, because this format does not support
+muxing packets larger than 65535 bytes (3640 samples). For newer ffmpeg
+versions audio is automatically packetized to 36000 byte (2000 sample) packets.
@section dv
DV (Digital Video) muxer.
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;
}
static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
- if (pkt->size > 65535) {
- av_log(s, AV_LOG_ERROR,
- "Packet size %d too large for s302m, must be <= 65535.\n",
- pkt->size);
- return AVERROR_INVALIDDATA;
- }
avio_wb16(s->pb, pkt->size);
avio_wb16(s->pb, 0x8010); // unknown
avio_write(s->pb, pkt->data, pkt->size);
diff --git a/tests/ref/fate/dcinema-encode b/tests/ref/fate/dcinema-encode
index 566d8f5091..8eec68901e 100644
--- a/tests/ref/fate/dcinema-encode
+++ b/tests/ref/fate/dcinema-encode
@@ -7,23 +7,14 @@
#sample_rate 0: 96000
#channel_layout_name 0: 5.1(side)
#stream#, dts, pts, duration, size, hash
-0, 0, 0, 1024, 12288, 848250bf0a20e324f60151629134ebd5
-0, 1024, 1024, 1024, 12288, cd3c42240d163a7e8835aeda9538f881
-0, 2048, 2048, 1024, 12288, f213a268e7ab62b53a4a4acb9b303dfb
-0, 3072, 3072, 1024, 12288, 14d4f3289b057394abc995bfea58912a
-0, 4096, 4096, 1024, 12288, a69453c3f0c23abfacb49b15aedc432a
-0, 5120, 5120, 1024, 12288, 6578b4a89b1fa4c8897b1376974b685d
-0, 6144, 6144, 1024, 12288, 4893b62addf1bea4c03c173f173aa082
-0, 7168, 7168, 1024, 12288, 992b70ea94c339dfda2d3514ac56c4a9
-0, 8192, 8192, 1024, 12288, 543f85139b77d30f8a46fd22d63e3ec7
-0, 9216, 9216, 1024, 12288, f52f825a2fe71f66786d5cd08487e271
-0, 10240, 10240, 1024, 12288, 50ac352cd73a803f52bfd393e610f83b
-0, 11264, 11264, 1024, 12288, e9475a9a8794b9b0b912b855bc05001f
-0, 12288, 12288, 1024, 12288, bf205474f44a381583b1f077ab8a9d0c
-0, 13312, 13312, 1024, 12288, f5655b1da90d808c7e05b4bda02233ca
-0, 14336, 14336, 1024, 12288, f8493bb74a270b50706cace85549c317
-0, 15360, 15360, 1024, 12288, c299fbbdcae68c97bca63210f6a1f7da
-0, 16384, 16384, 1024, 12288, 2f263932e3d4c419853e3369d70ef8d9
-0, 17408, 17408, 1024, 12288, 09862736b8a1a1ce5c8d23814fb054cd
-0, 18432, 18432, 1024, 12288, a99506638c5a3d84d3fa46ee2ba6c5ad
-0, 19456, 19456, 1024, 12288, ab6f04f68cfbf2c9a89e9641604b3a50
+0, 0, 0, 2000, 24000, f7b7be0b72225eeaa98ec0b2ea7ad34d
+0, 2000, 2000, 2000, 24000, c2d1d19b65f9ec1f7415bce5f2fbac8e
+0, 4000, 4000, 2000, 24000, 461979d3566bc69cd4d1911ed1559191
+0, 6000, 6000, 2000, 24000, 8fe028dc7a9e5512b6c24d33cf76c4f6
+0, 8000, 8000, 2000, 24000, 8f7be8b0e562cc56110ee5de6b97bec3
+0, 10000, 10000, 2000, 24000, 53f053a72010471bd1a150af0873ec4a
+0, 12000, 12000, 2000, 24000, adcfe7407ec384f65f384cfd85793963
+0, 14000, 14000, 2000, 24000, 4c541973df0e37a77eca16022d4d316c
+0, 16000, 16000, 2000, 24000, 362d410570c821384e3ba30a03cdc907
+0, 18000, 18000, 2000, 24000, 00643563149102a4834841217a85d284
+0, 20000, 20000, 480, 5760, 7401d92e7105169bef3deb34e53e9605
--
2.35.3
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-03-08 0:54 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 22:51 [FFmpeg-devel] [PATCH 1/9] avcodec/bsf/pcm_rechunk: reorder supported codec list Marton Balint
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 2/9] avcodec/bsf/pcm_rechunk: add some more supported PCM formats Marton Balint
2024-03-06 14:18 ` Stefano Sabatini
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 3/9] avformat/daudenc: force 2000 sample packet size with a bsf Marton Balint
2024-03-06 14:24 ` Stefano Sabatini
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 4/9] fate: make filter-channelsplit test use a fixed frame size Marton Balint
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 5/9] fate: use a fixed wav demux packet size for amix tests Marton Balint
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 6/9] fate: use atrim filter instead of -frames:a 20 for fate-filter-tremolo Marton Balint
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 7/9] avformat/pcm: use a common default packet size function for both wav and pcm Marton Balint
2024-03-06 20:37 ` Michael Niedermayer
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 8/9] avformat/pcm: remove max samples cap when calculating the default packet size Marton Balint
2024-03-05 22:51 ` [FFmpeg-devel] [PATCH 9/9] avformat/pcm: decrease target audio frame per sec to 10 Marton Balint
2024-03-06 13:47 ` [FFmpeg-devel] [PATCH 1/9] avcodec/bsf/pcm_rechunk: reorder supported codec list Stefano Sabatini
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 " Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 2/9] avcodec/bsf/pcm_rechunk: add some more supported PCM formats Marton Balint
2024-03-09 16:21 ` Stefano Sabatini
2024-03-08 0:53 ` Marton Balint [this message]
2024-03-09 16:23 ` [FFmpeg-devel] [PATCH v2 3/9] avformat/daudenc: force 2000 sample packet size with a bsf Stefano Sabatini
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 4/9] fate: make filter-channelsplit test use a fixed frame size Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 5/9] fate: use a fixed wav demux packet size for amix tests Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 6/9] fate: use atrim filter instead of -frames:a 20 for fate-filter-tremolo Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 7/9] avformat/pcm: factorize and improve determining the default packet size Marton Balint
2024-03-12 21:31 ` Marton Balint
2024-03-14 23:18 ` [FFmpeg-devel] [PATCH v3 " Marton Balint
2024-03-16 8:45 ` Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 8/9] avformat/wavdec: use ff_pcm_default_packet_size for " Marton Balint
2024-03-08 0:53 ` [FFmpeg-devel] [PATCH v2 9/9] avformat/pcm: decrease target audio frame per sec to 10 Marton Balint
2024-03-14 8:10 ` Tobias Rapp
2024-03-14 11:12 ` Paul B Mahol
2024-03-14 22:30 ` Marton Balint
2024-03-17 12:44 ` Paul B Mahol
2024-03-14 22:04 ` Marton Balint
2024-03-15 7:54 ` Tobias Rapp
2024-03-09 16:20 ` [FFmpeg-devel] [PATCH v2 1/9] avcodec/bsf/pcm_rechunk: reorder supported codec list Stefano Sabatini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240308005333.12416-3-cus@passwd.hu \
--to=cus@passwd.hu \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git