From 5d64e55b3f772a4d82a4f1cd09262f6c2e4a4c86 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 10 Apr 2023 17:25:00 +0800 Subject: [PATCH] tmp --- simp_ffmpeg_output.c | 14 +++++--------- simp_filter.c | 6 ++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/simp_ffmpeg_output.c b/simp_ffmpeg_output.c index c94cc90..323b64a 100644 --- a/simp_ffmpeg_output.c +++ b/simp_ffmpeg_output.c @@ -217,11 +217,9 @@ static int _ffmpeg_output_close(simp_avio_t* io) return 0; } -static int __ffmpeg_encode(simp_avio_t* io, AVCodecContext* c, AVPacket* pkt, AVFrame* frame) +static int __ffmpeg_encode(simp_avio_t* io, AVCodecContext* c, AVPacket* pkt, AVFrame* frame, int idx) { simp_ffmpeg_t* priv = io->priv; - simp_frame_t* f; - AVStream* s; int ret = avcodec_send_frame(c, frame); if (ret < 0) { @@ -239,6 +237,8 @@ static int __ffmpeg_encode(simp_avio_t* io, AVCodecContext* c, AVPacket* pkt, AV return ret; } + scf_logw("idx: %d, frame->pts: %ld, pkt->stream_index: %d, pkt->pts: %ld\n", idx, frame->pts, pkt->stream_index, pkt->pts); + ret = av_write_frame(priv->fmt_ctx, pkt); av_packet_unref(pkt); @@ -289,9 +289,7 @@ static void* __ffmpeg_output_run(void* arg) scf_list_del(&f->list); pthread_mutex_unlock(&io->mutex); - scf_logw("frame->pts: %ld\n", f->frame->pts); - - ret = __ffmpeg_encode(io, priv->vcodec_ctx, priv->vpkt, f->frame); + ret = __ffmpeg_encode(io, priv->vcodec_ctx, priv->vpkt, f->frame, priv->vidx); simp_frame_free(f); f = NULL; @@ -308,8 +306,6 @@ static void* __ffmpeg_output_run(void* arg) scf_list_del(&f->list); pthread_mutex_unlock(&io->mutex); - scf_logw("frame->pts: %ld\n", f->frame->pts); - ret = av_audio_fifo_write(priv->afifo, (void**)f->frame->data, f->frame->nb_samples); simp_frame_free(f); @@ -332,7 +328,7 @@ static void* __ffmpeg_output_run(void* arg) goto end; } - ret = __ffmpeg_encode(io, priv->acodec_ctx, priv->apkt, priv->aframe); + ret = __ffmpeg_encode(io, priv->acodec_ctx, priv->apkt, priv->aframe, priv->aidx); if (ret < 0) { io->error = ret; goto end; diff --git a/simp_filter.c b/simp_filter.c index 74a949e..dc5b312 100644 --- a/simp_filter.c +++ b/simp_filter.c @@ -309,7 +309,7 @@ static void* __filter_run(void* arg) int vn = 0; int an = 0; - sleep(2); + usleep(500 * 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); @@ -334,7 +334,6 @@ static void* __filter_run(void* arg) int ret = av_buffersink_get_frame(f->vbuffersink_ctx, f->vframe); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { - scf_loge("\n"); break; } else if (ret < 0) { scf_loge("av_buffersink_get_frame error, ret: %s\n", av_err2str(ret)); @@ -343,7 +342,7 @@ static void* __filter_run(void* arg) goto error; } - scf_logw("f->frame->pts: %ld\n", f->vframe->pts); + scf_loge("f->frame->pts: %ld\n", f->vframe->pts); for (l = scf_list_head(&f->outputs); l != scf_list_sentinel(&f->outputs); l != scf_list_next(l)) { io = scf_list_data(l, simp_avio_t, list); @@ -377,7 +376,6 @@ static void* __filter_run(void* arg) int ret = av_buffersink_get_frame(f->abuffersink_ctx, f->aframe); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { - scf_loge("\n"); break; } else if (ret < 0) { scf_loge("av_buffersink_get_frame error, ret: %s\n", av_err2str(ret)); -- 2.25.1