Skip to content

Commit f754f90

Browse files
author
Clement Champetier
committed
Description: add getOutputExtensions
1 parent 37d8ea1 commit f754f90

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/AvTranscoder/Description.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,40 @@ std::vector<std::string> getInputExtensions()
6868

6969
std::vector<std::string> getOutputExtensions()
7070
{
71+
av_register_all();
7172
std::vector<std::string> extensions;
73+
AVOutputFormat* oFormat = NULL;
7274

75+
while( ( oFormat = av_oformat_next( oFormat ) ) )
76+
{
77+
if( oFormat->extensions != NULL )
78+
{
79+
// parse extensions
80+
std::string exts = std::string( oFormat->extensions );
81+
char* ext = strtok( const_cast<char*>( exts.c_str() ), "," );
82+
while( ext != NULL )
83+
{
84+
extensions.push_back( std::string( ext ) );
85+
ext = strtok( NULL, "," );
86+
}
87+
88+
// parse name (name's format defines (in general) extensions )
89+
// don't need to do it in recent LibAV/FFMpeg versions
90+
exts = std::string( oFormat->name );
91+
ext = strtok( const_cast<char*>( exts.c_str() ), "," );
92+
while( ext != NULL )
93+
{
94+
extensions.push_back( std::string( ext ) );
95+
ext = strtok( NULL, "," );
96+
}
97+
}
98+
}
99+
// sort
100+
std::sort( extensions.begin(), extensions.end() );
101+
// suppress duplicates
102+
std::vector<std::string>::iterator last = std::unique( extensions.begin(), extensions.end() );
103+
extensions.erase( last, extensions.end() );
104+
73105
return extensions;
74106
}
75107

0 commit comments

Comments
 (0)