1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

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>
This commit is contained in:
Andreas Rheinhardt 2023-09-29 17:32:59 +02:00
parent 0c1103d4dc
commit 259e1d2bd7
8 changed files with 46 additions and 39 deletions

View File

@ -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");

View File

@ -1,5 +1,5 @@
dede1d72a28c7eb0a849acf230b08247 *tests/data/fate/matroska-avoid-negative-ts.matroska
973072 tests/data/fate/matroska-avoid-negative-ts.matroska
fb4e7a969ef65f61c4c45d5976188aa2 *tests/data/fate/matroska-avoid-negative-ts.matroska
973080 tests/data/fate/matroska-avoid-negative-ts.matroska
#extradata 0: 22, 0x2885037c
#tb 0: 1/1000
#media_type 0: video

View File

@ -1,5 +1,5 @@
156c5c615bee0c55e76275df8d84e505 *tests/data/fate/matroska-encoding-delay.matroska
961238 tests/data/fate/matroska-encoding-delay.matroska
604531e6d08cb35b2f3eec838ac45b80 *tests/data/fate/matroska-encoding-delay.matroska
961252 tests/data/fate/matroska-encoding-delay.matroska
#extradata 0: 22, 0x32ea0490
#tb 0: 1/1000
#media_type 0: video
@ -32,7 +32,7 @@ dts_time=-0.010000
duration=24
duration_time=0.024000
size=1152
pos=1255
pos=1263
flags=K__
[/PACKET]
[PACKET]
@ -45,7 +45,7 @@ dts_time=0.000000
duration=40
duration_time=0.040000
size=237628
pos=2415
pos=2423
flags=K__
[/PACKET]
[PACKET]
@ -58,7 +58,7 @@ dts_time=0.014000
duration=24
duration_time=0.024000
size=1152
pos=240050
pos=240058
flags=K__
[/PACKET]
[PACKET]
@ -71,7 +71,7 @@ dts_time=0.038000
duration=24
duration_time=0.024000
size=1152
pos=241225
pos=241233
flags=K__
[/PACKET]
[PACKET]
@ -84,7 +84,7 @@ dts_time=0.040000
duration=40
duration_time=0.040000
size=238066
pos=242385
pos=242393
flags=K__
[/PACKET]
[STREAM]

View File

@ -1,5 +1,5 @@
52e030428110a8c1b74c03c7ad31a6ca *tests/data/fate/matroska-mpegts-remux.matroska
6500 tests/data/fate/matroska-mpegts-remux.matroska
48fcc343d88d0ffaba9223150fb0a195 *tests/data/fate/matroska-mpegts-remux.matroska
6516 tests/data/fate/matroska-mpegts-remux.matroska
#tb 0: 1/1000
#media_type 0: audio
#codec_id 0: ac3

View File

@ -1,3 +1,3 @@
4fede420f36a21bbb3ae4e5d6a884267 *tests/data/lavf/lavf.mka
43572 tests/data/lavf/lavf.mka
b9c2d23dffba449cf1111f062b93c93f *tests/data/lavf/lavf.mka
43588 tests/data/lavf/lavf.mka
tests/data/lavf/lavf.mka CRC=0x3a1da17e

View File

@ -1,3 +1,3 @@
d5f719b715ad5eb6860c85f0d8202b8e *tests/data/lavf/lavf.mkv
320426 tests/data/lavf/lavf.mkv
6224bc0893bd0bb8a789e74bbd38c9c7 *tests/data/lavf/lavf.mkv
320440 tests/data/lavf/lavf.mkv
tests/data/lavf/lavf.mkv CRC=0xec6c3c68

View File

@ -1,3 +1,3 @@
7681b6ece94f20684838bcbba2458c58 *tests/data/lavf/lavf.mkv_attachment
472576 tests/data/lavf/lavf.mkv_attachment
05132b99d16128e552c1a6f1619be8b7 *tests/data/lavf/lavf.mkv_attachment
472590 tests/data/lavf/lavf.mkv_attachment
tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68

View File

@ -1,48 +1,48 @@
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 674 size: 208
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 682 size: 208
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret: 0 st: 0 flags:0 ts: 0.788000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret: 0 st: 0 flags:1 ts:-0.317000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret:-1 st: 1 flags:0 ts: 2.577000
ret: 0 st: 1 flags:1 ts: 1.471000
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size: 209
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320158 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146866 size: 27925
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret:-1 st: 0 flags:0 ts: 2.153000
ret: 0 st: 0 flags:1 ts: 1.048000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret: 0 st: 1 flags:0 ts:-0.058000
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 674 size: 208
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 682 size: 208
ret: 0 st: 1 flags:1 ts: 2.836000
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size: 209
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320158 size: 209
ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146866 size: 27925
ret: 0 st: 0 flags:0 ts:-0.482000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret: 0 st: 0 flags:1 ts: 2.413000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret:-1 st: 1 flags:0 ts: 1.307000
ret: 0 st: 1 flags:1 ts: 0.201000
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 674 size: 208
ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 682 size: 208
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret: 0 st: 0 flags:0 ts: 0.883000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292306 size: 27834
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292314 size: 27834
ret: 0 st: 0 flags:1 ts:-0.222000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837
ret:-1 st: 1 flags:0 ts: 2.672000
ret: 0 st: 1 flags:1 ts: 1.566000
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320147 size: 209
ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320158 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146858 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146866 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 890 size: 27837
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 898 size: 27837