14 : _formatContext(&formatContext)
15 , _avFormatContext(&formatContext.getAVFormatContext())
20 , _attachementStreams()
44 case AVMEDIA_TYPE_VIDEO:
50 case AVMEDIA_TYPE_AUDIO:
56 case AVMEDIA_TYPE_DATA:
62 case AVMEDIA_TYPE_SUBTITLE:
68 case AVMEDIA_TYPE_ATTACHMENT:
74 case AVMEDIA_TYPE_UNKNOWN:
88 for(
size_t streamIndex = 0; streamIndex <
_videoStreams.size(); ++streamIndex)
90 const size_t videoStreamIndex =
_videoStreams.at(streamIndex).getStreamIndex();
94 for(
size_t streamIndex = 0; streamIndex <
_audioStreams.size(); ++streamIndex)
96 const size_t audioStreamIndex =
_audioStreams.at(streamIndex).getStreamIndex();
100 for(
size_t streamIndex = 0; streamIndex <
_dataStreams.size(); ++streamIndex)
102 const size_t dataStreamIndex =
_dataStreams.at(streamIndex).getStreamIndex();
106 for(
size_t streamIndex = 0; streamIndex <
_subtitleStreams.size(); ++streamIndex)
108 const size_t subtitleStreamIndex =
_subtitleStreams.at(streamIndex).getStreamIndex();
114 const size_t attachementStreamIndex =
_attachementStreams.at(streamIndex).getStreamIndex();
118 for(
size_t streamIndex = 0; streamIndex <
_unknownStreams.size(); ++streamIndex)
120 const size_t unknownStreamIndex =
_unknownStreams.at(streamIndex).getStreamIndex();
132 throw std::runtime_error(
"unknown file name");
139 throw std::runtime_error(
"unknown format name");
146 throw std::runtime_error(
"unknown format long name");
162 #if LIBAVFORMAT_VERSION_MAJOR <= 55
163 throw std::runtime_error(
"cannot get mime type format: libavformat library has a major version <= 55.");
166 throw std::runtime_error(
"Unknown demuxer format mime type");
174 throw std::runtime_error(
"unknown format context");
181 throw std::runtime_error(
"unknown format context");
188 throw std::runtime_error(
"unknown format context");
195 throw std::runtime_error(
"unknown format context");
202 throw std::runtime_error(
"unknown format context");
211 std::stringstream os;
212 os <<
"No stream properties correspond to stream at index ";
214 throw std::runtime_error(os.str());
219 std::vector<avtranscoder::StreamProperties*> streams;
220 for(std::map<size_t, StreamProperties*>::const_iterator it =
_streams.begin(); it !=
_streams.end(); ++it)
222 streams.push_back(it->second);
230 throw std::runtime_error(
"unknown format context");
260 for(
size_t metadataIndex = 0; metadataIndex <
_metadatas.size(); ++metadataIndex)
273 for(PropertyVector::const_iterator it = dataVector.begin(); it != dataVector.end(); ++it)
275 dataMap.insert(std::make_pair(it->first, it->second));
285 for(PropertyMap::iterator it = properties.begin(); it != properties.end(); ++it)
286 writer << std::make_pair(it->first.c_str(), it->second.c_str());
287 return writer.
build();
297 writer << std::make_pair(
"format", format.
build());
305 video << it->asJson();
307 writer << std::make_pair(
"video", video.
build());
315 audio << it->asJson();
317 writer << std::make_pair(
"audio", audio.
build());
325 data << it->asJson();
327 writer << std::make_pair(
"data", data.
build());
332 for(std::vector<avtranscoder::SubtitleProperties>::const_iterator it =
_subtitleStreams.begin();
335 subtitle << it->asJson();
337 writer << std::make_pair(
"subtitle", subtitle.
build());
342 for(std::vector<avtranscoder::AttachementProperties>::const_iterator it =
_attachementStreams.begin();
345 attachement << it->asJson();
347 writer << std::make_pair(
"attachement", attachement.
build());
352 for(std::vector<avtranscoder::UnknownProperties>::const_iterator it =
_unknownStreams.begin();
355 unknown << it->asJson();
357 writer << std::make_pair(
"unknown", unknown.
build());
359 return writer.
build();
380 for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
382 flux << std::setw(
detail::keyWidth) << it->first <<
": " << it->second << std::endl;
double getStartTime() const
size_t getBitRate() const
total stream bitrate in bit/s, 0 if not available (result of a computation by ffmpeg) ...
Base class of Progress. Inherit this class to have your own way to manage a progress bar...
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
EAnalyseLevel
Level of file analysis.
std::vector< DataProperties > _dataStreams
Array of properties per data stream.
PropertyMap asMap() const
Return format properties as a map (name of property, value)
bool isRawFormat() const
Is there a container, or a raw bitstreams without access to timing information.
size_t getNbStreams() const
void extractStreamProperties(IProgress &progress, const EAnalyseLevel level)
Relaunch streams analysis with a specific level.
Write an array to a stream.
std::vector< AttachementProperties > _attachementStreams
Array of properties per attachement stream.
const std::string separator
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
std::string getFilename() const
size_t getNbSubtitleStreams() const
std::vector< SubtitleProperties > _subtitleStreams
Array of properties per subtitle stream.
void fillMetadataDictionnary(AVDictionary *avdictionnary, PropertyVector &metadata)
Fill metadata parameter with the given AVDictionary.
std::string allPropertiesAsJson() const
Return all properties as a json format.
std::string getFormatLongName() const
Descriptive name for the format, meant to be more human-readable than name, or empty if unknown...
const std::vector< avtranscoder::StreamProperties * > getStreamProperties() const
std::map< size_t, StreamProperties * > _streams
Map of properties per stream index (of all types) - only references to the following properties...
const avtranscoder::StreamProperties & getStreamPropertiesWithIndex(const size_t streamIndex) const
virtual std::string build()
void addProperty(PropertyVector &data, const std::string &key, T(FileProperties::*getter)(void) const) const
std::map< std::string, std::string > PropertyMap
size_t getNbAudioStreams() const
PropertyVector _metadatas
std::string getFormatMimeType() const
Comma-separated list of mime types, or empty if unknown.
size_t getPacketSize() const
std::vector< AudioProperties > _audioStreams
Array of properties per audio stream.
PropertyVector asVector() const
Return format properties as a vector (name of property: value)
Wrapper of an AVFormatContext.
std::string getFormatName() const
A comma separated list of short names for the format, or empty if unknown.
std::vector< UnknownProperties > _unknownStreams
Array of properties per unknown stream.
std::vector< VideoProperties > _videoStreams
Array of properties per video stream.
size_t getNbAttachementStreams() const
Virtual based class of properties for all types of stream.
size_t getNbDataStreams() const
size_t getProgramsCount() const
std::string asJson() const
Return all format properties as a json format.
Write an object to a stream.
size_t getNbUnknownStreams() const
size_t getNbStreams() const
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
const AVFormatContext * _avFormatContext
Has link (no ownership)
PropertyVector & fillVector(PropertyVector &data) const
To avoid copy of the vector.
const FormatContext * _formatContext
Has link (no ownership)
float getDuration() const
in seconds
Implementation of IProgress, to manage cases when we need an IProgress but don't care of a progress b...
FileProperties(const FormatContext &formatContext)
Analayse a file from its FormatContext.
AVStream & getAVStream(size_t index) const
size_t getNbVideoStreams() const
void clearStreamProperties()
Clear all array of stream properties.