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;



        if (d <= 0)

            /* 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);

        }

        e = s + d;

        avio_printf(avf->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",

                       srt->index,

                       (int)(s / 3600000),      (int)(s / 60000) % 60,

                       (int)(s /    1000) % 60, (int)(s %  1000),

                       (int)(e / 3600000),      (int)(e / 60000) % 60,

                       (int)(e /    1000) % 60, (int)(e %  1000));

    }

    avio_write(avf->pb, pkt->data, pkt->size);

    if (write_ts)

        avio_write(avf->pb, "\n\n", 2);

    avio_flush(avf->pb);

    return 0;

}

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;



        if (d <= 0)

            

            d = pkt->convergence_duration;

        if (s == AV_NOPTS_VALUE || d < 0) {

            av_log(avf, AV_LOG_ERROR, "Insufficient timestamps.\n");

            return AVERROR(EINVAL);

        }

        e = s + d;

        avio_printf(avf->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",

                       srt->index,

                       (int)(s / 3600000),      (int)(s / 60000) % 60,

                       (int)(s /    1000) % 60, (int)(s %  1000),

                       (int)(e / 3600000),      (int)(e / 60000) % 60,

                       (int)(e /    1000) % 60, (int)(e %  1000));

    }

    avio_write(avf->pb, pkt->data, pkt->size);

    if (write_ts)

        avio_write(avf->pb, "\n\n", 2);

    avio_flush(avf->pb);

    return 0;

}

    srt->index++;             av_log(avf, AV_LOG_ERROR, "Insufficient timestamps.\n");             return AVERROR(EINVAL);
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    SRTContext *srt = VAR_0->priv_data;

    int VAR_2 = VAR_0->streams[0]->codec->codec_id != AV_CODEC_ID_SRT;



    srt->index++;

    if (VAR_2) {

        int64_t s = VAR_1->pts, e, d = VAR_1->duration;



        if (d <= 0)

            

            d = VAR_1->convergence_duration;

        if (s == AV_NOPTS_VALUE || d < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Insufficient timestamps.\n");

            return AVERROR(EINVAL);

        }

        e = s + d;

        avio_printf(VAR_0->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",

                       srt->index,

                       (int)(s / 3600000),      (int)(s / 60000) % 60,

                       (int)(s /    1000) % 60, (int)(s %  1000),

                       (int)(e / 3600000),      (int)(e / 60000) % 60,

                       (int)(e /    1000) % 60, (int)(e %  1000));

    }

    avio_write(VAR_0->pb, VAR_1->data, VAR_1->size);

    if (VAR_2)

        avio_write(VAR_0->pb, "\n\n", 2);

    avio_flush(VAR_0->pb);

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ SRTContext *srt = VAR_0->priv_data; int VAR_2 = VAR_0->streams[0]->codec->codec_id != AV_CODEC_ID_SRT; srt->index++; if (VAR_2) { int64_t s = VAR_1->pts, e, d = VAR_1->duration; if (d <= 0)
d = VAR_1->convergence_duration; if (s == AV_NOPTS_VALUE || d < 0) { av_log(VAR_0, AV_LOG_ERROR, "Insufficient timestamps.\n"); return AVERROR(EINVAL); } e = s + d; avio_printf(VAR_0->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n",
srt->index,
(int)(s / 3600000),      (int)(s / 60000) % 60,
(int)(s /    1000) % 60, (int)(s %  1000),
(int)(e / 3600000),      (int)(e / 60000) % 60,
(int)(e /    1000) % 60, (int)(e %  1000)); } avio_write(VAR_0->pb, VAR_1->data, VAR_1->size); if (VAR_2)
avio_write(VAR_0->pb, "\n\n", 2); avio_flush(VAR_0->pb); return 0; }