From e159d6eae36b3316b75e669b4c07e8e535f6bde0 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 11 Apr 2023 22:20:42 +0800 Subject: [PATCH] speed --- main.c | 3 +++ simp_filter.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index a7d1d8e..19288d0 100644 --- a/main.c +++ b/main.c @@ -34,6 +34,9 @@ int main(int argc, char* argv[]) simp_filter_add_input (f, in); simp_filter_add_output(f, out); + f->speed.num = 200; + f->speed.den = 1; + if (simp_filter_run(f) < 0) { scf_loge("\n"); return -1; diff --git a/simp_filter.c b/simp_filter.c index 4e3c169..da8c69e 100644 --- a/simp_filter.c +++ b/simp_filter.c @@ -284,7 +284,15 @@ static int _filter_add_video(simp_avio_t* io, AVRational speed) io->nb_vframes--; pthread_mutex_unlock(&io->mutex); - scf_logd("vf->pts: %ld, vtime: %ld, time: %ld, nb_vframes: %d\n", vf->frame->pts, vtime, time, io->nb_vframes); + int64_t usec = vtime % 1000000; + int64_t sec = vtime / 1000000; + int64_t hour = sec / 3600; + sec %= 3600; + int64_t min = sec / 60; + sec %= 60; + + scf_logi("vf->pts: %ld, vtime: %ld, time: %ld, nb_vframes: %d, %ld:%ld:%ld.%ld\n", + vf->frame->pts, vtime, time, io->nb_vframes, hour, min, sec, usec); int ret = av_buffersrc_add_frame_flags(io->vbuffersrc_ctx, vf->frame, AV_BUFFERSRC_FLAG_KEEP_REF); @@ -320,6 +328,12 @@ static int _filter_add_audio(simp_avio_t* io, AVRational speed) int64_t time = gettime() - io->start_time; int64_t atime = af->frame->pts * av_q2d(io->sample_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 (atime < time) { scf_list_del(&af->list); pthread_mutex_unlock(&io->mutex); @@ -363,7 +377,7 @@ static void* __filter_run(void* arg) while (!f->exit) { - usleep(1000); + usleep(100); 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); -- 2.25.1