13
0

Implement FFMPEG/MP3 export-format spec and profile

This commit is contained in:
Robin Gareus 2018-11-19 23:44:50 +01:00
parent 5fa05b403c
commit 27e0e78e1d
6 changed files with 78 additions and 7 deletions

View File

@ -104,6 +104,7 @@ class LIBARDOUR_API ExportFormatManager : public PBD::ScopedConnectionList
void select_upload (bool);
void set_command (std::string);
void select_src_quality (ExportFormatBase::SRCQuality value);
void select_codec_quality (int);
void select_trim_beginning (bool value);
void select_silence_beginning (AnyTime const & time);
void select_trim_end (bool value);

View File

@ -52,6 +52,8 @@ class LIBARDOUR_API ExportFormat : public ExportFormatBase, public ExportFormatB
Quality get_quality () const { return *qualities.begin(); }
bool has_sample_format ();
bool has_codec_quality ();
bool sample_format_is_compatible (SampleFormat format) const;
/* If the format has a specific sample format, this function should be overridden
@ -76,6 +78,7 @@ class LIBARDOUR_API ExportFormat : public ExportFormatBase, public ExportFormatB
virtual bool has_broadcast_info () const { return false; }
protected:
void add_sample_rate (SampleRate rate) { sample_rates.insert (rate); }
@ -85,6 +88,36 @@ class LIBARDOUR_API ExportFormat : public ExportFormatBase, public ExportFormatB
void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
};
class LIBARDOUR_API HasCodecQuality : public PBD::ScopedConnectionList {
public:
struct CodecQuality {
CodecQuality (std::string const& n, int q)
: name (n)
, quality (q)
{}
std::string name;
int quality;
};
typedef boost::shared_ptr<CodecQuality> CodecQualityPtr;
typedef std::list<CodecQualityPtr> CodecQualityList;
virtual ~HasCodecQuality () {}
void add_codec_quality (std::string const& name, int q) {
CodecQualityPtr ptr (new CodecQuality (name, q));
_codec_qualties.push_back (ptr);
}
CodecQualityList const & get_codec_qualities () const {
return _codec_qualties;
}
protected:
CodecQualityList _codec_qualties;
};
/// Class to be inherited by export formats that have a selectable sample format
class LIBARDOUR_API HasSampleFormat : public PBD::ScopedConnectionList {
public:
@ -211,7 +244,7 @@ class LIBARDOUR_API ExportFormatBWF : public ExportFormat, public HasSampleForma
};
class LIBARDOUR_API ExportFormatFFMPEG : public ExportFormat {
class LIBARDOUR_API ExportFormatFFMPEG : public ExportFormat, public HasCodecQuality {
public:
ExportFormatFFMPEG (std::string const& name, std::string const& ext);
~ExportFormatFFMPEG () {};

View File

@ -287,6 +287,13 @@ ExportFormatManager::select_src_quality (ExportFormatBase::SRCQuality value)
check_for_description_change ();
}
void
ExportFormatManager::select_codec_quality (int value)
{
current_selection->set_codec_quality (value);
check_for_description_change ();
}
void
ExportFormatManager::select_with_cue (bool value)
{

View File

@ -156,7 +156,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
, _soundcloud_upload (false)
, _command ("")
, _analyse (true)
, _codec_quality (-3)
, _codec_quality (-2)
{
format_ids.insert (F_None);
endiannesses.insert (E_FileDefault);
@ -192,7 +192,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const
, _soundcloud_upload (false)
, _command ("")
, _analyse (true)
, _codec_quality (-3)
, _codec_quality (-2)
{
_silence_beginning.type = Time::Timecode;
_silence_end.type = Time::Timecode;

View File

@ -33,6 +33,13 @@ ExportFormat::has_sample_format ()
return dynamic_cast<HasSampleFormat *> (this);
}
bool
ExportFormat::has_codec_quality ()
{
return dynamic_cast<HasCodecQuality *> (this);
}
bool
ExportFormat::sample_format_is_compatible (SampleFormat format) const
{
@ -374,17 +381,33 @@ ExportFormatFFMPEG::ExportFormatFFMPEG (std::string const& name, std::string con
set_format_id (F_FFMPEG);
sample_formats.insert (SF_Float);
add_sample_rate (SR_8);
add_sample_rate (SR_22_05);
add_sample_rate (SR_44_1);
add_sample_rate (SR_48);
add_sample_rate (SR_88_2);
add_sample_rate (SR_96);
add_sample_rate (SR_176_4);
add_sample_rate (SR_192);
add_sample_rate (SR_Session);
add_endianness (E_Little);
add_codec_quality ("VBR 220-260 kb/s", 0);
add_codec_quality ("VBR 190-250 kb/s", -1);
add_codec_quality ("VBR 170-210 kb/s", -2);
add_codec_quality ("VBR 150-195 kb/s", -3);
add_codec_quality ("VBR 140-185 kb/s", -4);
add_codec_quality ("VBR 120-150 kb/s", -5);
add_codec_quality ("VBR 100-130 kb/s", -6);
add_codec_quality ("VBR 80-120 kb/s", -7);
add_codec_quality ("VBR 70-105 kb/s", -8);
add_codec_quality ("VBR 45-85 kb/s", -9);
/* Available CBR options are:
* 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320
*/
add_codec_quality ("CBR 64 kb/s", 64);
add_codec_quality ("CBR 128 kb/s", 128);
add_codec_quality ("CBR 160 kb/s", 160);
add_codec_quality ("CBR 192 kb/s", 192);
add_codec_quality ("CBR 256 kb/s", 256);
set_extension (ext);
set_quality (Q_LossyCompression);
}

View File

@ -763,6 +763,13 @@ ExportProfileManager::load_format_from_disk (std::string const & path)
ExportFormatSpecPtr format = handler->add_format (*root);
if (format->format_id() == ExportFormatBase::F_FFMPEG) {
std::string unused;
if (!ArdourVideoToolPaths::transcoder_exe (unused, unused)) {
error << string_compose (_("Ignored format '%1': encoder is not avilable"), path) << endmsg;
return;
}
}
/* Handle id to filename mapping and don't add duplicates to list */
FilePair pair (format->id(), path);