aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/argo_asf.c
diff options
context:
space:
mode:
authorZane van Iperen <zane@zanevaniperen.com>2020-08-08 09:44:48 +1000
committerZane van Iperen <zane@zanevaniperen.com>2020-08-11 08:50:27 +1000
commitd2f42b9be1a3c996c02c10022935bf6135f5bc88 (patch)
tree05cd6d8a500eadcd0176bab644929c6295c63f12 /libavformat/argo_asf.c
parenta3a4591868f86663e8aec2026e5bdc8e71fb16b6 (diff)
downloadffmpeg-d2f42b9be1a3c996c02c10022935bf6135f5bc88.tar.gz
avformat/argo_asf: strip file extension from name
Only when the user hasn't manually specified one. Matches the original files more closely. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Diffstat (limited to 'libavformat/argo_asf.c')
-rw-r--r--libavformat/argo_asf.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 577b9d9c01..37ad2bf5e9 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -329,10 +329,24 @@ static int argo_asf_write_header(AVFormatContext *s)
fhdr.version_minor = (uint16_t)ctx->version_minor;
fhdr.num_chunks = 1;
fhdr.chunk_offset = ASF_FILE_HEADER_SIZE;
- if (ctx->name)
+ /*
+ * If the user specified a name, use it as is. Otherwise take the
+ * basename and lop off the extension (if any).
+ */
+ if (ctx->name) {
strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
- else
- strncpy(fhdr.name, av_basename(s->url), sizeof(fhdr.name));
+ } else {
+ const char *start = av_basename(s->url);
+ const char *end = strrchr(start, '.');
+ size_t len;
+
+ if(end)
+ len = end - start;
+ else
+ len = strlen(start);
+
+ memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name)));
+ }
chdr.num_blocks = 0;
chdr.num_samples = ASF_SAMPLE_COUNT;