From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 3/8] avformat/matroskaenc: Only write DiscardPadding if nonzero
Date: Thu, 1 Sep 2022 23:23:58 +0200
Message-ID: <GV1P250MB0737C22CA51D9A60B85A85648F7B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB0737BEEBBFA5D0B1739C8D978F7B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
It is possible for the trailing padding to be zero, namely
e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used
for leading padding. Matroska supports this (use a negative
DiscardPadding), but players do not; at least Firefox refuses
to play such a file. So for now only write DiscardPadding
if it is trailing padding and nonzero.
The fate-matroska-ogg-opus-remux was affected by this.
(I wish CodecDelay would not exist and DiscardPadding would
be used to instead trim the codec delay away (with the Block
timestamp corresponding to the time at which the actually
output audio is output).)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/matroskaenc.c | 12 +++++++-----
tests/ref/fate/matroska-ogg-opus-remux | 10 +++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1256bdfe36..de6c993e6a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -2591,7 +2591,6 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv,
uint8_t *side_data;
size_t side_data_size;
uint64_t additional_id;
- int64_t discard_padding = 0;
unsigned track_number = track->track_num;
EBML_WRITER(9);
@@ -2619,10 +2618,13 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv,
AV_PKT_DATA_SKIP_SAMPLES,
&side_data_size);
if (side_data && side_data_size >= 10) {
- discard_padding = av_rescale_q(AV_RL32(side_data + 4),
- (AVRational){1, par->sample_rate},
- (AVRational){1, 1000000000});
- ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding);
+ int64_t discard_padding = AV_RL32(side_data + 4);
+ if (discard_padding) {
+ discard_padding = av_rescale_q(discard_padding,
+ (AVRational){1, par->sample_rate},
+ (AVRational){1, 1000000000});
+ ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding);
+ }
}
side_data = av_packet_get_side_data(pkt,
diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux
index b69c29df8e..1fa776ef01 100644
--- a/tests/ref/fate/matroska-ogg-opus-remux
+++ b/tests/ref/fate/matroska-ogg-opus-remux
@@ -1,5 +1,5 @@
-605e8e89efb3028e261dd10255c7f59a *tests/data/fate/matroska-ogg-opus-remux.matroska
-10207 tests/data/fate/matroska-ogg-opus-remux.matroska
+a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matroska
+10200 tests/data/fate/matroska-ogg-opus-remux.matroska
#extradata 0: 19, 0x399c0471
#tb 0: 1/1000
#media_type 0: audio
@@ -57,7 +57,7 @@ dts_time=-0.007000
duration=20
duration_time=0.020000
size=402
-pos=543
+pos=540
flags=K_
[/PACKET]
[PACKET]
@@ -70,7 +70,7 @@ dts_time=0.013000
duration=20
duration_time=0.020000
size=216
-pos=956
+pos=949
flags=K_
[/PACKET]
[PACKET]
@@ -83,7 +83,7 @@ dts_time=0.033000
duration=20
duration_time=0.020000
size=215
-pos=1179
+pos=1172
flags=K_
[/PACKET]
[STREAM]
--
2.34.1
_______________________________________________
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:[~2022-09-01 21:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 20:38 [FFmpeg-devel] [PATCH 1/8] fftools/ffprobe: Report initial and trailing padding Andreas Rheinhardt
2022-09-01 21:23 ` [FFmpeg-devel] [PATCH 2/8] fate/matroska: Add tests for muxing with initial_padding Andreas Rheinhardt
2022-09-01 21:23 ` Andreas Rheinhardt [this message]
2022-09-01 21:23 ` [FFmpeg-devel] [PATCH 4/8] avformat/matroskaenc: Don't override samplerate for CodecDelay Andreas Rheinhardt
2022-09-01 21:24 ` [FFmpeg-devel] [PATCH 5/8] avformat/matroskaenc: Actually apply timestamp offset for Opus Andreas Rheinhardt
2022-09-01 21:24 ` [FFmpeg-devel] [PATCH 6/8] avformat/mux: Allow muxers to set custom min timestamp Andreas Rheinhardt
2022-09-01 21:24 ` [FFmpeg-devel] [PATCH 7/8] avformat/matroskaenc: Use " Andreas Rheinhardt
2022-09-01 21:24 ` [FFmpeg-devel] [PATCH 8/8] avformat/matroskaenc: Write CodecDelay for codecs != Opus Andreas Rheinhardt
2022-09-04 22:52 ` [FFmpeg-devel] [PATCH 1/8] fftools/ffprobe: Report initial and trailing padding Andreas Rheinhardt
2022-09-06 7:55 ` Anton Khirnov
2022-09-06 9:31 ` Andreas Rheinhardt
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=GV1P250MB0737C22CA51D9A60B85A85648F7B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--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