[FFmpeg-devel] [PATCH 17/23] avformat/matroskaenc: Allow empty filename for attachments

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Wed Nov 6 04:49:16 EET 2019


The EBML as well as the Matroska specifications allow empty strings, yet
the Matroska muxer enforced the requirement that a filename tag exists
for attachments and errored out if it didn't. This has been changed: In
the absence of a filename, an empty string is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/matroskaenc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f84e50f94e..e64e1e1036 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1677,6 +1677,7 @@ static int mkv_write_attachments(AVFormatContext *s)
         ebml_master attached_file;
         AVDictionaryEntry *t;
         const char *mimetype = NULL;
+        const char *filename;
 
         if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
             continue;
@@ -1685,11 +1686,11 @@ static int mkv_write_attachments(AVFormatContext *s)
 
         if (t = av_dict_get(st->metadata, "title", NULL, 0))
             put_ebml_string(dyn_cp, MATROSKA_ID_FILEDESC, t->value);
-        if (!(t = av_dict_get(st->metadata, "filename", NULL, 0))) {
-            av_log(s, AV_LOG_ERROR, "Attachment stream %d has no filename tag.\n", i);
-            return AVERROR(EINVAL);
-        }
-        put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, t->value);
+        if (t = av_dict_get(st->metadata, "filename", NULL, 0)) {
+            filename = t->value;
+        } else
+            filename = "";
+        put_ebml_string(dyn_cp, MATROSKA_ID_FILENAME, filename);
         if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
             mimetype = t->value;
         else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
-- 
2.20.1



More information about the ffmpeg-devel mailing list