diff mbox series

[FFmpeg-devel,14/20] avformat/matroskaenc: Warn that WebM doesn't support Attachments

Message ID 20200405155928.9323-15-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series Matroska muxer patches
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt April 5, 2020, 3:59 p.m. UTC
As WebM doesn't support Attachments, the Matroska muxer drops them when
in WebM mode. This happened silently until this commit which adds a
warning for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroskaenc.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index acac3828f2..1b9ea45bc0 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1735,12 +1735,6 @@  static int mkv_write_header(AVFormatContext *s)
     int ret, i, version = 2;
     int64_t creation_time;
 
-    if (!strcmp(s->oformat->name, "webm")) {
-        mkv->mode      = MODE_WEBM;
-        mkv->write_crc = 0;
-    } else
-        mkv->mode = MODE_MATROSKAv2;
-
     if (mkv->mode != MODE_WEBM ||
         av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
         av_dict_get(s->metadata, "alpha_mode", NULL, 0))
@@ -2614,6 +2608,12 @@  static int mkv_init(struct AVFormatContext *s)
         s->internal->avoid_negative_ts_use_pts = 1;
     }
 
+    if (!strcmp(s->oformat->name, "webm")) {
+        mkv->mode      = MODE_WEBM;
+        mkv->write_crc = 0;
+    } else
+        mkv->mode = MODE_MATROSKAv2;
+
     mkv->tracks = av_mallocz_array(s->nb_streams, sizeof(*mkv->tracks));
     if (!mkv->tracks) {
         return AVERROR(ENOMEM);
@@ -2640,8 +2640,13 @@  static int mkv_init(struct AVFormatContext *s)
         // ms precision is the de-facto standard timescale for mkv files
         avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
 
-        if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
+            if (mkv->mode == MODE_WEBM) {
+                av_log(s, AV_LOG_WARNING, "Stream %d will be ignored "
+                       "as WebM doesn't support attachments.\n", i);
+            }
             continue;
+        }
 
         nb_tracks++;
         track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks;