diff mbox series

[FFmpeg-devel,v2,3/3] avformat/argo_asf: use title metadata when muxing

Message ID 20211012110224.639056-3-zane@zanevaniperen.com
State Accepted
Commit 5d16660598dd9409c1028204cac3a966a939b719
Headers show
Series [FFmpeg-devel,v2,1/3] avformat/argo_asf: cleanup and NULL-terminate name field in header | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Zane van Iperen Oct. 12, 2021, 11:02 a.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/argo_asf.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 740680ece1..2b3569ebc3 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -358,14 +358,22 @@  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;