@@ -302,10 +302,25 @@ static int argo_asf_write_header(AVFormatContext *s)
/* version_{major,minor} set by options. */
ctx->fhdr.num_chunks = 1;
ctx->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(ctx->fhdr.name, ctx->name, FF_ARRAY_ELEMS(ctx->fhdr.name));
- else
- strncpy(ctx->fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(ctx->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(ctx->fhdr.name, start, FFMIN(len, FF_ARRAY_ELEMS(ctx->fhdr.name)));
+ }
ctx->ckhdr.num_blocks = 0;
ctx->ckhdr.num_samples = ASF_SAMPLE_COUNT;
Only when the user hasn't manually specified one. Matches the original files more closely. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> --- libavformat/argo_asf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)