Skip to content

Commit 2489b7f

Browse files
author
Clement Champetier
committed
OptionLoader: add getters for short/long names of format
1 parent 44f1f41 commit 2489b7f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/AvTranscoder/OptionLoader.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ OptionLoader::OptionLoader()
2020
, m_avCodecContext( NULL )
2121
, m_outputFormat( NULL )
2222
, m_codec( NULL )
23+
, m_formatsLongNames()
24+
, m_formatsShortNames()
2325
{
2426
// Alloc format context
2527
m_avFormatContext = avformat_alloc_context();
@@ -33,6 +35,21 @@ OptionLoader::OptionLoader()
3335
AVCodec* avCodec = NULL;
3436
m_avCodecContext = avcodec_alloc_context3( avCodec );
3537
#endif
38+
39+
// fill format short and long names
40+
AVOutputFormat* fmt = NULL;
41+
while( ( fmt = av_oformat_next( fmt ) ) )
42+
{
43+
// add only format with video track
44+
if( fmt->video_codec != AV_CODEC_ID_NONE )
45+
{
46+
if( fmt->long_name )
47+
{
48+
m_formatsLongNames.push_back( std::string( fmt->long_name ) + std::string( " (" ) + std::string( fmt->name ) + std::string( ")" ) );
49+
m_formatsShortNames.push_back( std::string( fmt->name ) );
50+
}
51+
}
52+
}
3653
}
3754

3855
OptionLoader::~OptionLoader()

src/AvTranscoder/OptionLoader.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class OptionLoader
5151
OptionMap loadOutputFormatOptions();
5252
OptionMap loadVideoCodecOptions();
5353
OptionMap loadAudioCodecOptions();
54+
55+
std::vector<std::string>& getFormatsLongNames() { return m_formatsLongNames; }
56+
std::vector<std::string>& getFormatsShortNames() { return m_formatsShortNames; }
5457
private:
5558
/**
5659
* @brief: load array of Option depending on the flags.
@@ -63,6 +66,9 @@ class OptionLoader
6366

6467
AVOutputFormat* m_outputFormat;
6568
AVCodec* m_codec;
69+
70+
std::vector<std::string> m_formatsLongNames;
71+
std::vector<std::string> m_formatsShortNames;
6672

6773
};
6874

0 commit comments

Comments
 (0)