Improve:audio encoder.

This commit is contained in:
Fancy code 2024-07-08 11:23:22 +08:00
parent dc8a17cc3e
commit 63946512aa
5 changed files with 16 additions and 18 deletions

View File

@ -102,10 +102,8 @@ if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
message(FATAL_ERROR "You set support clang-tidy, but clang-tidy not found.
Check path ${LLVM_PATH}/build/bin, weather clang-tidy exist.
How to install tools?
See ${IPC_SDK_PATH}/doc/clang-tidy_user_guide.md
How to disable clang-tidy tool?
Modify: set(CLANG_TIDY_SUPPORT \"false\")
See:${IPC_SDK_PATH}/builde/global_config.cmake")
Execute : make compile_llvm (in the project root directory)
Or see ${CMAKE_SOURCE_DIR_IPCSDK}/doc/clang-tidy_user_guide.md")
endif()
endif()
# find the clang-format tools

View File

@ -71,7 +71,8 @@ bool FfmpegEncoder::Init(int &outputFlags)
switch (mCodec->type) {
case AVMEDIA_TYPE_AUDIO:
mCodecCtx->sample_fmt = mCodec->sample_fmts ? mCodec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
mCodecCtx->bit_rate = 64000;
// mCodecCtx->bit_rate = 64000;
mCodecCtx->bit_rate = 24000;
mCodecCtx->sample_rate = 44100;
if (mCodec->supported_samplerates) {
mCodecCtx->sample_rate = mCodec->supported_samplerates[0];
@ -81,7 +82,9 @@ bool FfmpegEncoder::Init(int &outputFlags)
}
}
mCodecCtx->sample_rate = 8000;
av_channel_layout_copy(&mCodecCtx->ch_layout, &src);
mCodecCtx->ch_layout.nb_channels = 1;
av_channel_layout_default(&mCodecCtx->ch_layout, 1);
// av_channel_layout_copy(&mCodecCtx->ch_layout, &src);
break;
case AVMEDIA_TYPE_VIDEO:

View File

@ -84,7 +84,6 @@ void FfmpegMuxStreamV2::GetStreamData(const void *data, const size_t &size, cons
return;
}
}
LogInfo("Write frame size: %zu.\n", size);
if (streamInfo.mType == STREAM_TYPE_VIDEO_H264 && mVideoStream) {
mVideoStream->WriteSourceData(data, size);
}

View File

@ -54,6 +54,15 @@ private:
void GetAVPacketDataCallback(AVPacket *pkt);
private:
/**
* @brief Add media streams (audio streams or video streams) to the output file. If the input stream data needs to
* be encoded or decoded, set the matching encoder/decoder parameters as needed.The AV_CODEC_ID_NONE parameter means
* that no codec needs to be set.
* @param outputFormat
* @param encodecId
* @param decodecId
* @return std::shared_ptr<FfmpegOutputStream>
*/
static std::shared_ptr<FfmpegOutputStream> AddStream(AVFormatContext *outputFormat, enum AVCodecID encodecId,
enum AVCodecID decodecId);

View File

@ -65,11 +65,6 @@ bool FfmpegOutputStream::Init(AVFormatContext *outputFormat)
}
else {
mStream->time_base = (AVRational){1, 15};
// int ret = avcodec_parameters_copy(mStream->codecpar, in_codecpar);
// if (ret < 0) {
// LogError("Failed to copy codec parameters\n");
// return false;
// }
mStream->codecpar->codec_id = AV_CODEC_ID_H264;
mStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
mStream->codecpar->width = 1920;
@ -79,12 +74,6 @@ bool FfmpegOutputStream::Init(AVFormatContext *outputFormat)
mStream->codecpar->codec_tag = 0;
mStream->codecpar->extradata = nullptr;
mStream->codecpar->extradata_size = 0;
// mEncoder = std::make_shared<FfmpegEncoder>(AV_CODEC_ID_MPEG4);
// mEncoder->Init(outputFormat->flags);
// mStream->time_base = mEncoder->GetTimeBase();
// mEncoder->OpenEncoder(nullptr, mStream);
// mEncoder->UnInit();
// mEncoder.reset();
}
return true;
}