[FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Added a warning for incorrect segment name extension
Karthick J
kjeyapal at akamai.com
Fri May 4 09:32:21 EEST 2018
From: Karthick Jeyapal <kjeyapal at akamai.com>
Applicable only to webm output format.
By default all the segment filenames end with .m4s extension.
When someone chooses webm output format, we recommend they also override the relevant segment name options to end with .webm extension. This patch will issue a warning for he same.
---
libavformat/dashenc.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 412f074..bd374e2 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -177,6 +177,16 @@ static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filenam
}
}
+static int check_file_extension(const char *filename, const char *extension) {
+ char *dot;
+ if (!filename || !extension)
+ return -1;
+ dot = strrchr(filename, '.');
+ if (dot && !strcmp(dot + 1, extension))
+ return 0;
+ return -1;
+}
+
static void set_vp9_codec_str(AVFormatContext *s, AVCodecParameters *par,
AVRational *frame_rate, char *str, int size) {
VPCC vpcc;
@@ -967,6 +977,14 @@ static int dash_init(AVFormatContext *s)
if (c->segment_type == SEGMENT_TYPE_WEBM) {
snprintf(c->format_name, sizeof(c->format_name), "webm");
+ if ((!c->single_file && check_file_extension(c->init_seg_name, c->format_name) != 0) ||
+ (!c->single_file && check_file_extension(c->media_seg_name, c->format_name) != 0) ||
+ (c->single_file && check_file_extension(c->single_file_name, c->format_name) != 0)) {
+ av_log(s, AV_LOG_WARNING,
+ "One or many segment file names doesn't end with .webm. "
+ "Override -init_seg_name and/or -media_seg_name and/or "
+ "-single_file_name to end with the extension .webm\n");
+ }
} else if (c->segment_type == SEGMENT_TYPE_MP4) {
snprintf(c->format_name, sizeof(c->format_name), "mp4");
} else {
--
2.7.4
More information about the ffmpeg-devel
mailing list