Signed-off-by: Zane van Iperen <z...@zanevaniperen.com>
---
 libavformat/argo_asf.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index f729a393ad..1171d9b7a7 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -361,18 +361,27 @@ static int argo_asf_write_header(AVFormatContext *s)
         .num_chunks    = 1,
         .chunk_offset  = ASF_FILE_HEADER_SIZE
     };
-    const char *name = ctx->name, *end;
+    AVDictionaryEntry *t;
+    const char *name, *end;
     size_t len;
 
     /*
-     * If the user specified a name, use it as is. Otherwise take the
-     * basename and lop off the extension (if any).
+     * If the user specified a name, use it as is. Otherwise,
+     * try to use metadata (if present), then fall back to the
+     * filename (minus extension).
      */
-    if (name || !(end = strrchr((name = av_basename(s->url)), '.'))) {
+    if (ctx->name) {
+        name = ctx->name;
+        len  = strlen(ctx->name);
+    } else if ((t = av_dict_get(s->metadata, "title", NULL, 0))) {
+        name = t->value;
+        len  = strlen(t->value);
+    } else if (!(end = strrchr((name = av_basename(s->url)), '.'))) {
         len = strlen(name);
     } else {
         len = end - name;
     }
+
     memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name)));
 
     chdr.num_blocks    = 0;
-- 
2.31.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to