6 #include <libavcodec/avcodec.h>
7 #include <libavformat/avformat.h>
8 #include <libavutil/avutil.h>
9 #include <libavutil/pixdesc.h>
10 #include <libavutil/channel_layout.h>
26 throw std::runtime_error(
"unknown codec context");
28 const char* fmtName = av_get_sample_fmt_name(
_codecContext->sample_fmt);
30 throw std::runtime_error(
"unknown sample format");
32 return std::string(fmtName);
38 throw std::runtime_error(
"unknown codec context");
42 case AV_SAMPLE_FMT_NONE:
44 case AV_SAMPLE_FMT_U8:
45 return "unsigned 8 bits";
46 case AV_SAMPLE_FMT_S16:
47 return "signed 16 bits";
48 case AV_SAMPLE_FMT_S32:
49 return "signed 32 bits";
50 case AV_SAMPLE_FMT_FLT:
52 case AV_SAMPLE_FMT_DBL:
54 case AV_SAMPLE_FMT_U8P:
55 return "unsigned 8 bits, planar";
56 case AV_SAMPLE_FMT_S16P:
57 return "signed 16 bits, planar";
58 case AV_SAMPLE_FMT_S32P:
59 return "signed 32 bits, planar";
60 case AV_SAMPLE_FMT_FLTP:
61 return "float, planar";
62 case AV_SAMPLE_FMT_DBLP:
63 return "double, planar";
64 case AV_SAMPLE_FMT_NB:
65 return "number of sample formats";
67 return "unknown sample format";
73 throw std::runtime_error(
"unknown codec context");
76 av_get_channel_layout_string(buf1,
sizeof(buf1), -1,
_codecContext->channel_layout);
77 return std::string(buf1);
83 throw std::runtime_error(
"unknown codec context");
85 const char* channelName = av_get_channel_name(
_codecContext->channel_layout);
87 throw std::runtime_error(
"unknown channel name");
89 return std::string(channelName);
95 throw std::runtime_error(
"unknown codec context");
97 #ifdef AVTRANSCODER_FFMPEG_DEPENDENCY
98 const char* channelDescription = av_get_channel_description(
_codecContext->channel_layout);
99 if(!channelDescription)
100 throw std::runtime_error(
"unknown channel description");
101 return std::string(channelDescription);
103 throw std::runtime_error(
"can't access channel description");
110 throw std::runtime_error(
"unknown codec context");
117 throw std::runtime_error(
"unknown codec context");
124 throw std::runtime_error(
"unknown codec context");
131 int bitsPerSample = av_get_bits_per_sample(
_codecContext->codec_id);
138 throw std::runtime_error(
"unknown format context");
148 throw std::runtime_error(
"unknown codec context");
157 data.insert(data.begin(), basedProperty.begin(), basedProperty.end());
179 for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
181 flux << std::setw(
detail::keyWidth) << it->first <<
": " << it->second << std::endl;
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
const AVFormatContext * _formatContext
Has link (no ownership)
const std::string separator
size_t getTicksPerFrame() const
size_t getBitRate() const
0 if unknown
void addProperty(PropertyVector &data, const std::string &key, T(AudioProperties::*getter)(void) const) const
AudioProperties(const FormatContext &formatContext, const size_t index)
std::string getChannelDescription() const
float getDuration() const
in seconds
std::string getChannelLayout() const
std::string getChannelName() const
size_t getNbChannels() const
size_t getSampleRate() const
Wrapper of an AVFormatContext.
virtual PropertyVector & fillVector(PropertyVector &data) const
To avoid copy of the vector.
AVCodecContext * _codecContext
Has link (no ownership)
std::string getSampleFormatName() const
Virtual based class of properties for all types of stream.
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
PropertyVector asVector() const
Same data with a specific order.
PropertyVector & fillVector(PropertyVector &data) const
To avoid copy of the vector.
std::string getSampleFormatLongName() const
size_t getNbSamples() const