mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-16 16:20:50 +02:00
Update for FFmpeg 3.5
This commit is contained in:
parent
c1babb3bb3
commit
3d4a357f95
@ -883,6 +883,7 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_encoder);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_encoder_by_name);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_find_decoder);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_get_name);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_open2);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_decode_audio4);
|
||||
FFMPEG_INITDYN(avcodec, avcodec_encode_audio2);
|
||||
@ -913,6 +914,7 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)
|
||||
FFMPEG_INITALT(avutil, av_frame_alloc, avcodec, avcodec_alloc_frame);
|
||||
FFMPEG_INITALT(avutil, av_frame_free, avcodec, avcodec_free_frame);
|
||||
FFMPEG_INITDYN(avutil, av_samples_get_buffer_size);
|
||||
FFMPEG_INITDYN(avutil, av_get_default_channel_layout);
|
||||
|
||||
wxLogMessage(wxT("All symbols loaded successfully. Initializing the library."));
|
||||
#endif
|
||||
|
19
src/FFmpeg.h
19
src/FFmpeg.h
@ -128,6 +128,13 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
#define AV_CODEC_FLAG_QSCALE CODEC_FLAG_QSCALE
|
||||
#define AV_CODEC_FLAG_GLOBAL_HEADER CODEC_FLAG_GLOBAL_HEADER
|
||||
#define AV_CODEC_CAP_SMALL_LAST_FRAME CODEC_CAP_SMALL_LAST_FRAME
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -535,6 +542,12 @@ extern "C" {
|
||||
(void *ptr),
|
||||
(ptr)
|
||||
);
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
int64_t,
|
||||
av_get_default_channel_layout,
|
||||
(int nb_channels),
|
||||
(nb_channels)
|
||||
);
|
||||
|
||||
//
|
||||
// libavcodec
|
||||
@ -563,6 +576,12 @@ extern "C" {
|
||||
(enum AVCodecID id),
|
||||
(id)
|
||||
);
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
const char*,
|
||||
avcodec_get_name,
|
||||
(enum AVCodecID id),
|
||||
(id)
|
||||
);
|
||||
FFMPEG_FUNCTION_WITH_RETURN(
|
||||
unsigned int,
|
||||
av_codec_get_tag,
|
||||
|
@ -465,12 +465,13 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project)
|
||||
|
||||
if (mEncAudioCodecCtx->global_quality >= 0)
|
||||
{
|
||||
mEncAudioCodecCtx->flags |= CODEC_FLAG_QSCALE;
|
||||
mEncAudioCodecCtx->flags |= AV_CODEC_FLAG_QSCALE;
|
||||
}
|
||||
else mEncAudioCodecCtx->global_quality = 0;
|
||||
mEncAudioCodecCtx->global_quality = mEncAudioCodecCtx->global_quality * FF_QP2LAMBDA;
|
||||
mEncAudioCodecCtx->sample_rate = mSampleRate;
|
||||
mEncAudioCodecCtx->channels = mChannels;
|
||||
mEncAudioCodecCtx->channel_layout = av_get_default_channel_layout(mChannels);
|
||||
mEncAudioCodecCtx->time_base.num = 1;
|
||||
mEncAudioCodecCtx->time_base.den = mEncAudioCodecCtx->sample_rate;
|
||||
mEncAudioCodecCtx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
@ -519,8 +520,8 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project)
|
||||
|
||||
if (mEncFormatCtx->oformat->flags & AVFMT_GLOBALHEADER)
|
||||
{
|
||||
mEncAudioCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||
mEncFormatCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
||||
mEncAudioCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
mEncFormatCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
}
|
||||
|
||||
// Open the codec.
|
||||
@ -689,7 +690,7 @@ bool ExportFFmpeg::Finalize()
|
||||
// Or if frame_size is 1, then it's some kind of PCM codec, they don't have frames and will be fine with the samples
|
||||
// Otherwise we'll send a full frame of audio + silence padding to ensure all audio is encoded
|
||||
int frame_size = default_frame_size;
|
||||
if (mEncAudioCodecCtx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME ||
|
||||
if (mEncAudioCodecCtx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME ||
|
||||
frame_size == 1)
|
||||
frame_size = nFifoBytes / (mEncAudioCodecCtx->channels * sizeof(int16_t));
|
||||
|
||||
|
@ -931,7 +931,9 @@ CompatibilityEntry ExportFFmpegOptions::CompatibilityList[] =
|
||||
{ wxT("asf"), AV_CODEC_ID_ADPCM_G726 },
|
||||
{ wxT("asf"), AV_CODEC_ID_MP2 },
|
||||
{ wxT("asf"), AV_CODEC_ID_MP3 },
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
{ wxT("asf"), AV_CODEC_ID_VOXWARE },
|
||||
#endif
|
||||
{ wxT("asf"), AV_CODEC_ID_AAC },
|
||||
{ wxT("asf"), AV_CODEC_ID_WMAV1 },
|
||||
{ wxT("asf"), AV_CODEC_ID_WMAV2 },
|
||||
@ -965,7 +967,9 @@ CompatibilityEntry ExportFFmpegOptions::CompatibilityList[] =
|
||||
{ wxT("avi"), AV_CODEC_ID_ADPCM_G726 },
|
||||
{ wxT("avi"), AV_CODEC_ID_MP2 },
|
||||
{ wxT("avi"), AV_CODEC_ID_MP3 },
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
{ wxT("avi"), AV_CODEC_ID_VOXWARE },
|
||||
#endif
|
||||
{ wxT("avi"), AV_CODEC_ID_AAC },
|
||||
{ wxT("avi"), AV_CODEC_ID_WMAV1 },
|
||||
{ wxT("avi"), AV_CODEC_ID_WMAV2 },
|
||||
@ -1012,7 +1016,9 @@ CompatibilityEntry ExportFFmpegOptions::CompatibilityList[] =
|
||||
{ wxT("matroska"), AV_CODEC_ID_ADPCM_G726 },
|
||||
{ wxT("matroska"), AV_CODEC_ID_MP2 },
|
||||
{ wxT("matroska"), AV_CODEC_ID_MP3 },
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
{ wxT("matroska"), AV_CODEC_ID_VOXWARE },
|
||||
#endif
|
||||
{ wxT("matroska"), AV_CODEC_ID_AAC },
|
||||
{ wxT("matroska"), AV_CODEC_ID_WMAV1 },
|
||||
{ wxT("matroska"), AV_CODEC_ID_WMAV2 },
|
||||
@ -1118,7 +1124,9 @@ CompatibilityEntry ExportFFmpegOptions::CompatibilityList[] =
|
||||
{ wxT("nut"), AV_CODEC_ID_ADPCM_G726 },
|
||||
{ wxT("nut"), AV_CODEC_ID_MP2 },
|
||||
{ wxT("nut"), AV_CODEC_ID_MP3 },
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
{ wxT("nut"), AV_CODEC_ID_VOXWARE },
|
||||
#endif
|
||||
{ wxT("nut"), AV_CODEC_ID_AAC },
|
||||
{ wxT("nut"), AV_CODEC_ID_WMAV1 },
|
||||
{ wxT("nut"), AV_CODEC_ID_WMAV2 },
|
||||
@ -1166,7 +1174,9 @@ CompatibilityEntry ExportFFmpegOptions::CompatibilityList[] =
|
||||
{ wxT("wav"), AV_CODEC_ID_ADPCM_G726 },
|
||||
{ wxT("wav"), AV_CODEC_ID_MP2 },
|
||||
{ wxT("wav"), AV_CODEC_ID_MP3 },
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
{ wxT("wav"), AV_CODEC_ID_VOXWARE },
|
||||
#endif
|
||||
{ wxT("wav"), AV_CODEC_ID_AAC },
|
||||
{ wxT("wav"), AV_CODEC_ID_WMAV1 },
|
||||
{ wxT("wav"), AV_CODEC_ID_WMAV2 },
|
||||
|
@ -404,23 +404,27 @@ bool FFmpegImportFileHandle::InitCodecs()
|
||||
sc->m_stream = mFormatContext->streams[i];
|
||||
sc->m_codecCtx = sc->m_stream->codec;
|
||||
|
||||
AVCodec *codec = avcodec_find_decoder(sc->m_codecCtx->codec_id);
|
||||
const AVCodecID id = sc->m_codecCtx->codec_id;
|
||||
const char* name = avcodec_get_name(id);
|
||||
const AVCodec *codec = avcodec_find_decoder(id);
|
||||
|
||||
if (codec == NULL)
|
||||
{
|
||||
wxLogError(wxT("FFmpeg : avcodec_find_decoder() failed. Index[%02d], Codec[%02x - %s]"),i,sc->m_codecCtx->codec_id,sc->m_codecCtx->codec_name);
|
||||
wxLogError(wxT("FFmpeg : avcodec_find_decoder() failed. Index[%02d], Codec[%02x - %s]"),i,id,name);
|
||||
//FFmpeg can't decode this stream, skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
if (codec->type != sc->m_codecCtx->codec_type)
|
||||
{
|
||||
wxLogError(wxT("FFmpeg : Codec type mismatch, skipping. Index[%02d], Codec[%02x - %s]"),i,sc->m_codecCtx->codec_id,sc->m_codecCtx->codec_name);
|
||||
wxLogError(wxT("FFmpeg : Codec type mismatch, skipping. Index[%02d], Codec[%02x - %s]"),i,id,name);
|
||||
//Non-audio codec reported as audio? Nevertheless, we don't need THIS.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (avcodec_open2(sc->m_codecCtx, codec, NULL) < 0)
|
||||
{
|
||||
wxLogError(wxT("FFmpeg : avcodec_open() failed. Index[%02d], Codec[%02x - %s]"),i,sc->m_codecCtx->codec_id,sc->m_codecCtx->codec_name);
|
||||
wxLogError(wxT("FFmpeg : avcodec_open() failed. Index[%02d], Codec[%02x - %s]"),i,id,name);
|
||||
//Can't open decoder - skip this stream
|
||||
continue;
|
||||
}
|
||||
@ -434,7 +438,7 @@ bool FFmpegImportFileHandle::InitCodecs()
|
||||
duration = mFormatContext->duration / AV_TIME_BASE;
|
||||
wxString bitrate = wxT("");
|
||||
if (sc->m_codecCtx->bit_rate > 0)
|
||||
bitrate.Printf(wxT("%d"),sc->m_codecCtx->bit_rate);
|
||||
bitrate.Printf(wxT("%d"),(int)sc->m_codecCtx->bit_rate);
|
||||
else
|
||||
bitrate.Printf(wxT("?"));
|
||||
|
||||
@ -444,7 +448,8 @@ bool FFmpegImportFileHandle::InitCodecs()
|
||||
{
|
||||
lang.FromUTF8(tag->value);
|
||||
}
|
||||
strinfo.Printf(_("Index[%02x] Codec[%s], Language[%s], Bitrate[%s], Channels[%d], Duration[%d]"),sc->m_stream->id,codec->name,lang,bitrate,sc->m_stream->codec->channels, duration);
|
||||
strinfo.Printf(_("Index[%02x] Codec[%s], Language[%s], Bitrate[%s], Channels[%d], Duration[%d]"),
|
||||
sc->m_stream->id,codec->name,lang,bitrate,(int)sc->m_stream->codec->channels,(int)duration);
|
||||
mStreamInfo.Add(strinfo);
|
||||
mScs->get()[mNumStreams++] = std::move(sc);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user