Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5e936f

Browse files
committed
Merge pull request#198 from cchampet/dev_mimeType
InputFile/OutputFile: can get format name/long name/mime type
2 parentsae287ba +1b0f75f commitc5e936f

File tree

6 files changed

+101
-24
lines changed

6 files changed

+101
-24
lines changed

‎src/AvTranscoder/file/InputFile.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,42 @@ InputStream& InputFile::getStream( size_t index )
116116
}
117117
}
118118

119+
120+
std::stringInputFile::getFormatName()const
121+
{
122+
if( _formatContext.getAVInputFormat().name ==NULL )
123+
{
124+
LOG_WARN("Unknown demuxer format name of '" << _filename <<"'.")
125+
return"";
126+
}
127+
returnstd::string(_formatContext.getAVInputFormat().name);
128+
}
129+
130+
std::stringInputFile::getFormatLongName()const
131+
{
132+
if( _formatContext.getAVInputFormat().long_name ==NULL )
133+
{
134+
LOG_WARN("Unknown demuxer format long name of '" << _filename <<"'.")
135+
return"";
136+
}
137+
returnstd::string(_formatContext.getAVInputFormat().long_name);
138+
}
139+
140+
std::stringInputFile::getFormatMimeType()const
141+
{
142+
#if LIBAVFORMAT_VERSION_MAJOR <= 55
143+
LOG_WARN("Cannot get mime type format of '" << _filename <<"' because your libavformat library has a major version <= 55.")
144+
return"not available";
145+
#else
146+
if( _formatContext.getAVInputFormat().mime_type ==NULL )
147+
{
148+
LOG_WARN("Unknown demuxer format mime type of '" << _filename <<"'.")
149+
return"";
150+
}
151+
returnstd::string(_formatContext.getAVInputFormat().mime_type);
152+
#endif
153+
}
154+
119155
doubleInputFile::getFps()
120156
{
121157
double fps =1;

‎src/AvTranscoder/file/InputFile.hpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ class AvExport InputFile
6060
* @note Activate a stream results in buffered its data when processing
6161
**/
6262
voidactivateStream(constsize_t streamIndex,constbool activate =true );
63-
64-
/**
65-
* @return Return the resource to access
66-
**/
67-
std::stringgetFilename()const {return _filename; }
6863

6964
/**
7065
* @brief Return media properties on the current InputFile.
@@ -80,6 +75,23 @@ class AvExport InputFile
8075
**/
8176
InputStream&getStream(size_t index );
8277

78+
std::stringgetFilename()const {return _filename; }
79+
80+
/**
81+
* @brief A comma separated list of short names for the format, or empty if unknown.
82+
*/
83+
std::stringgetFormatName()const;
84+
85+
/**
86+
* @brief Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.
87+
*/
88+
std::stringgetFormatLongName()const;
89+
90+
/**
91+
* @brief Comma-separated list of mime types, or empty if unknown.
92+
*/
93+
std::stringgetFormatMimeType()const;
94+
8395
FormatContext&getFormatContext() {return _formatContext; }
8496

8597
/**

‎src/AvTranscoder/file/OutputFile.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,36 @@ IOutputStream& OutputFile::getStream( const size_t streamId )
8585
return *_outputStreams.at( streamId );
8686
}
8787

88+
std::stringOutputFile::getFormatName()const
89+
{
90+
if( _formatContext.getAVOutputFormat().name ==NULL )
91+
{
92+
LOG_WARN("Unknown muxer format name of '" << _filename <<"'.")
93+
return"";
94+
}
95+
returnstd::string(_formatContext.getAVOutputFormat().name);
96+
}
97+
98+
std::stringOutputFile::getFormatLongName()const
99+
{
100+
if( _formatContext.getAVOutputFormat().long_name ==NULL )
101+
{
102+
LOG_WARN("Unknown muxer format long name of '" << _filename <<"'.")
103+
return"";
104+
}
105+
returnstd::string(_formatContext.getAVOutputFormat().long_name);
106+
}
107+
108+
std::stringOutputFile::getFormatMimeType()const
109+
{
110+
if( _formatContext.getAVOutputFormat().mime_type ==NULL )
111+
{
112+
LOG_WARN("Unknown muxer format mime type of '" << _filename <<"'.")
113+
return"";
114+
}
115+
returnstd::string(_formatContext.getAVOutputFormat().mime_type);
116+
}
117+
88118
boolOutputFile::beginWrap( )
89119
{
90120
LOG_DEBUG("Begin wrap of OutputFile" )

‎src/AvTranscoder/file/OutputFile.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ class AvExport OutputFile : public IOutputFile
5353
voidaddMetadata(const std::string& key,const std::string& value );
5454

5555
IOutputStream&getStream(constsize_t streamId );
56+
57+
std::stringgetFilename()const {return _filename; }
58+
59+
/**
60+
* @brief A comma separated list of short names for the format, or empty if unknown.
61+
*/
62+
std::stringgetFormatName()const;
63+
64+
/**
65+
* @brief Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.
66+
*/
67+
std::stringgetFormatLongName()const;
68+
69+
/**
70+
* @brief Comma-separated list of mime types, or empty if unknown.
71+
*/
72+
std::stringgetFormatMimeType()const;
73+
5674
FormatContext&getFormatContext() {return _formatContext; }
5775

5876
/**

‎src/AvTranscoder/util.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ extern "C" {
1212
namespaceavtranscoder
1313
{
1414

15-
std::stringgetFormat(const std::string& filename )
16-
{
17-
std::stringformat("" );
18-
19-
AVOutputFormat* avOutputFormat =av_guess_format(NULL, filename.c_str(),NULL);
20-
if( avOutputFormat )
21-
{
22-
if( avOutputFormat->name )
23-
format =std::string( avOutputFormat->name );
24-
}
25-
26-
return format;
27-
}
28-
2915
boolmatchFormat(const std::string& format,const std::string& filename )
3016
{
3117
AVOutputFormat* avOutputFormat =av_guess_format( format.c_str(), filename.c_str(),NULL);

‎src/AvTranscoder/util.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ namespace avtranscoder
1919
typedef std::map<std::string, OptionArray> OptionArrayMap;
2020
typedef std::vector< std::pair<std::string, std::string> > NamesArray;//< short/long names of format/video codec/audio codec
2121

22-
/**
23-
* @brief Get format name from a given filename
24-
*/
25-
std::string AvExportgetFormat(const std::string& filename );
26-
2722
/**
2823
* @brief Check if a format name corresponds to the format of a given filename
2924
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp