1
1
#include " InputFile.hpp"
2
2
3
3
#include < AvTranscoder/option/Context.hpp>
4
+ #include < AvTranscoder/mediaProperty/mediaProperty.hpp>
4
5
#include < AvTranscoder/mediaProperty/VideoProperties.hpp>
5
6
#include < AvTranscoder/mediaProperty/AudioProperties.hpp>
6
7
#include < AvTranscoder/mediaProperty/DataProperties.hpp>
7
8
#include < AvTranscoder/mediaProperty/SubtitleProperties.hpp>
8
9
#include < AvTranscoder/mediaProperty/AttachementProperties.hpp>
9
10
#include < AvTranscoder/mediaProperty/UnknownProperties.hpp>
10
11
11
-
12
12
extern " C" {
13
13
#include < libavcodec/avcodec.h>
14
14
#include < libavformat/avformat.h>
@@ -24,7 +24,8 @@ namespace avtranscoder
24
24
25
25
InputFile::InputFile ( const std::string& filename )
26
26
: _formatContext ( NULL )
27
- , _filename ( filename )
27
+ , _properties( NULL )
28
+ , _filename( filename )
28
29
{
29
30
av_register_all ();
30
31
if ( avformat_open_input ( &_formatContext, _filename.c_str (), NULL , NULL ) < 0 )
@@ -42,6 +43,10 @@ InputFile::InputFile( const std::string& filename )
42
43
throw std::runtime_error ( " unable to find stream informations" );
43
44
}
44
45
46
+ // Initialize FileProperties
47
+ _properties = FileProperties ( _formatContext );
48
+
49
+ // Create streams
45
50
for ( size_t streamIndex = 0 ; streamIndex < _formatContext->nb_streams ; ++streamIndex )
46
51
{
47
52
_inputStreams.push_back ( new AvInputStream ( *this , streamIndex ) );
@@ -68,56 +73,38 @@ InputFile& InputFile::analyse( IProgress& progress, const EAnalyseLevel level )
68
73
69
74
seekAtFrame ( 0 );
70
75
71
- _properties.filename = _formatContext->filename ;
72
- _properties.formatName = _formatContext->iformat ->name ;
73
- _properties.formatLongName = _formatContext->iformat ->long_name ;
74
- _properties.streamsCount = _formatContext->nb_streams ;
75
- _properties.programsCount = _formatContext->nb_programs ;
76
- _properties.startTime = 1.0 * (unsigned int )_formatContext->start_time / AV_TIME_BASE;
77
- _properties.duration = 1.0 * _formatContext->duration / AV_TIME_BASE;
78
- _properties.bitRate = _formatContext->bit_rate ;
79
- _properties.packetSize = _formatContext->packet_size ;
80
-
81
- detail::fillMetadataDictionnary ( _formatContext->metadata , _properties.metadatas );
82
-
83
76
for ( size_t streamId = 0 ; streamId < _formatContext->nb_streams ; streamId++ )
84
77
{
85
78
switch ( _formatContext->streams [streamId]->codec ->codec_type )
86
79
{
87
80
case AVMEDIA_TYPE_VIDEO:
88
81
{
89
- _properties.videoStreams .push_back ( videoStreamInfo ( _formatContext, streamId, progress, level ) );
90
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.videoStreams .back ().metadatas );
82
+ _properties.getVideoProperties ().push_back ( VideoProperties ( _formatContext, streamId, progress ) );
91
83
break ;
92
84
}
93
85
case AVMEDIA_TYPE_AUDIO:
94
86
{
95
- _properties.audioStreams .push_back ( audioStreamInfo ( _formatContext, streamId ) );
96
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.audioStreams .back ().metadatas );
87
+ _properties.getAudioProperties ().push_back ( AudioProperties ( _formatContext, streamId ) );
97
88
break ;
98
89
}
99
90
case AVMEDIA_TYPE_DATA:
100
91
{
101
- _properties.dataStreams .push_back ( dataStreamInfo ( _formatContext, streamId ) );
102
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.dataStreams .back ().metadatas );
92
+ _properties.getDataProperties ().push_back ( DataProperties ( _formatContext, streamId ) );
103
93
break ;
104
94
}
105
95
case AVMEDIA_TYPE_SUBTITLE:
106
96
{
107
- _properties.subtitleStreams .push_back ( subtitleStreamInfo ( _formatContext, streamId ) );
108
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.subtitleStreams .back ().metadatas );
97
+ _properties.getSubtitleProperties ().push_back ( SubtitleProperties ( _formatContext, streamId ) );
109
98
break ;
110
99
}
111
100
case AVMEDIA_TYPE_ATTACHMENT:
112
101
{
113
- _properties.attachementStreams .push_back ( attachementStreamInfo ( _formatContext, streamId ) );
114
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.attachementStreams .back ().metadatas );
102
+ _properties.getAttachementProperties ().push_back ( AttachementProperties ( _formatContext, streamId ) );
115
103
break ;
116
104
}
117
105
case AVMEDIA_TYPE_UNKNOWN:
118
106
{
119
- _properties.unknownStreams .push_back ( unknownStreamInfo ( _formatContext, streamId ) );
120
- detail::fillMetadataDictionnary ( _formatContext->streams [streamId]->metadata , _properties.unknownStreams .back ().metadatas );
107
+ _properties.getUnknownPropertiesProperties ().push_back ( UnknownProperties ( _formatContext, streamId ) );
121
108
break ;
122
109
}
123
110
case AVMEDIA_TYPE_NB:
@@ -132,13 +119,11 @@ InputFile& InputFile::analyse( IProgress& progress, const EAnalyseLevel level )
132
119
return *this ;
133
120
}
134
121
135
- Properties InputFile::analyseFile ( const std::string& filename, IProgress& progress, const EAnalyseLevel level )
122
+ FileProperties InputFile::analyseFile ( const std::string& filename, IProgress& progress, const EAnalyseLevel level )
136
123
{
137
124
InputFile file ( filename );
138
125
file.analyse ( progress, level );
139
- Properties properties;
140
- file.getProperties ( properties );
141
- return properties;
126
+ return file.getProperties ();
142
127
}
143
128
144
129
AVMediaType InputFile::getStreamType ( size_t index )
@@ -229,9 +214,9 @@ void InputFile::setProfile( const ProfileLoader::Profile& profile )
229
214
}
230
215
catch ( std::exception& e )
231
216
{
232
- std::cout << " [InputFile] warning - can't set option " << (*it). first << " to " << (*it). second << " : " << e.what () << std::endl;
217
+ std::cout << " [InputFile] warning: " << e.what () << std::endl;
233
218
}
234
219
}
235
220
}
236
221
237
- }
222
+ }
0 commit comments