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) {
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);
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;
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);
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;
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);
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));
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);
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));