From: yu.dongliang <18588496441@163.com> Date: Tue, 11 Apr 2023 13:53:11 +0000 (+0800) Subject: speed X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=ea5dec36f96d9d67e821168f791598f4ef047c62;p=simplay.git speed --- diff --git a/simp.h b/simp.h index 3ced822..0f44cf8 100644 --- a/simp.h +++ b/simp.h @@ -38,6 +38,7 @@ struct simp_avio_s scf_list_t aout; int64_t start_time; + AVRational speed; int x; int y; @@ -81,6 +82,8 @@ struct simp_filter_s AVFrame* vframe; AVFrame* aframe; + AVRational speed; + int error; int exit; int flush; diff --git a/simp_filter.c b/simp_filter.c index f857dde..4e3c169 100644 --- a/simp_filter.c +++ b/simp_filter.c @@ -259,7 +259,7 @@ int simp_filter_close(simp_filter_t* f, int flush) return 0; } -static int _filter_add_video(simp_avio_t* io) +static int _filter_add_video(simp_avio_t* io, AVRational speed) { simp_frame_t* vf; scf_list_t* vl; @@ -273,6 +273,12 @@ static int _filter_add_video(simp_avio_t* io) int64_t time = gettime() - io->start_time; int64_t vtime = vf->frame->pts * av_q2d(io->frame_rate) * 1000000LL; + if (speed.num > 0 && speed.den > 0) + time *= av_q2d(speed); + + else if (io->speed.num > 0 && io->speed.num > 0) + time *= av_q2d(io->speed); + if (vtime < time) { scf_list_del(&vf->list); io->nb_vframes--; @@ -300,7 +306,7 @@ static int _filter_add_video(simp_avio_t* io) return 0; } -static int _filter_add_audio(simp_avio_t* io) +static int _filter_add_audio(simp_avio_t* io, AVRational speed) { simp_frame_t* af; scf_list_t* al; @@ -357,7 +363,7 @@ static void* __filter_run(void* arg) while (!f->exit) { - usleep(500 * 1000); + usleep(1000); for (l = scf_list_head(&f->inputs); l != scf_list_sentinel(&f->inputs); l = scf_list_next(l)) { io = scf_list_data(l, simp_avio_t, list); @@ -369,7 +375,7 @@ static void* __filter_run(void* arg) simp_avio_stop(io); if (io->vopen) { - f->error = _filter_add_video(io); + f->error = _filter_add_video(io, f->speed); if (f->error < 0) goto error; @@ -384,7 +390,7 @@ static void* __filter_run(void* arg) } if (io->aopen) { - f->error = _filter_add_audio(io); + f->error = _filter_add_audio(io, f->speed); if (f->error < 0) goto error;