diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2011-10-10 18:32:24 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2011-10-12 17:03:53 +0200 |
commit | 1786c7f844ee16462f61588d1dcaab6d7a2e6eb9 (patch) | |
tree | 76c0f1cf415455a22b385451ba1a3f00d21b94b5 | |
parent | 82df8c39975e7a719b06a91f248b1b2a07244101 (diff) | |
download | ffmpeg-1786c7f844ee16462f61588d1dcaab6d7a2e6eb9.tar.gz |
segment: basic pattern support and playlist output
Yet another option half implemented, more will follow...
-rw-r--r-- | libavformat/segment.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index 624ce6fce6..41aceee826 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -35,6 +35,7 @@ typedef struct { char path[1024]; AVFormatContext *avf; char *format; /**< Set by a private option. */ + char *pattern; /**< Set by a private option. */ float time; /**< Set by a private option. */ int64_t offset_time; int64_t recording_time; @@ -49,7 +50,8 @@ static int segment_header(SegmentContext *s) av_strlcpy(oc->filename, s->path, sizeof(oc->filename)); - av_strlcatf(oc->filename, sizeof(oc->filename), "%03d", s->number++); + av_strlcatf(oc->filename, sizeof(oc->filename), + s->pattern, s->number++); if ((err = avio_open(&oc->pb, oc->filename, AVIO_FLAG_WRITE)) < 0) { return err; @@ -116,7 +118,8 @@ static int seg_write_header(AVFormatContext *s) av_strlcpy(oc->filename, seg->path, sizeof(oc->filename)); - av_strlcatf(oc->filename, sizeof(oc->filename), "%2d", seg->number++); + av_strlcatf(oc->filename, sizeof(oc->filename), + seg->pattern, seg->number++); if ((ret = avio_open(&oc->pb, oc->filename, AVIO_FLAG_WRITE)) < 0) { avformat_free_context(oc); @@ -130,6 +133,9 @@ static int seg_write_header(AVFormatContext *s) if (ret) avformat_free_context(oc); + avio_printf(s->pb, "%s\n", oc->filename); + avio_flush(s->pb); + return ret; } @@ -156,7 +162,8 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) avformat_free_context(oc); return ret; } - + avio_printf(s->pb, "%s\n", oc->filename); + avio_flush(s->pb); } ret = oc->oformat->write_packet(oc, pkt); @@ -178,7 +185,9 @@ static int seg_write_trailer(struct AVFormatContext *s) #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 }, + { "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 }, + { NULL }, }; |