aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-01 15:02:44 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-05-01 15:56:38 +0200
commit82e4f39883932c1b1e5c7792a1be12dec6ab603d (patch)
tree92de9b08e68730d7a31802e99548f48bac1aed1a
parent154d80eae70b73c683e70a157e73173aabb26a58 (diff)
parenta1aa37dd0b96710d4a17718198a3f56aea2040c1 (diff)
downloadffmpeg-82e4f39883932c1b1e5c7792a1be12dec6ab603d.tar.gz
Merge commit 'a1aa37dd0b96710d4a17718198a3f56aea2040c1'
* commit 'a1aa37dd0b96710d4a17718198a3f56aea2040c1': matroskaenc: write CodecDelay Conflicts: libavformat/matroskaenc.c tests/ref/lavf/mkv tests/ref/seek/lavf-mkv This is largely not merged as it causes assertion failures and av sync errors Further investigation of this is warranted if the changes are found to fix/improve something in relation to d92b1b1babe69268971863649c225e1747358a74 See: d92b1b1babe69268971863649c225e1747358a74 Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/matroskaenc.c17
-rw-r--r--libavformat/version.h2
2 files changed, 13 insertions, 6 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 62e2d57ab9..e5e61169dd 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -85,6 +85,7 @@ typedef struct {
typedef struct {
int write_dts;
int has_cue;
+ int64_t ts_offset;
} mkv_track;
#define MODE_MATROSKAv2 0x01
@@ -694,13 +695,17 @@ static int mkv_write_tracks(AVFormatContext *s)
}
}
+ if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->delay && codec->codec_id == AV_CODEC_ID_OPUS) {
+// mkv->tracks[i].ts_offset = av_rescale_q(codec->delay,
+// (AVRational){ 1, codec->sample_rate },
+// st->time_base);
+
+ put_ebml_uint(pb, MATROSKA_ID_CODECDELAY,
+ av_rescale_q(codec->delay, (AVRational){ 1, codec->sample_rate },
+ (AVRational){ 1, 1000000000 }));
+ }
if (codec->codec_id == AV_CODEC_ID_OPUS) {
- uint64_t codec_delay =av_rescale_q(codec->delay,
- (AVRational){1, codec->sample_rate},
- (AVRational){1, 1000000000});
- put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codec_delay);
put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
-
}
if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 ||
@@ -1549,6 +1554,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "Can't write packet with unknown timestamp\n");
return AVERROR(EINVAL);
}
+ ts += mkv->tracks[pkt->stream_index].ts_offset;
if (!s->pb->seekable) {
if (!mkv->dyn_bc) {
@@ -1614,6 +1620,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
cluster_time = pkt->dts - mkv->cluster_pts;
else
cluster_time = pkt->pts - mkv->cluster_pts;
+ cluster_time += mkv->tracks[pkt->stream_index].ts_offset;
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
// after 4k and on a keyframe
diff --git a/libavformat/version.h b/libavformat/version.h
index cbdb6b3aa3..8905fb5b25 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 37
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MICRO 102
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \