Prevent an assert and a segfault.
---
I'm not 100% happy about the fallback.
libavformat/movenc.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index ef03857..66751b6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1239,11 +1239,12 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack
*track)
const char *hdlr, *descr = NULL, *hdlr_type = NULL;
int64_t pos = avio_tell(pb);
- if (!track) { /* no media --> data handler */
- hdlr = "dhlr";
- hdlr_type = "url ";
- descr = "DataHandler";
- } else {
+ /* no media --> data handler */
+ hdlr = "dhlr";
+ hdlr_type = "url ";
+ descr = "DataHandler";
+
+ if (track) {
hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
hdlr_type = "vide";
@@ -1258,6 +1259,18 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack
*track)
} else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {
hdlr_type = "hint";
descr = "HintHandler";
+ } else if (track->enc->codec_tag == MKTAG('t','m','c','d')) {
+ hdlr_type = "tmcd";
+ descr = "TimeCodeHandler";
+ } else {
+ char tag_buf[32];
+ av_get_codec_tag_string(tag_buf, sizeof(tag_buf),
+ track->enc->codec_tag);
+
+ av_log(track->enc, AV_LOG_WARNING,
+ "Unknown hldr_type for %s / 0x%04X, writing dummy values\n",
+ tag_buf, track->enc->codec_tag);
+ return 0;
}
}
@@ -1640,7 +1653,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb,
MOVMuxContext *mov)
int version;
for (i = 0; i < mov->nb_streams; i++) {
- if (mov->tracks[i].entry > 0) {
+ if (mov->tracks[i].entry > 0 && mov->tracks[i].timescale) {
max_track_len_temp = av_rescale_rnd(mov->tracks[i].track_duration,
MOV_TIMESCALE,
mov->tracks[i].timescale,
@@ -3126,6 +3139,8 @@ static int mov_write_header(AVFormatContext *s)
}
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->codec->time_base.den;
+ } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ track->timescale = st->codec->time_base.den;
}
if (!track->height)
track->height = st->codec->height;
--
1.8.3.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel