Skip to content

Commit 4690467

Browse files
author
Clement Champetier
committed
OptionLoader: add getters for short/long names of video/audio codecs
1 parent 2489b7f commit 4690467

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/AvTranscoder/OptionLoader.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ OptionLoader::OptionLoader()
2222
, m_codec( NULL )
2323
, m_formatsLongNames()
2424
, m_formatsShortNames()
25+
, m_videoCodecsLongNames()
26+
, m_videoCodecsShortNames()
27+
, m_audioCodecsLongNames()
28+
, m_audioCodecsShortNames()
2529
{
2630
// Alloc format context
2731
m_avFormatContext = avformat_alloc_context();
@@ -50,6 +54,42 @@ OptionLoader::OptionLoader()
5054
}
5155
}
5256
}
57+
58+
// fill video and audio codec short and long names
59+
AVCodec* c = NULL;
60+
while( ( c = av_codec_next( c ) ) )
61+
{
62+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 )
63+
if( c->encode2 )
64+
#else
65+
if( c->encode )
66+
#endif
67+
{
68+
switch( c->type )
69+
{
70+
case AVMEDIA_TYPE_VIDEO:
71+
{
72+
if( c->long_name )
73+
{
74+
m_videoCodecsLongNames.push_back( std::string( c->long_name ) );
75+
m_videoCodecsShortNames.push_back( std::string( c->name ) );
76+
}
77+
break;
78+
}
79+
case AVMEDIA_TYPE_AUDIO:
80+
{
81+
if( c->long_name )
82+
{
83+
m_audioCodecsLongNames.push_back( std::string( c->long_name ) );
84+
m_audioCodecsShortNames.push_back( std::string( c->name ) );
85+
}
86+
break;
87+
}
88+
default:
89+
break;
90+
}
91+
}
92+
}
5393
}
5494

5595
OptionLoader::~OptionLoader()

src/AvTranscoder/OptionLoader.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class OptionLoader
5454

5555
std::vector<std::string>& getFormatsLongNames() { return m_formatsLongNames; }
5656
std::vector<std::string>& getFormatsShortNames() { return m_formatsShortNames; }
57+
58+
std::vector<std::string>& getVideoCodecsLongNames() { return m_videoCodecsLongNames; }
59+
std::vector<std::string>& getVideoCodecsShortNames() { return m_videoCodecsShortNames; }
60+
61+
std::vector<std::string>& getAudioCodecsLongNames() { return m_audioCodecsLongNames; }
62+
std::vector<std::string>& getAudioCodecsShortNames() { return m_audioCodecsShortNames; }
63+
5764
private:
5865
/**
5966
* @brief: load array of Option depending on the flags.
@@ -69,6 +76,12 @@ class OptionLoader
6976

7077
std::vector<std::string> m_formatsLongNames;
7178
std::vector<std::string> m_formatsShortNames;
79+
80+
std::vector<std::string> m_videoCodecsLongNames;
81+
std::vector<std::string> m_videoCodecsShortNames;
82+
83+
std::vector<std::string> m_audioCodecsLongNames;
84+
std::vector<std::string> m_audioCodecsShortNames;
7285

7386
};
7487

0 commit comments

Comments
 (0)