[FFmpeg-devel] [PATCH] libavformat/segment.c cut at clocktime
Michael Niedermayer
michaelni at gmx.at
Mon Jul 7 20:52:26 CEST 2014
On Fri, Jul 04, 2014 at 06:57:32PM +0200, Deti Fliegl wrote:
> On 04.07.14 17:27, Stefano Sabatini wrote:
> > Consistency edit:
> Applied.
> > why do you think there is an integer overflow here?
> because I forgot a type cast of the struct tm values.
>
> > Ideally, use localtime_r since this is not thread-safe, see the
> > ifdeffery as used in other parts of the code, for example
> > libavcodec/jacobsubdec.c.
> Done.
>
> New version attached.
>
> Deti
> doc/muxers.texi | 10 ++++++++++
> libavformat/segment.c | 30 ++++++++++++++++++++++++++++--
> 2 files changed, 38 insertions(+), 2 deletions(-)
> 0e4537f28c2d358c27477a06bd8cfa1cc208036b 0001-Finalized-segmenter-code.patch
> From f3fcfe47b4be1f10d7ed42802cabc59635a6bedb Mon Sep 17 00:00:00 2001
> From: Deti fliegl <fliegl at baycom.de>
> Date: Fri, 4 Jul 2014 18:52:27 +0200
> Subject: [PATCH] Finalized segmenter code
>
> Signed-off-by: Deti fliegl <fliegl at baycom.de>
> ---
> doc/muxers.texi | 10 ++++++++++
> libavformat/segment.c | 30 ++++++++++++++++++++++++++++--
> 2 files changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index da7f186..dc2a08b 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -879,6 +879,16 @@ Note that splitting may not be accurate, unless you force the
> reference stream key-frames at the given time. See the introductory
> notice and the examples below.
>
> + at item segment_atclocktime @var{1|0}
> +If set to "1" split at regular clock time intervals starting from 00:00
> +o'clock. The @var{time} value specified in @option{segment_time} is
> +used for setting the length of the splitting interval.
> +
> +For example with @option{segment_time} set to "900" this makes it possible
> +to create files at 12:00 o'clock, 12:15, 12:30, etc.
> +
> +Default value is "0".
> +
> @item segment_time_delta @var{delta}
> Specify the accuracy time when selecting the start time for a
> segment, expressed as a duration specification. Default value is "0".
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index fe84f27..1e4416b 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -27,6 +27,8 @@
> /* #define DEBUG */
>
> #include <float.h>
> +#include <time.h>
> +#include <sys/time.h>
>
> #include "avformat.h"
> #include "internal.h"
> @@ -73,6 +75,12 @@ typedef struct {
> char *list; ///< filename for the segment list file
> int list_flags; ///< flags affecting list generation
> int list_size; ///< number of entries for the segment list file
> +
> + int use_clocktime; ///< flag to cut segments at regular clock time
> + int64_t last_val; ///< remember last time for wrap around detection
> + int64_t last_cut; ///< remember last cut
> + int cut_pending;
> +
> char *entry_prefix; ///< prefix to add to list entry filenames
> ListType list_type; ///< set the list type
> AVIOContext *list_pb; ///< list file put-byte context
> @@ -668,6 +676,10 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
> int64_t end_pts = INT64_MAX, offset;
> int start_frame = INT_MAX;
> int ret;
> + struct tm ti;
> + struct timeval now;
> + int64_t usecs;
> + int64_t wrapped_val;
>
> if (seg->times) {
> end_pts = seg->segment_count < seg->nb_times ?
> @@ -676,7 +688,19 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
> start_frame = seg->segment_count <= seg->nb_frames ?
> seg->frames[seg->segment_count] : INT_MAX;
> } else {
> - end_pts = seg->time * (seg->segment_count+1);
> + if (seg->use_clocktime) {
> + gettimeofday(&now, NULL);
> + localtime_r(&now.tv_sec, &ti);
this either needs to be under a HAVE_LOCALTIME_R check or some other
function like av_gettime() has to be used
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140707/53d80b29/attachment.asc>
More information about the ffmpeg-devel
mailing list