AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.hpp
Go to the documentation of this file.
1 #ifndef _AV_TRANSCODER_UTIL_HPP
2 #define _AV_TRANSCODER_UTIL_HPP
3 
4 #include "common.hpp"
5 #include "Option.hpp"
6 
7 extern "C" {
8 #include <libavcodec/avcodec.h>
9 #include <libavformat/avformat.h>
10 #include <libavutil/pixfmt.h>
11 #include <libavutil/samplefmt.h>
12 }
13 
14 #include <string>
15 #include <vector>
16 #include <map>
17 
18 namespace avtranscoder
19 {
20 
21 typedef std::map<std::string, OptionArray> OptionArrayMap;
22 typedef std::map<std::string, std::string> NamesMap; //< short/long names of format/video codec/audio codec
23 
24 /**
25 * @brief Get pixel format supported by a video codec.
26 * @param videoCodecName: the video codec name (empty if not indicated, and so get all pixel formats supported by all video
27 * codecs).
28 */
29 std::vector<std::string> AvExport getSupportedPixelFormats(const std::string& videoCodecName = "");
30 
31 /**
32 * @brief Get sample format supported by an audio codec.
33 * @param audioCodecName: the audio codec name (empty if not indicated, and so get all sample formats supported by all audio
34 * codecs).
35 */
36 std::vector<std::string> AvExport getSupportedSampleFormats(const std::string& audioCodecName = "");
37 
38 /**
39 * @brief Get the corresponding AVPixelFormat from the pixel format name
40 * @param pixelFormat: the name of the pixel format
41 */
42 AVPixelFormat AvExport getAVPixelFormat(const std::string& pixelFormat);
43 
44 /**
45 * @brief Get the corresponding AVSampleFormat from the sample format name
46 * @param sampleFormat: the name of the sample format
47 */
48 AVSampleFormat AvExport getAVSampleFormat(const std::string& sampleFormat);
49 
50 /**
51  * @return The name of the given pixel format.
52  * @note Returns an empty string if the format is not found.
53  */
54 std::string AvExport getPixelFormatName(const AVPixelFormat pixelFormat);
55 
56 /**
57  * @return The name of the given sample format.
58  * @note Returns an empty string if the format is not found.
59  */
60 std::string AvExport getSampleFormatName(const AVSampleFormat sampleFormat);
61 
62 #ifndef SWIG
63 /**
64  * @return The list of all formats available in FFmpeg / libav.
65  */
66 std::vector<AVOutputFormat*> getAvailableFormats();
67 #endif
68 /**
69  * @brief Get a map of short/long names of all formats available in FFmpeg / libav.
70  * @note Need to call preloadCodecsAndFormats before using this function.
71  */
72 NamesMap AvExport getAvailableFormatsNames();
73 
74 /**
75  * @brief Get a map of short/long names of all formats dedicate for video available in FFmpeg / libav.
76  * @note Need to call preloadCodecsAndFormats before using this function.
77  */
78 NamesMap AvExport getAvailableVideoFormatsNames();
79 
80 /**
81  * @brief Get a map of short/long names of all formats dedicate for video available in FFmpeg / libav.
82  * @note Need to call preloadCodecsAndFormats before using this function.
83  */
84 NamesMap AvExport getAvailableAudioFormatsNames();
85 
86 #ifndef SWIG
87 /**
88  * @return The list of all codecs available in FFmpeg / libav.
89  */
90 std::vector<AVCodec*> getAvailableCodecs();
91 #endif
92 
93 /**
94  * @brief Get a map of short/long names of all video codecs available in FFmpeg / libav.
95  * @note Need to call preloadCodecsAndFormats before using this function.
96  */
97 NamesMap AvExport getAvailableVideoCodecsNames();
98 
99 /**
100  * @brief Get a map of short/long names of all audio codecs available in FFmpeg / libav.
101  * @note Need to call preloadCodecsAndFormats before using this function.
102  */
103 NamesMap AvExport getAvailableAudioCodecsNames();
104 
105 #ifndef SWIG
106 /**
107  * @brief Get the list of options for each output format
108  * @note Need to call preloadCodecsAndFormats before using this function.
109  */
110 OptionArrayMap AvExport getAvailableOptionsPerOutputFormat();
111 
112 /**
113  * @brief Get the list of options for each video codec
114  * @note Need to call preloadCodecsAndFormats before using this function.
115  */
116 OptionArrayMap AvExport getAvailableOptionsPerVideoCodec();
117 
118 /**
119  * @brief Get the list of options for each audio codec
120  * @note Need to call preloadCodecsAndFormats before using this function.
121  */
122 OptionArrayMap AvExport getAvailableOptionsPerAudioCodec();
123 #endif
124 }
125 
126 #endif
std::map< std::string, OptionArray > OptionArrayMap
Definition: util.hpp:21
NamesMap getAvailableAudioCodecsNames()
Get a map of short/long names of all audio codecs available in FFmpeg / libav.
Definition: util.cpp:199
std::vector< std::string > getSupportedPixelFormats(const std::string &videoCodecName)
Get pixel format supported by a video codec.
Definition: util.cpp:13
AVPixelFormat getAVPixelFormat(const std::string &pixelFormat)
Get the corresponding AVPixelFormat from the pixel format name.
Definition: util.cpp:90
std::vector< std::string > getSupportedSampleFormats(const std::string &audioCodecName)
Get sample format supported by an audio codec.
Definition: util.cpp:58
std::vector< AVOutputFormat * > getAvailableFormats()
Definition: util.cpp:112
std::string getPixelFormatName(const AVPixelFormat pixelFormat)
Definition: util.cpp:100
OptionArrayMap getAvailableOptionsPerOutputFormat()
Get the list of options for each output format.
Definition: util.cpp:214
std::map< std::string, std::string > NamesMap
Definition: util.hpp:22
NamesMap getAvailableAudioFormatsNames()
Get a map of short/long names of all formats dedicate for video available in FFmpeg / libav...
Definition: util.cpp:154
std::vector< AVCodec * > getAvailableCodecs()
Definition: util.cpp:169
NamesMap getAvailableVideoCodecsNames()
Get a map of short/long names of all video codecs available in FFmpeg / libav.
Definition: util.cpp:184
NamesMap getAvailableFormatsNames()
Get a map of short/long names of all formats available in FFmpeg / libav.
Definition: util.cpp:127
OptionArrayMap getAvailableOptionsPerVideoCodec()
Get the list of options for each video codec.
Definition: util.cpp:238
NamesMap getAvailableVideoFormatsNames()
Get a map of short/long names of all formats dedicate for video available in FFmpeg / libav...
Definition: util.cpp:139
OptionArrayMap getAvailableOptionsPerAudioCodec()
Get the list of options for each audio codec.
Definition: util.cpp:266
#define AVPixelFormat
Definition: common.hpp:43
std::string getSampleFormatName(const AVSampleFormat sampleFormat)
Definition: util.cpp:106
AVSampleFormat getAVSampleFormat(const std::string &sampleFormat)
Get the corresponding AVSampleFormat from the sample format name.
Definition: util.cpp:95