From bdb533b9e5e73ef3f7414d8301feb8b130c3ccb9 Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Fri, 9 Sep 2022 17:58:59 +0800 Subject: [PATCH] Feature: select video and audio stream --- app/src/main/cpp/ff_http_pusher.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/cpp/ff_http_pusher.cpp b/app/src/main/cpp/ff_http_pusher.cpp index 29b505a..f1548d4 100644 --- a/app/src/main/cpp/ff_http_pusher.cpp +++ b/app/src/main/cpp/ff_http_pusher.cpp @@ -32,6 +32,14 @@ int FFHttpPusher::open(const char *inputPath, const char *outputPath) { out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } out_stream->codecpar->codec_tag = 0; + + if (in_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + video_index = i; + } else if (in_stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { + if (audio_index == -1) { + audio_index = i; + } + } } if (!(outFormatCtx->oformat->flags & AVFMT_NOFILE)) { @@ -70,6 +78,10 @@ int FFHttpPusher::push() { break; } + if (packet.stream_index != video_index && packet.stream_index != audio_index) + continue; + + // sync AVRational time_base = inFormatCtx->streams[packet.stream_index]->time_base; int64_t pts_time = av_rescale_q(packet.pts, time_base, AV_TIME_BASE_Q); int64_t cur_time = av_gettime() - startTime;