[FFmpeg-devel] [PATCH 3/3] lavf/srtenc: ignore invalid timed packets instead of failing.
Clément Bœsch
ubitux at gmail.com
Fri Nov 9 00:13:59 CET 2012
On Sun, Oct 28, 2012 at 08:38:52PM +0100, Clément Bœsch wrote:
> On Thu, Oct 25, 2012 at 07:03:24PM +0200, Clément Bœsch wrote:
> > This way we don't abort in the middle of remuxing, just warn about an
> > event ignored. The index increment is moved to make sure the output
> > numbers still make sense.
> > ---
> > libavformat/srtenc.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/srtenc.c b/libavformat/srtenc.c
> > index 8338238..9c8c3d9 100644
> > --- a/libavformat/srtenc.c
> > +++ b/libavformat/srtenc.c
> > @@ -35,6 +35,8 @@ typedef struct SRTContext{
> >
> > static int srt_write_header(AVFormatContext *avf)
> > {
> > + SRTContext *srt = avf->priv_data;
> > +
> > if (avf->nb_streams != 1 ||
> > avf->streams[0]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
> > av_log(avf, AV_LOG_ERROR,
> > @@ -50,6 +52,7 @@ static int srt_write_header(AVFormatContext *avf)
> > return AVERROR(EINVAL);
> > }
> > avpriv_set_pts_info(avf->streams[0], 64, 1, 1000);
> > + srt->index = 1;
> > return 0;
> > }
> >
> > @@ -58,7 +61,6 @@ static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)
> > SRTContext *srt = avf->priv_data;
> > int write_ts = avf->streams[0]->codec->codec_id != AV_CODEC_ID_SRT;
> >
> > - srt->index++;
> > if (write_ts) {
> > int64_t s = pkt->pts, e, d = pkt->duration;
> >
> > @@ -66,8 +68,9 @@ static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)
> > /* For backward compatibility, fallback to convergence_duration. */
> > d = pkt->convergence_duration;
> > if (s == AV_NOPTS_VALUE || d < 0) {
> > - av_log(avf, AV_LOG_ERROR, "Insufficient timestamps.\n");
> > - return AVERROR(EINVAL);
> > + av_log(avf, AV_LOG_WARNING,
> > + "Insufficient timestamps in event number %d.\n", srt->index);
> > + return 0;
> > }
> > e = s + d;
> > avio_printf(avf->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",
> > @@ -81,6 +84,7 @@ static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)
> > if (write_ts)
> > avio_write(avf->pb, "\n\n", 2);
> > avio_flush(avf->pb);
> > + srt->index++;
> > return 0;
> > }
>
> ping
>
I'll push this tomorrow if I see no other comment.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121109/caf3d3f2/attachment.asc>
More information about the ffmpeg-devel
mailing list