@@ -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 ) {
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@gmail.com> --- libavformat/matroskaenc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)