AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VideoProperties.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_MEDIA_PROPERTY_VIDEO_PROPERTIES_HPP
2 #define _AV_TRANSCODER_MEDIA_PROPERTY_VIDEO_PROPERTIES_HPP
3 
4 #include "PixelProperties.hpp"
5 
9 
10 extern "C" {
11 #include <libavcodec/avcodec.h>
12 }
13 
14 #include <string>
15 #include <vector>
16 #include <utility>
17 
18 namespace avtranscoder
19 {
20 
21 class AvExport VideoProperties : public StreamProperties
22 {
23 public:
24  VideoProperties(const FormatContext& formatContext, const size_t index, IProgress& progress,
25  const EAnalyseLevel level = eAnalyseLevelFirstGop);
26 
27  std::string getProfileName() const;
28  std::string getColorTransfert() const;
29  std::string getColorspace() const;
30  std::string getColorRange() const;
31  std::string getColorPrimaries() const;
32  std::string getChromaSampleLocation() const;
33  std::string getFieldOrder() const;
34 
35  PixelProperties& getPixelProperties() { return _pixelProperties; }
36 
37  int64_t getStartTimecode() const;
38  std::string getStartTimecodeString() const;
39 
40  Rational getSar() const; // sample/pixel aspect ratio
41  Rational getDar() const; // display aspect ratio
42 
43  size_t getBitRate() const; ///< in bits/s
44  size_t getMaxBitRate() const;
45  size_t getMinBitRate() const;
46  size_t getNbFrames() const;
47  size_t getTicksPerFrame() const;
48  size_t getWidth() const;
49  size_t getHeight() const;
50  size_t getDtgActiveFormat() const;
51  size_t getReferencesFrames() const;
52  int getProfile() const;
53  int getLevel() const;
54 
55  /**
56  * @brief Corresponds to the 'fps' returned by ffprobe.
57  * fps = the average framerate that has come from the AVStream
58  * tbn = the time base in AVStream that has come from the AVStream
59  * tbc = the time base in AVCodecContext for the codec used for a particular stream
60  * tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate
61  */
62  float getFps() const;
63 
64  bool hasBFrames() const;
65  // bool isClosedGop() const;
66 
67  //@{
68  // Warning: Can acces these data when analyse first gop
69  // @see EAnalyseLevel
70  // @see analyseGopStructure
71  bool isInterlaced() const { return _isInterlaced; }
72  bool isTopFieldFirst() const { return _isTopFieldFirst; }
73  /**
74  * @return the distance between two nearest I frame
75  */
76  size_t getGopSize() const { return _gopSize; }
77  std::vector<std::pair<char, int> > getGopStructure() const { return _gopStructure; }
78 //@}
79 
80 #ifndef SWIG
81  AVCodecContext& getAVCodecContext() { return *_codecContext; }
82  const PixelProperties& getPixelProperties() const { return _pixelProperties; }
83 #endif
84 
85  PropertyVector& fillVector(PropertyVector& data) const;
86 
87 private:
88  /**
89  * @brief frame type / is key frame
90  * @param progress: callback to get analysis progression
91  */
92  void analyseGopStructure(IProgress& progress);
93 
94 #ifndef SWIG
95  template <typename T>
96  void addProperty(PropertyVector& dataVector, const std::string& key, T (VideoProperties::*getter)(void) const) const
97  {
98  try
99  {
100  detail::add(dataVector, key, (this->*getter)());
101  }
102  catch(const std::exception& e)
103  {
104  detail::add(dataVector, key, detail::propertyValueIfError);
105  }
106  }
107 #endif
108 
109 private:
110  /**
111  * @brief Level of analysis asked.
112  */
114 
115  /**
116  * @brief All the pixel properties contained in this stream.
117  */
119 
120  //@{
121  // Can acces these data when analyse first gop
124  size_t _gopSize;
125  std::vector<std::pair<char, int> > _gopStructure; ///< picture type, encoded frame size in bytes
126  //@}
127 
128  /**
129  * @brief GOP timecode of the first frame
130  * @note AVCodecContext stores the GOP timecode of the last decoded frame
131  */
133 };
134 
135 #ifndef SWIG
136 AvExport std::ostream& operator<<(std::ostream& flux, const StreamProperties& streamProperties);
137 #endif
138 }
139 
140 #endif
Base class of Progress. Inherit this class to have your own way to manage a progress bar...
Definition: IProgress.hpp:23
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< std::pair< char, int > > _gopStructure
picture type, encoded frame size in bytes
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
Definition: util.cpp:16
void addProperty(PropertyVector &dataVector, const std::string &key, T(VideoProperties::*getter)(void) const) const
AVCodecContext & getAVCodecContext()
Wrapper of an AVFormatContext.
EAnalyseLevel _levelAnalysis
Level of analysis asked.
const PixelProperties & getPixelProperties() const
int64_t _firstGopTimeCode
GOP timecode of the first frame.
PixelProperties & getPixelProperties()
Virtual based class of properties for all types of stream.
std::vector< std::pair< char, int > > getGopStructure() const
AVRational Rational
Definition: common.hpp:55
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
Definition: InputFile.cpp:171
const std::string propertyValueIfError
Definition: util.hpp:38
PixelProperties _pixelProperties
All the pixel properties contained in this stream.
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