aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-09-29 17:32:59 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-10-02 12:22:20 +0200
commit259e1d2bd7edd17e6cd64f0fb2b0e66fe49c846a (patch)
tree108f34bde0b26db47a489f669f5877c294b145c6 /libavformat
parent0c1103d4dc4c6af56b09df6d4ecb252606666d7b (diff)
downloadffmpeg-259e1d2bd7edd17e6cd64f0fb2b0e66fe49c846a.tar.gz
avformat/matroskaenc: Write default duration for audio
This is easily possible for those codecs with a fixed frame-size (in samples). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/matroskaenc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 9286932a08..9d1c8946cd 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -61,6 +61,7 @@
#include "libavcodec/av1.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/codec_desc.h"
+#include "libavcodec/codec_par.h"
#include "libavcodec/defs.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
@@ -1926,6 +1927,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
switch (par->codec_type) {
AVRational frame_rate;
+ int audio_frame_samples;
+
case AVMEDIA_TYPE_VIDEO:
mkv->have_video = 1;
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
@@ -1991,6 +1994,10 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO);
+ audio_frame_samples = av_get_audio_frame_duration2(par, 0);
+ if (audio_frame_samples)
+ mkv_write_default_duration(track, pb, (AVRational){ audio_frame_samples,
+ par->sample_rate });
if (!native_id)
// no mkv-specific ID, use ACM mode
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");