File tree Expand file tree Collapse file tree 6 files changed +101
-24
lines changed Expand file tree Collapse file tree 6 files changed +101
-24
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,42 @@ InputStream& InputFile::getStream( size_t index )
116
116
}
117
117
}
118
118
119
+
120
+ std::string InputFile::getFormatName () const
121
+ {
122
+ if ( _formatContext.getAVInputFormat ().name == NULL )
123
+ {
124
+ LOG_WARN (" Unknown demuxer format name of '" << _filename << " '." )
125
+ return " " ;
126
+ }
127
+ return std::string (_formatContext.getAVInputFormat ().name );
128
+ }
129
+
130
+ std::string InputFile::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
+ return std::string (_formatContext.getAVInputFormat ().long_name );
138
+ }
139
+
140
+ std::string InputFile::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
+ return std::string (_formatContext.getAVInputFormat ().mime_type );
152
+ #endif
153
+ }
154
+
119
155
double InputFile::getFps ()
120
156
{
121
157
double fps = 1 ;
Original file line number Diff line number Diff line change @@ -60,11 +60,6 @@ class AvExport InputFile
60
60
* @note Activate a stream results in buffered its data when processing
61
61
**/
62
62
void activateStream ( const size_t streamIndex, const bool activate = true );
63
-
64
- /* *
65
- * @return Return the resource to access
66
- **/
67
- std::string getFilename () const { return _filename; }
68
63
69
64
/* *
70
65
* @brief Return media properties on the current InputFile.
@@ -80,6 +75,23 @@ class AvExport InputFile
80
75
**/
81
76
InputStream& getStream ( size_t index );
82
77
78
+ std::string getFilename () const { return _filename; }
79
+
80
+ /* *
81
+ * @brief A comma separated list of short names for the format, or empty if unknown.
82
+ */
83
+ std::string getFormatName () 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::string getFormatLongName () const ;
89
+
90
+ /* *
91
+ * @brief Comma-separated list of mime types, or empty if unknown.
92
+ */
93
+ std::string getFormatMimeType () const ;
94
+
83
95
FormatContext& getFormatContext () { return _formatContext; }
84
96
85
97
/* *
Original file line number Diff line number Diff line change @@ -85,6 +85,36 @@ IOutputStream& OutputFile::getStream( const size_t streamId )
85
85
return *_outputStreams.at ( streamId );
86
86
}
87
87
88
+ std::string OutputFile::getFormatName () const
89
+ {
90
+ if ( _formatContext.getAVOutputFormat ().name == NULL )
91
+ {
92
+ LOG_WARN (" Unknown muxer format name of '" << _filename << " '." )
93
+ return " " ;
94
+ }
95
+ return std::string (_formatContext.getAVOutputFormat ().name );
96
+ }
97
+
98
+ std::string OutputFile::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
+ return std::string (_formatContext.getAVOutputFormat ().long_name );
106
+ }
107
+
108
+ std::string OutputFile::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
+ return std::string (_formatContext.getAVOutputFormat ().mime_type );
116
+ }
117
+
88
118
bool OutputFile::beginWrap ( )
89
119
{
90
120
LOG_DEBUG ( " Begin wrap of OutputFile" )
Original file line number Diff line number Diff line change @@ -53,6 +53,24 @@ class AvExport OutputFile : public IOutputFile
53
53
void addMetadata ( const std::string& key, const std::string& value );
54
54
55
55
IOutputStream& getStream ( const size_t streamId );
56
+
57
+ std::string getFilename () const { return _filename; }
58
+
59
+ /* *
60
+ * @brief A comma separated list of short names for the format, or empty if unknown.
61
+ */
62
+ std::string getFormatName () 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::string getFormatLongName () const ;
68
+
69
+ /* *
70
+ * @brief Comma-separated list of mime types, or empty if unknown.
71
+ */
72
+ std::string getFormatMimeType () const ;
73
+
56
74
FormatContext& getFormatContext () { return _formatContext; }
57
75
58
76
/* *
Original file line number Diff line number Diff line change @@ -12,20 +12,6 @@ extern "C" {
12
12
namespace avtranscoder
13
13
{
14
14
15
- std::string getFormat ( const std::string& filename )
16
- {
17
- std::string format ( " " );
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
-
29
15
bool matchFormat ( const std::string& format, const std::string& filename )
30
16
{
31
17
AVOutputFormat* avOutputFormat = av_guess_format ( format.c_str (), filename.c_str (), NULL );
Original file line number Diff line number Diff line change @@ -19,11 +19,6 @@ namespace avtranscoder
19
19
typedef std::map<std::string, OptionArray> OptionArrayMap;
20
20
typedef std::vector< std::pair<std::string, std::string> > NamesArray; // < short/long names of format/video codec/audio codec
21
21
22
- /* *
23
- * @brief Get format name from a given filename
24
- */
25
- std::string AvExport getFormat ( const std::string& filename );
26
-
27
22
/* *
28
23
* @brief Check if a format name corresponds to the format of a given filename
29
24
*/
You can’t perform that action at this time.
0 commit comments