[FFmpeg-devel] [PATCH] ffserver: fix seeking with ?date=...
Stefano Sabatini
stefasab at gmail.com
Fri Oct 5 18:19:16 CEST 2012
On date Friday 2012-10-05 16:49:20 +0200, Clément Bœsch encoded:
> From: Clément Bœsch <clement.boesch at smartjog.com>
>
> Regression since 5f847bf61dca1fd1a2f65a2f56c9a99d1cb716ab.
Nit: add a more verbose description regarding the introduced
regression.
> ---
> ffmpeg_opt.c | 5 ++++-
> libavformat/ffm.h | 1 +
> libavformat/ffmenc.c | 10 ++++++++--
> 3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index bce66f8..323ae8b 100644
> --- a/ffmpeg_opt.c
> +++ b/ffmpeg_opt.c
> @@ -1368,8 +1368,11 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
> choose_pixel_fmt(st, codec, st->codec->pix_fmt);
> }
>
> + /* ffserver seeking with date=... needs a date reference */
> + err = parse_option(o, "metadata", "creation_time=now", options);
> +
> avformat_close_input(&ic);
> - return 0;
> + return err;
> }
>
> static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
> diff --git a/libavformat/ffm.h b/libavformat/ffm.h
> index 04f19cc..4940235 100644
> --- a/libavformat/ffm.h
> +++ b/libavformat/ffm.h
> @@ -54,6 +54,7 @@ typedef struct FFMContext {
> int64_t dts;
> uint8_t *packet_ptr, *packet_end;
> uint8_t packet[FFM_PACKET_SIZE];
> + int64_t start_time;
> } FFMContext;
>
> int64_t ffm_read_write_index(int fd);
> diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
> index 1aa4775..8c60b5d 100644
> --- a/libavformat/ffmenc.c
> +++ b/libavformat/ffmenc.c
> @@ -22,6 +22,7 @@
> #include "libavutil/intreadwrite.h"
> #include "libavutil/intfloat.h"
> #include "libavutil/avassert.h"
> +#include "libavutil/parseutils.h"
> #include "avformat.h"
> #include "internal.h"
> #include "ffm.h"
> @@ -85,11 +86,15 @@ static void ffm_write_data(AVFormatContext *s,
> static int ffm_write_header(AVFormatContext *s)
> {
> FFMContext *ffm = s->priv_data;
> + AVDictionaryEntry *t;
> AVStream *st;
> AVIOContext *pb = s->pb;
> AVCodecContext *codec;
> int bit_rate, i;
>
> + if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
> + av_parse_time(&ffm->start_time, t->value, 0);
> +
Missing error check.
> ffm->packet_size = FFM_PACKET_SIZE;
>
> /* header */
> @@ -199,11 +204,12 @@ static int ffm_write_header(AVFormatContext *s)
>
> static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
> {
> + FFMContext *ffm = s->priv_data;
> int64_t dts;
> uint8_t header[FRAME_HEADER_SIZE+4];
> int header_size = FRAME_HEADER_SIZE;
>
> - dts = pkt->dts;
> + dts = ffm->start_time + pkt->dts;
Unrelated: do you have idea why dts and not pts?
> /* packet size & key_frame */
> header[0] = pkt->stream_index;
> header[1] = 0;
> @@ -211,7 +217,7 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
> header[1] |= FLAG_KEY_FRAME;
> AV_WB24(header+2, pkt->size);
> AV_WB24(header+5, pkt->duration);
> - AV_WB64(header+8, pkt->pts);
> + AV_WB64(header+8, ffm->start_time + pkt->pts);
> if (pkt->pts != pkt->dts) {
> header[1] |= FLAG_DTS;
> AV_WB32(header+16, pkt->pts - pkt->dts);
Looks OK otherwise if tested, thanks.
--
FFmpeg = Fundamental Fierce Marvellous Philosophical Enchanting Governor
More information about the ffmpeg-devel
mailing list