Skip to content

Commit 0f56476

Browse files
author
Clement Champetier
committed
util: added getAvailableVideo/AudioFormatsNames functions
1 parent 92689e1 commit 0f56476

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

src/AvTranscoder/util.cpp

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,43 @@ NamesMap getAvailableFormatsNames()
121121
if(!fmt->name)
122122
continue;
123123

124-
formatsNames.insert(
125-
std::make_pair(std::string(fmt->name), std::string(fmt->long_name ? fmt->long_name : "")));
124+
formatsNames.insert(std::make_pair(std::string(fmt->name), std::string(fmt->long_name ? fmt->long_name : "")));
125+
}
126+
return formatsNames;
127+
}
128+
129+
NamesMap getAvailableVideoFormatsNames()
130+
{
131+
NamesMap formatsNames;
132+
133+
AVOutputFormat* fmt = NULL;
134+
while((fmt = av_oformat_next(fmt)))
135+
{
136+
if(!fmt->name)
137+
continue;
138+
139+
if(fmt->video_codec == AV_CODEC_ID_NONE)
140+
continue;
141+
142+
formatsNames.insert(std::make_pair(std::string(fmt->name), std::string(fmt->long_name ? fmt->long_name : "")));
143+
}
144+
return formatsNames;
145+
}
146+
147+
NamesMap getAvailableAudioFormatsNames()
148+
{
149+
NamesMap formatsNames;
150+
151+
AVOutputFormat* fmt = NULL;
152+
while((fmt = av_oformat_next(fmt)))
153+
{
154+
if(!fmt->name)
155+
continue;
156+
157+
if(fmt->audio_codec == AV_CODEC_ID_NONE)
158+
continue;
159+
160+
formatsNames.insert(std::make_pair(std::string(fmt->name), std::string(fmt->long_name ? fmt->long_name : "")));
126161
}
127162
return formatsNames;
128163
}
@@ -139,8 +174,7 @@ NamesMap getAvailableVideoCodecsNames()
139174
if(!c->name)
140175
continue;
141176

142-
videoCodecsNames.insert(
143-
std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
177+
videoCodecsNames.insert(std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
144178
}
145179
}
146180
return videoCodecsNames;
@@ -158,8 +192,7 @@ NamesMap getAvailableAudioCodecsNames()
158192
if(!c->name)
159193
continue;
160194

161-
audioCodecsNames.insert(
162-
std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
195+
audioCodecsNames.insert(std::make_pair(std::string(c->name), std::string(c->long_name ? c->long_name : "")));
163196
}
164197
}
165198
return audioCodecsNames;

src/AvTranscoder/util.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,31 @@ std::string AvExport getPixelFormatName(const AVPixelFormat pixelFormat);
5858
std::string AvExport getSampleFormatName(const AVSampleFormat sampleFormat);
5959

6060
/**
61-
* @brief Get a map of short/long names of all format available by FFmpeg / libav.
61+
* @brief Get a map of short/long names of all formats available by FFmpeg / libav.
6262
* @note Need to call preloadCodecsAndFormats before using this function.
6363
*/
6464
NamesMap AvExport getAvailableFormatsNames();
6565

6666
/**
67-
* @brief Get a map of short/long names of all video codec available by FFmpeg / libav.
67+
* @brief Get a map of short/long names of all formats dedicate for video available by FFmpeg / libav.
68+
* @note Need to call preloadCodecsAndFormats before using this function.
69+
*/
70+
NamesMap AvExport getAvailableVideoFormatsNames();
71+
72+
/**
73+
* @brief Get a map of short/long names of all formats dedicate for video available by FFmpeg / libav.
74+
* @note Need to call preloadCodecsAndFormats before using this function.
75+
*/
76+
NamesMap AvExport getAvailableAudioFormatsNames();
77+
78+
/**
79+
* @brief Get a map of short/long names of all video codecs available by FFmpeg / libav.
6880
* @note Need to call preloadCodecsAndFormats before using this function.
6981
*/
7082
NamesMap AvExport getAvailableVideoCodecsNames();
7183

7284
/**
73-
* @brief Get a map of short/long names of all audio codec available by FFmpeg / libav.
85+
* @brief Get a map of short/long names of all audio codecs available by FFmpeg / libav.
7486
* @note Need to call preloadCodecsAndFormats before using this function.
7587
*/
7688
NamesMap AvExport getAvailableAudioCodecsNames();

0 commit comments

Comments
 (0)