Improve:audio encoder.
This commit is contained in:
parent
dc8a17cc3e
commit
63946512aa
|
@ -102,10 +102,8 @@ if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
|
||||||
message(FATAL_ERROR "You set support clang-tidy, but clang-tidy not found.
|
message(FATAL_ERROR "You set support clang-tidy, but clang-tidy not found.
|
||||||
Check path ${LLVM_PATH}/build/bin, weather clang-tidy exist.
|
Check path ${LLVM_PATH}/build/bin, weather clang-tidy exist.
|
||||||
How to install tools?
|
How to install tools?
|
||||||
See ${IPC_SDK_PATH}/doc/clang-tidy_user_guide.md
|
Execute : make compile_llvm (in the project root directory)
|
||||||
How to disable clang-tidy tool?
|
Or see ${CMAKE_SOURCE_DIR_IPCSDK}/doc/clang-tidy_user_guide.md")
|
||||||
Modify: set(CLANG_TIDY_SUPPORT \"false\")
|
|
||||||
See:${IPC_SDK_PATH}/builde/global_config.cmake")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# find the clang-format tools
|
# find the clang-format tools
|
||||||
|
|
|
@ -71,7 +71,8 @@ bool FfmpegEncoder::Init(int &outputFlags)
|
||||||
switch (mCodec->type) {
|
switch (mCodec->type) {
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
mCodecCtx->sample_fmt = mCodec->sample_fmts ? mCodec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
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;
|
mCodecCtx->sample_rate = 44100;
|
||||||
if (mCodec->supported_samplerates) {
|
if (mCodec->supported_samplerates) {
|
||||||
mCodecCtx->sample_rate = mCodec->supported_samplerates[0];
|
mCodecCtx->sample_rate = mCodec->supported_samplerates[0];
|
||||||
|
@ -81,7 +82,9 @@ bool FfmpegEncoder::Init(int &outputFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mCodecCtx->sample_rate = 8000;
|
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;
|
break;
|
||||||
|
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
|
|
|
@ -84,7 +84,6 @@ void FfmpegMuxStreamV2::GetStreamData(const void *data, const size_t &size, cons
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogInfo("Write frame size: %zu.\n", size);
|
|
||||||
if (streamInfo.mType == STREAM_TYPE_VIDEO_H264 && mVideoStream) {
|
if (streamInfo.mType == STREAM_TYPE_VIDEO_H264 && mVideoStream) {
|
||||||
mVideoStream->WriteSourceData(data, size);
|
mVideoStream->WriteSourceData(data, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,15 @@ private:
|
||||||
void GetAVPacketDataCallback(AVPacket *pkt);
|
void GetAVPacketDataCallback(AVPacket *pkt);
|
||||||
|
|
||||||
private:
|
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,
|
static std::shared_ptr<FfmpegOutputStream> AddStream(AVFormatContext *outputFormat, enum AVCodecID encodecId,
|
||||||
enum AVCodecID decodecId);
|
enum AVCodecID decodecId);
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,6 @@ bool FfmpegOutputStream::Init(AVFormatContext *outputFormat)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mStream->time_base = (AVRational){1, 15};
|
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_id = AV_CODEC_ID_H264;
|
||||||
mStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
mStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
mStream->codecpar->width = 1920;
|
mStream->codecpar->width = 1920;
|
||||||
|
@ -79,12 +74,6 @@ bool FfmpegOutputStream::Init(AVFormatContext *outputFormat)
|
||||||
mStream->codecpar->codec_tag = 0;
|
mStream->codecpar->codec_tag = 0;
|
||||||
mStream->codecpar->extradata = nullptr;
|
mStream->codecpar->extradata = nullptr;
|
||||||
mStream->codecpar->extradata_size = 0;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user