AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OutputFile.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_FILE_OUTPUT_FILE_HPP_
2 #define _AV_TRANSCODER_FILE_OUTPUT_FILE_HPP_
3 
5 
8 
9 #include <vector>
10 
11 namespace avtranscoder
12 {
13 
14 /**
15  * @brief Outputfile is the default implentation of wrapper which uses LibAV/FFMpeg.
16  **/
17 class AvExport OutputFile : public IOutputFile
18 {
19 private:
20  OutputFile(const OutputFile& outputFile);
21  OutputFile& operator=(const OutputFile& outputFile);
22 
23 public:
24  /**
25  * @brief Create an output media file.
26  * @param filename resource to access
27  * @param formatName should matches with the names of the registered formats
28  * @param mimeType should matches with the MIME type of the registered formats
29  * @note The caller should indicate formatName and/or mimeType if the filename has no extension.
30  * @note The ressource is allocated when beginWrap.
31  * @see beginWrap
32  **/
33  OutputFile(const std::string& filename, const std::string& formatName = "", const std::string& mimeType = "");
34 
35  ~OutputFile();
36 
37  IOutputStream& addVideoStream(const VideoCodec& videoDesc);
38  IOutputStream& addAudioStream(const AudioCodec& audioDesc);
39  IOutputStream& addDataStream(const DataCodec& dataDesc);
40 
41  /**
42  * @brief Open ressource, write header, and setup specific wrapping options given when call setupWrapping.
43  * @note Need to add the streams to mux before calling this method.
44  * @note After this call, a new list of AVOption, relative to the format choosen, will be available for the OutputFile.
45  */
46  bool beginWrap();
47 
48  IOutputStream::EWrappingStatus wrap(const CodedData& data, const size_t streamIndex);
49 
50  /**
51  * @brief Close ressource and write trailer.
52  */
53  bool endWrap();
54 
55  /**
56  * @brief Add metadata to the output file.
57  * @note Depending on the format, you are not sure to find your metadata after the transcode.
58  */
59  void addMetadata(const PropertyVector& data);
60  void addMetadata(const std::string& key, const std::string& value);
61 
62  IOutputStream& getStream(const size_t streamIndex);
63 
64  std::string getFilename() const;
65 
66  /**
67  * @brief A comma separated list of short names for the format, or empty if unknown.
68  */
69  std::string getFormatName() const;
70 
71  /**
72  * @brief Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.
73  */
74  std::string getFormatLongName() const;
75 
76  /**
77  * @brief Comma-separated list of mime types, or empty if unknown.
78  */
79  std::string getFormatMimeType() const;
80 
81  FormatContext& getFormatContext() { return _formatContext; }
82 
83  /**
84  * @brief Set the format and the generic options of the output file.
85  * @param profile: the profile of the output format
86  * @note options specific to the output format will be set in beginWrap.
87  * @see beginWrap
88  */
89  void setupWrapping(const ProfileLoader::Profile& profile);
90 
91 private:
92  //@{
93  // @brief Set options of output format.
94  // @note setupWrappingOptions: called when setupWrapping, to set common options.
95  // @note setupRemainingWrappingOptions: called when beginWrap, to set specific options.
96  // @see setupWrapping
97  void setupWrappingOptions(const ProfileLoader::Profile& profile);
98  void setupRemainingWrappingOptions();
99  //@}
100 
101 private:
103  std::vector<OutputStream*> _outputStreams; ///< Has ownership
104  std::vector<size_t> _frameCount; ///< Number of wrapped frames
105 
106  double _previousProcessedStreamDuration; ///< To manage process streams order
107 
108  /**
109  * @brief To setup specific wrapping options.
110  * @see setupWrapping
111  * @see beginWrap
112  */
114 };
115 }
116 
117 #endif
double _previousProcessedStreamDuration
To manage process streams order.
Definition: OutputFile.hpp:106
FormatContext & getFormatContext()
Definition: OutputFile.hpp:81
FormatContext _formatContext
Definition: OutputFile.hpp:102
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
Outputfile is the default implentation of wrapper which uses LibAV/FFMpeg.
Definition: OutputFile.hpp:17
IOutputfile is the interface to wrap and write medias. It can be overloaded to integrate custom wrapp...
Definition: IOutputFile.hpp:22
EWrappingStatus
define wrapping result status
std::map< std::string, std::string > Profile
ProfileLoader::Profile _profile
To setup specific wrapping options.
Definition: OutputFile.hpp:113
Wrapper of an AVFormatContext.
std::vector< size_t > _frameCount
Number of wrapped frames.
Definition: OutputFile.hpp:104
This class describes coded data.
Definition: CodedData.hpp:18
std::vector< OutputStream * > _outputStreams
Has ownership.
Definition: OutputFile.hpp:103
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