tmp
authoryu.dongliang <18588496441@163.com>
Mon, 10 Apr 2023 09:25:00 +0000 (17:25 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 10 Apr 2023 09:25:00 +0000 (17:25 +0800)
simp_ffmpeg_output.c
simp_filter.c

index c94cc90597eae3f706e4a2a31addaf9d5b5a432b..323b64a478e6bf9a4ddb0684b946791365a77cba 100644 (file)
@@ -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;
index 74a949e27d7fc5e5a559f792bf5baf25a3f4c3b4..dc5b312d2cab0c16d2678f5a66d354f4e338ad8a 100644 (file)
@@ -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));