@@ -21,8 +21,10 @@ OptionLoader::OptionLoader()
21
21
, m_outputFormat( NULL )
22
22
, m_codec( NULL )
23
23
{
24
+ // Alloc format context
24
25
m_avFormatContext = avformat_alloc_context ();
25
26
27
+ // Alloc codec context
26
28
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 53, 8, 0 )
27
29
m_avCodecContext = avcodec_alloc_context ();
28
30
// deprecated in the same version
@@ -79,6 +81,77 @@ OptionLoader::OptionMap OptionLoader::loadOutputFormatOptions()
79
81
return outputFormatOptions;
80
82
}
81
83
84
+ OptionLoader::OptionMap OptionLoader::loadVideoCodecOptions ()
85
+ {
86
+ OptionMap videoCodecOptions;
87
+
88
+ m_codec = av_codec_next ( NULL );
89
+
90
+ // iterate on codecs
91
+ while ( m_codec )
92
+ {
93
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 )
94
+ if ( m_codec->encode2 )
95
+ #else
96
+ if ( m_codec->encode )
97
+ #endif
98
+ {
99
+ // add only video codec
100
+ if ( m_codec->type == AVMEDIA_TYPE_VIDEO )
101
+ {
102
+ if ( m_codec->priv_class )
103
+ {
104
+ std::string videoCodecName ( m_codec->name );
105
+ OptionArray optionsArray = loadOptions ( (void *)&m_codec->priv_class );
106
+
107
+ videoCodecOptions.insert (
108
+ std::pair< std::string, OptionArray >(
109
+ videoCodecName,
110
+ optionsArray )
111
+ );
112
+ }
113
+ }
114
+ }
115
+ m_codec = av_codec_next ( m_codec );
116
+ }
117
+ return videoCodecOptions;
118
+ }
119
+
120
+ OptionLoader::OptionMap OptionLoader::loadAudioCodecOptions ()
121
+ {
122
+ OptionMap audioCodecOptions;
123
+
124
+ m_codec = av_codec_next ( NULL );
125
+
126
+ // iterate on codecs
127
+ while ( m_codec )
128
+ {
129
+ #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 )
130
+ if ( m_codec->encode2 )
131
+ #else
132
+ if ( m_codec->encode )
133
+ #endif
134
+ {
135
+ // add only audio codec
136
+ if ( m_codec->type == AVMEDIA_TYPE_AUDIO )
137
+ {
138
+ if ( m_codec->priv_class )
139
+ {
140
+ std::string audioCodecName ( m_codec->name );
141
+ OptionArray optionsArray = loadOptions ( (void *)&m_codec->priv_class );
142
+
143
+ audioCodecOptions.insert (
144
+ std::pair< std::string, OptionArray >(
145
+ audioCodecName,
146
+ optionsArray )
147
+ );
148
+ }
149
+ }
150
+ }
151
+ m_codec = av_codec_next ( m_codec );
152
+ }
153
+ return audioCodecOptions;
154
+ }
82
155
83
156
OptionLoader::OptionArray OptionLoader::loadOptions ( void * av_class, int req_flags )
84
157
{
0 commit comments