40#define DESC XO("FFmpeg-compatible files")
43#if defined(USE_FFMPEG)
184 std::unique_ptr<ImportFileHandle>
Open(
222 Tags *tags)
override;
298 wxString extension = filename.AfterLast(
wxT(
'.'));
310 if (dontShowDlg == 0 && newsession)
326 auto handle = std::make_unique<FFmpegImportFileHandle>(filename);
329 bool success = handle->Init();
339 std::make_unique< FFmpegImportPlugin >()
360 wxLogError(
wxT(
"FFmpeg : AVFormatContextWrapper::OpenInputContext() failed for file %s"),
mName);
380 auto codec =
mFFmpeg->CreateDecoder(
id);
386 wxT(
"FFmpeg : CreateDecoder() failed. Index[%02d], Codec[%02x - %s]"),
394 if ( codecContextPtr->Open( codecContextPtr->GetCodec() ) < 0 )
396 wxLogError(
wxT(
"FFmpeg : Open() failed. Index[%02d], Codec[%02x - %s]"),i,
id,
name);
401 const int channels = codecContextPtr->GetChannels();
403 codecContextPtr->GetPreferredAudacitySampleFormat();
405 auto codecContext = codecContextPtr.get();
409 channels, preferredFormat,
true });
419 if (codecContext->GetBitRate() > 0)
420 bitrate.Printf(
wxT(
"%d"),(
int)codecContext->GetBitRate());
422 bitrate.Printf(
wxT(
"?"));
426 auto lang = std::string(streamMetadata.
Get(
"language", {}));
430"Index[%02x] Codec[%s], Language[%s], Bitrate[%s], Channels[%d], Duration[%d]")
436 (
int)codecContext->GetChannels(),
483 for (
auto &channel : stream)
495 int64_t stream_delay = 0;
506 wxT(
"Stream %d start_time = %lld, that would be %f milliseconds."),
510 if (stream_delay > 0)
513 for (
auto &channel : stream)
527 for (std::unique_ptr<AVPacketWrapper> packet;
532 auto streamContextIt = std::find_if(
535 { return ctx.StreamIndex == index;
541 res =
WriteData(&(*streamContextIt), packet.get());
547 auto emptyPacket =
mFFmpeg->CreateAVPacketWrapper();
560 for(
auto &channel : stream)
577 for (
int i = 0; i < static_cast<int>(
mStreamContexts.size()); ++iter, ++i)
595 auto data = sc->
CodecContext->DecodeAudioPacketInt16(packet);
597 const int channelsCount = sc->
CodecContext->GetChannels();
598 const int samplesPerChannel = data.size() / channelsCount;
601 auto iter2 = iter->begin();
602 for (
size_t chn = 0; chn < nChannels; ++iter2, ++chn)
604 iter2->get()->Append(
612 auto data = sc->
CodecContext->DecodeAudioPacketFloat(packet);
614 const int channelsCount = sc->
CodecContext->GetChannels();
615 const int samplesPerChannel = data.size() / channelsCount;
618 auto iter2 = iter->begin();
619 for (
size_t chn = 0; chn < nChannels; ++iter2, ++chn)
621 iter2->get()->Append(
658 filesize > 0 && packet->
GetPos() > 0 && packet->
GetPos() <= filesize)
678 if (wxString(
mAVFormatContext->GetInputFormat()->GetName()).Contains(
"m4a"))
683 else if (wxString(
mAVFormatContext->GetInputFormat()->GetName()).Contains(
"asf"))
#define DICT_IGNORE_SUFFIX
const TranslatableString name
BoolSetting FFmpegNotFoundDontShow
#define AUDACITY_AV_TIME_BASE
#define AUDACITY_AV_NOPTS_VALUE
BoolSetting NewImportingSession
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
static Importer::RegisteredImportPlugin registered
The interface that all file import "plugins" (if you want to call them that) must implement....
std::vector< TranslatableString > TranslatableStrings
std::string_view Get(const std::string_view &key, const std::string_view &defaultValue, int flags=0) const
virtual int64_t GetPos() const noexcept=0
virtual int64_t GetPresentationTimestamp() const noexcept=0
virtual int64_t GetDuration() const noexcept=0
virtual int GetIndex() const noexcept=0
virtual bool IsAudio() const noexcept=0
virtual AVDictionaryWrapper GetMetadata() const noexcept=0
virtual AudacityAVRational GetTimeBase() const noexcept=0
virtual int64_t GetFramesCount() const noexcept=0
virtual std::unique_ptr< AVCodecContextWrapper > GetAVCodecContext() const noexcept=0
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
! Does actual import, returned by FFmpegImportPlugin::Open
wxInt64 mProgressPos
Current timestamp, file position or whatever is used as first argument for Update()
std::unique_ptr< AVFormatContextWrapper > mAVFormatContext
FFmpegImportFileHandle(const FilePath &name)
void GetMetadata(Tags &tags, const wxChar *tag, const char *name)
TranslatableStrings mStreamInfo
Array of stream descriptions. After Init() and before Import(), same size as mStreamContexts.
void SetStreamUsage(wxInt32 StreamID, bool Use) override
const TranslatableStrings & GetStreamInfo() override
~FFmpegImportFileHandle()
ProgressResult Import(WaveTrackFactory *trackFactory, TrackHolders &outTracks, Tags *tags) override
const std::shared_ptr< FFmpegFunctions > mFFmpeg
TranslatableString GetFileDescription() override
void WriteMetadata(Tags *tags)
bool mStopped
True if importing was stopped by user.
ByteCount GetFileUncompressedBytes() override
bool mCancelled
True if importing was canceled by user.
wxInt32 GetStreamCount() override
std::vector< StreamContext > mStreamContexts
ProgressResult WriteData(StreamContext *sc, const AVPacketWrapper *packet)
wxInt64 mProgressLen
Duration, total length or whatever is used as second argument for Update()
An ImportPlugin for FFmpeg data.
TranslatableString FailureHint() const override
User visible message suggesting what to do when a file type isn't recognized; default empty string.
wxString GetPluginStringID() override
std::unique_ptr< ImportFileHandle > Open(const FilePath &Filename, AudacityProject *) override
! Probes the file and opens it if appropriate
TranslatableString GetPluginFormatDescription() override
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
An ImportFileHandle for data.
unsigned long long ByteCount
std::unique_ptr< ProgressDialog > mProgress
std::shared_ptr< WaveTrack > NewWaveTrack(WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
Build a wave track with appropriate format, which will not be narrower than the specified one.
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
bool SupportsExtension(const FileExtension &extension)
bool Write(const T &value)
Write value to config and return true if successful.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
Holds a msgid for the translation catalog; may also bind format arguments.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
A Track that contains audio waveform data.
void InsertSilence(double t, double len) override
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
static double streamStartTime
static std::shared_ptr< FFmpegFunctions > Load(bool fromUserPathOnly=false)
std::unique_ptr< AVCodecContextWrapper > CodecContext
sampleFormat SampleFormat