AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileProperties.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_MEDIA_PROPERTY_FILE_PROPERTIES_HPP
2 #define _AV_TRANSCODER_MEDIA_PROPERTY_FILE_PROPERTIES_HPP
3 
8 
16 
17 #include <string>
18 #include <vector>
19 #include <map>
20 
21 namespace avtranscoder
22 {
23 
24 class AvExport FileProperties
25 {
26 public:
27  /**
28  * @brief Analayse a file from its FormatContext
29  * @note The default streams analyse level is eAnalyseLevelHeader
30  * @see FormatContext
31  */
32  FileProperties(const FormatContext& formatContext);
33 
34  /**
35  * @brief Relaunch streams analysis with a specific level.
36  * @param progress callback to get analysis progression
37  * @param level of analysis
38  */
39  void extractStreamProperties(IProgress& progress, const EAnalyseLevel level);
40 
41  std::string getFilename() const;
42  std::string getFormatName() const; ///< A comma separated list of short names for the format, or empty if unknown.
43  std::string getFormatLongName() const; ///< Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.
44  bool isRawFormat() const; ///< Is there a container, or a raw bitstreams without access to timing information.
45  std::string getFormatMimeType() const; ///< Comma-separated list of mime types, or empty if unknown.
46 
47  size_t getProgramsCount() const;
48  double getStartTime() const;
49  float getDuration() const; ///< in seconds
50  size_t getBitRate() const; ///< total stream bitrate in bit/s, 0 if not available (result of a computation by ffmpeg)
51  size_t getPacketSize() const;
52 
53  const PropertyVector& getMetadatas() const { return _metadatas; }
54 
55  size_t getNbStreams() const;
56  size_t getNbVideoStreams() const { return _videoStreams.size(); }
57  size_t getNbAudioStreams() const { return _audioStreams.size(); }
58  size_t getNbDataStreams() const { return _dataStreams.size(); }
59  size_t getNbSubtitleStreams() const { return _subtitleStreams.size(); }
60  size_t getNbAttachementStreams() const { return _attachementStreams.size(); }
61  size_t getNbUnknownStreams() const { return _unknownStreams.size(); }
62 
63  const FormatContext& getFormatContext() { return *_formatContext; }
64 
65  //@{
66  // @brief Get the properties at the indicated stream index
67  // @throws A runtime error if the streamIndex does not match any stream
68  const avtranscoder::StreamProperties& getStreamPropertiesWithIndex(const size_t streamIndex) const;
69  //@}
70 
71  //@{
72  // @brief Get the list of properties for a given type (video, audio...)
73  const std::vector<avtranscoder::StreamProperties*> getStreamProperties() const;
74  const std::vector<avtranscoder::VideoProperties>& getVideoProperties() const { return _videoStreams; }
75  const std::vector<avtranscoder::AudioProperties>& getAudioProperties() const { return _audioStreams; }
76  const std::vector<avtranscoder::DataProperties>& getDataProperties() const { return _dataStreams; }
77  const std::vector<avtranscoder::SubtitleProperties>& getSubtitleProperties() const { return _subtitleStreams; }
78  const std::vector<avtranscoder::AttachementProperties>& getAttachementProperties() const { return _attachementStreams; }
79  const std::vector<avtranscoder::UnknownProperties>& getUnknownProperties() const { return _unknownStreams; }
80 //@}
81 
82 #ifndef SWIG
83  const AVFormatContext& getAVFormatContext() { return *_avFormatContext; }
84 #endif
85 
86  std::string allPropertiesAsJson() const; ///< Return all properties as a json format.
87  std::string asJson() const; ///< Return all format properties as a json format.
88  PropertyMap asMap() const; ///< Return format properties as a map (name of property, value)
89  PropertyVector asVector() const; ///< Return format properties as a vector (name of property: value)
90  PropertyVector& fillVector(PropertyVector& data) const; ///< To avoid copy of the vector
91 
92 private:
93 #ifndef SWIG
94  template <typename T>
95  void addProperty(PropertyVector& data, const std::string& key, T (FileProperties::*getter)(void) const) const
96  {
97  try
98  {
99  detail::add(data, key, (this->*getter)());
100  }
101  catch(const std::exception& e)
102  {
104  }
105  }
106 #endif
107 
108  void clearStreamProperties(); ///< Clear all array of stream properties
109 
110 private:
111  const FormatContext* _formatContext; ///< Has link (no ownership)
112  const AVFormatContext* _avFormatContext; ///< Has link (no ownership)
113 
114  std::map<size_t, StreamProperties*>
115  _streams; ///< Map of properties per stream index (of all types) - only references to the following properties
116 
117  std::vector<VideoProperties> _videoStreams; ///< Array of properties per video stream
118  std::vector<AudioProperties> _audioStreams; ///< Array of properties per audio stream
119  std::vector<DataProperties> _dataStreams; ///< Array of properties per data stream
120  std::vector<SubtitleProperties> _subtitleStreams; ///< Array of properties per subtitle stream
121  std::vector<AttachementProperties> _attachementStreams; ///< Array of properties per attachement stream
122  std::vector<UnknownProperties> _unknownStreams; ///< Array of properties per unknown stream
123 
125 };
126 
127 #ifndef SWIG
128 AvExport std::ostream& operator<<(std::ostream& flux, const FileProperties& fileProperties);
129 #endif
130 }
131 
132 #endif
const std::vector< avtranscoder::AudioProperties > & getAudioProperties() const
const std::vector< avtranscoder::UnknownProperties > & getUnknownProperties() const
Base class of Progress. Inherit this class to have your own way to manage a progress bar...
Definition: IProgress.hpp:23
const std::vector< avtranscoder::VideoProperties > & getVideoProperties() const
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
Definition: util.hpp:23
EAnalyseLevel
Level of file analysis.
Definition: util.hpp:10
std::vector< DataProperties > _dataStreams
Array of properties per data stream.
const std::vector< avtranscoder::SubtitleProperties > & getSubtitleProperties() const
std::vector< AttachementProperties > _attachementStreams
Array of properties per attachement stream.
const std::vector< avtranscoder::AttachementProperties > & getAttachementProperties() const
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
Definition: util.cpp:16
const PropertyVector & getMetadatas() const
size_t getNbSubtitleStreams() const
std::vector< SubtitleProperties > _subtitleStreams
Array of properties per subtitle stream.
const AVFormatContext & getAVFormatContext()
std::map< size_t, StreamProperties * > _streams
Map of properties per stream index (of all types) - only references to the following properties...
void addProperty(PropertyVector &data, const std::string &key, T(FileProperties::*getter)(void) const) const
std::map< std::string, std::string > PropertyMap
Definition: util.hpp:24
const FormatContext & getFormatContext()
std::vector< AudioProperties > _audioStreams
Array of properties per audio stream.
const std::vector< avtranscoder::DataProperties > & getDataProperties() const
Wrapper of an AVFormatContext.
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 getNbUnknownStreams() const
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
Definition: InputFile.cpp:171
const AVFormatContext * _avFormatContext
Has link (no ownership)
const FormatContext * _formatContext
Has link (no ownership)
const std::string propertyValueIfError
Definition: util.hpp:38
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy