试图解决编译错误

This commit is contained in:
Mike Solar
2025-06-18 08:54:06 +08:00
parent 7e0e94abf6
commit 5f9508434f
7 changed files with 35 additions and 32 deletions
+2
View File
@@ -98,3 +98,5 @@ compile_flags.txt
*creator.user*
*_qmlcache.qrc
.idea/
.idea
+1 -1
View File
@@ -256,7 +256,7 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
if (audio_enabled_) {
writer->writeTextElement(QStringLiteral("codec"), QString::number(audio_codec_));
writer->writeTextElement(QStringLiteral("samplerate"), QString::number(audio_params_.sample_rate()));
writer->writeTextElement(QStringLiteral("channellayout"), QString::number(audio_params_.channel_layout()));
writer->writeTextElement(QStringLiteral("channellayout"), QString::number());
writer->writeTextElement(QStringLiteral("format"), QString::fromStdString(audio_params_.format().to_string()));
writer->writeTextElement(QStringLiteral("bitrate"), QString::number(audio_bit_rate_));
}
+1 -1
View File
@@ -33,7 +33,7 @@
#include "render/colortransform.h"
#include "render/subtitleparams.h"
#include "render/videoparams.h"
//这个代码也许是创建工程文件用的?还是导出编码视频用的?
namespace olive {
class Encoder;
+22 -20
View File
@@ -439,9 +439,9 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, CancelAtom *can
} else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
// Create an audio stream object
uint64_t channel_layout = avstream->codecpar->channel_layout;
if (!channel_layout) {
channel_layout = static_cast<uint64_t>(av_get_default_channel_layout(avstream->codecpar->channels));
AVChannelLayout channel_layout = avstream->codecpar->ch_layout;
if (!channel_layout.nb_channels==0) {
av_channel_layout_default(&channel_layout,avstream->codecpar->ch_layout.nb_channels);
}
if (avstream->duration == AV_NOPTS_VALUE || duration_guessed_from_bitrate) {
@@ -551,22 +551,23 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector<QString> &filenames, cons
instance_.Seek(0);
// Handle NULL channel layout
uint64_t channel_layout = ValidateChannelLayout(instance_.avstream());
if (!channel_layout) {
AVChannelLayout channel_layout = ValidateChannelLayout(instance_.avstream());
if (!av_channel_layout_check(&channel_layout)) {
qCritical() << "Failed to determine channel layout of audio file, could not conform";
return false;
}
// Create resampling context
SwrContext* resampler = swr_alloc_set_opts(nullptr,
params.channel_layout(),
FFmpegUtils::GetFFmpegSampleFormat(params.format()),
params.sample_rate(),
channel_layout,
static_cast<AVSampleFormat>(instance_.avstream()->codecpar->format),
instance_.avstream()->codecpar->sample_rate,
0,
nullptr);
AVChannelLayout layout=params.channel_layout();
SwrContext* resampler;
swr_alloc_set_opts2(&resampler,
&layout,
FFmpegUtils::GetFFmpegSampleFormat(params.format()),
params.sample_rate(),
&channel_layout,
static_cast<AVSampleFormat>(instance_.avstream()->codecpar->format),
instance_.avstream()->codecpar->sample_rate,
0,
nullptr);
swr_init(resampler);
@@ -689,13 +690,14 @@ int FFmpegDecoder::GetNativeChannelCount(AVPixelFormat pix_fmt)
}
}
uint64_t FFmpegDecoder::ValidateChannelLayout(AVStream* stream)
AVChannelLayout FFmpegDecoder::ValidateChannelLayout(AVStream* stream)
{
if (stream->codecpar->channel_layout) {
return stream->codecpar->channel_layout;
if (av_channel_layout_check(&stream->codecpar->ch_layout)) {
return stream->codecpar->ch_layout;
}
return av_get_default_channel_layout(stream->codecpar->channels);
AVChannelLayout layout;
av_channel_layout_default(&layout,stream->codecpar->ch_layout.nb_channels);
return layout;
}
const char *FFmpegDecoder::GetInterlacingModeInFFmpeg(VideoParams::Interlacing interlacing)
+1 -1
View File
@@ -139,7 +139,7 @@ private:
static PixelFormat GetNativePixelFormat(AVPixelFormat pix_fmt);
static int GetNativeChannelCount(AVPixelFormat pix_fmt);
static uint64_t ValidateChannelLayout(AVStream *stream);
static AVChannelLayout ValidateChannelLayout(AVStream *stream);
static const char* GetInterlacingModeInFFmpeg(VideoParams::Interlacing interlacing);
+7 -8
View File
@@ -349,7 +349,7 @@ bool FFmpegEncoder::WriteAudioData(const AudioParams &audio_params, const uint8_
av_samples_copy(audio_frame_->data, output_data, audio_frame_offset_, i,
copy_length,
audio_frame_->channels, static_cast<AVSampleFormat>(audio_frame_->format));
audio_frame_->ch_layout.nb_channels, static_cast<AVSampleFormat>(audio_frame_->format));
audio_frame_offset_ += copy_length;
i += copy_length;
@@ -690,8 +690,7 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
// Assume audio stream
codec_ctx->sample_rate = params().audio_params().sample_rate();
codec_ctx->channel_layout = params().audio_params().channel_layout();
codec_ctx->channels = av_get_channel_layout_nb_channels(codec_ctx->channel_layout);
codec_ctx->ch_layout = params().audio_params().channel_layout();
codec_ctx->sample_fmt = FFmpegUtils::GetFFmpegSampleFormat(params().audio_params().format());
codec_ctx->time_base = {1, codec_ctx->sample_rate};
@@ -827,13 +826,13 @@ bool FFmpegEncoder::InitializeResampleContext(const AudioParams &audio)
if (audio_resample_ctx_) {
return true;
}
AVChannelLayout layout=audio.channel_layout();
// Create resample context
audio_resample_ctx_ = swr_alloc_set_opts(nullptr,
static_cast<int64_t>(audio_codec_ctx_->channel_layout),
swr_alloc_set_opts2(&audio_resample_ctx_,
&audio_codec_ctx_->ch_layout,
audio_codec_ctx_->sample_fmt,
audio_codec_ctx_->sample_rate,
static_cast<int64_t>(audio.channel_layout()),
&layout,
FFmpegUtils::GetFFmpegSampleFormat(audio.format()),
audio.sample_rate(),
0,
@@ -865,7 +864,7 @@ bool FFmpegEncoder::InitializeResampleContext(const AudioParams &audio)
return false;
}
audio_frame_->channel_layout = audio_codec_ctx_->channel_layout;
audio_frame_->ch_layout = audio_codec_ctx_->ch_layout;
audio_frame_->format = audio_codec_ctx_->sample_fmt;
audio_frame_->nb_samples = audio_max_samples_;