aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/segment.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2011-10-13 11:51:07 +0200
committerLuca Barbato <lu_zero@gentoo.org>2011-10-13 11:51:07 +0200
commit13c99587511bfc35acf3b9427ef4d48ae5aec312 (patch)
tree5e4890d86bc34b32e882d67fc1711b536b2c8d32 /libavformat/segment.c
parent1786c7f844ee16462f61588d1dcaab6d7a2e6eb9 (diff)
downloadffmpeg-13c99587511bfc35acf3b9427ef4d48ae5aec312.tar.gz
segment: extend options
let set an alternate path for the segment files.
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r--libavformat/segment.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 41aceee826..91905cf35f 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -32,10 +32,10 @@
typedef struct {
const AVClass *class; /**< Class for private options. */
int number;
- char path[1024];
AVFormatContext *avf;
char *format; /**< Set by a private option. */
char *pattern; /**< Set by a private option. */
+ char *path; /**< Set by a private option. */
float time; /**< Set by a private option. */
int64_t offset_time;
int64_t recording_time;
@@ -96,7 +96,12 @@ static int seg_write_header(AVFormatContext *s)
seg->recording_time = seg->time*1000000;
seg->offset_time = 0;
- av_strlcpy(seg->path, "test", sizeof("test"));
+ if (!seg->path) {
+ char *t;
+ seg->path = strdup(s->filename);
+ t = rindex(seg->path, '.');
+ if (t) t = '\0';
+ }
oc = avformat_alloc_context();
@@ -184,10 +189,10 @@ static int seg_write_trailer(struct AVFormatContext *s)
#define OFFSET(x) offsetof(SegmentContext, x)
#define E AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "container_format", "container format used for the segments", OFFSET(format), FF_OPT_TYPE_STRING, {.str = "nut"}, 0, 0, E },
- { "segment_time", "segment lenght in seconds", OFFSET(time), FF_OPT_TYPE_FLOAT, {.dbl = 2}, 0, FLT_MAX, E },
+ { "container_format", "container format used for the segments", OFFSET(format), FF_OPT_TYPE_STRING, {.str = "nut"}, 0, 0, E },
+ { "segment_time", "segment lenght in seconds", OFFSET(time), FF_OPT_TYPE_FLOAT, {.dbl = 2}, 0, FLT_MAX, E },
{ "segment_pattern", "pattern to use in segment files", OFFSET(pattern),FF_OPT_TYPE_STRING, {.str = "%03d"}, 0, 0, E },
-
+ { "segment_basename", "basename to use in segment files", OFFSET(pattern),FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
{ NULL },
};