8 #include <libavutil/avutil.h> 
   23     , _levelAnalysis(level)
 
   25     , _isInterlaced(false)
 
   26     , _isTopFieldFirst(false)
 
   29     , _firstGopTimeCode(-1)
 
   44         throw std::runtime_error(
"unknown codec");
 
   46     if(
_codec->capabilities & CODEC_CAP_TRUNCATED)
 
   49     const char* profile = NULL;
 
   51         throw std::runtime_error(
"unknown codec profile");
 
   53     return std::string(profile);
 
   59         throw std::runtime_error(
"unknown codec context");
 
   64             return "Rec 709 / ITU-R BT1361";
 
   65         case AVCOL_TRC_UNSPECIFIED:
 
   67         case AVCOL_TRC_GAMMA22:
 
   69         case AVCOL_TRC_GAMMA28:
 
   71 #if LIBAVCODEC_VERSION_MAJOR > 53 
   72         case AVCOL_TRC_SMPTE240M:
 
   75 #if LIBAVCODEC_VERSION_MAJOR > 54 
   76 #ifdef AVCOL_TRC_SMPTE170M 
   77         case AVCOL_TRC_SMPTE170M:
 
   78             return "Rec 601 / ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC";
 
   80 #ifdef AVCOL_TRC_LINEAR 
   81         case AVCOL_TRC_LINEAR:
 
   82             return "Linear transfer characteristics";
 
   86             return "Logarithmic transfer characteristic (100:1 range)";
 
   88 #ifdef AVCOL_TRC_LOG_SQRT 
   89         case AVCOL_TRC_LOG_SQRT:
 
   90             return "Logarithmic transfer characteristic (100 * Sqrt( 10 ) : 1 range)";
 
   92 #ifdef AVCOL_TRC_IEC61966_2_4 
   93         case AVCOL_TRC_IEC61966_2_4:
 
   94             return "IEC 61966-2-4";
 
   96 #ifdef AVCOL_TRC_BT1361_ECG 
   97         case AVCOL_TRC_BT1361_ECG:
 
   98             return "ITU-R BT1361 Extended Colour Gamut";
 
  100 #ifdef AVCOL_TRC_IEC61966_2_1 
  101         case AVCOL_TRC_IEC61966_2_1:
 
  102             return "IEC 61966-2-1 (sRGB or sYCC)";
 
  104 #ifdef AVCOL_TRC_BT2020_10 
  105         case AVCOL_TRC_BT2020_10:
 
  106             return "ITU-R BT2020 for 10 bit system";
 
  108 #ifdef AVCOL_TRC_BT2020_12 
  109         case AVCOL_TRC_BT2020_12:
 
  110             return "ITU-R BT2020 for 12 bit system";
 
  123         throw std::runtime_error(
"unknown codec context");
 
  129         case AVCOL_SPC_BT709:
 
  131         case AVCOL_SPC_UNSPECIFIED:
 
  132             return "unspecified";
 
  135         case AVCOL_SPC_BT470BG:
 
  136             return "BT470 (PAL - 625)";
 
  137         case AVCOL_SPC_SMPTE170M:
 
  138             return "Smpte 170M (NTSC)";
 
  139         case AVCOL_SPC_SMPTE240M:
 
  141 #if LIBAVCODEC_VERSION_MAJOR > 53 
  142         case AVCOL_SPC_YCOCG:
 
  148 #if LIBAVCODEC_VERSION_MAJOR > 54 
  149 #ifdef AVCOL_TRC_BT2020_12 
  150         case AVCOL_SPC_BT2020_NCL:
 
  151             return "ITU-R BT2020 non-constant luminance system";
 
  153 #ifdef AVCOL_TRC_BT2020_CL 
  154         case AVCOL_SPC_BT2020_CL:
 
  155             return "ITU-R BT2020 constant luminance system";
 
  168         throw std::runtime_error(
"unknown codec context");
 
  172         case AVCOL_RANGE_UNSPECIFIED:
 
  173             return "unspecified";
 
  174         case AVCOL_RANGE_MPEG:
 
  176         case AVCOL_RANGE_JPEG:
 
  188         throw std::runtime_error(
"unknown codec context");
 
  192         case AVCOL_PRI_BT709:
 
  194         case AVCOL_PRI_UNSPECIFIED:
 
  195             return "unspecified";
 
  196         case AVCOL_PRI_BT470M:
 
  198         case AVCOL_PRI_BT470BG:
 
  199             return "Rec 601 (PAL & SECAM)";
 
  200         case AVCOL_PRI_SMPTE170M:
 
  201             return "Rec 601 (NTSC)";
 
  202         case AVCOL_PRI_SMPTE240M:
 
  203             return "Smpte 240 (NTSC)";
 
  206 #if LIBAVCODEC_VERSION_MAJOR > 54 
  207 #ifdef AVCOL_TRC_BT2020_CL 
  208         case AVCOL_PRI_BT2020:
 
  209             return "ITU-R BT2020";
 
  222         throw std::runtime_error(
"unknown codec context");
 
  226         case AVCHROMA_LOC_UNSPECIFIED:
 
  227             return "unspecified";
 
  228         case AVCHROMA_LOC_LEFT:
 
  229             return "left (mpeg2/4, h264 default)";
 
  230         case AVCHROMA_LOC_CENTER:
 
  231             return "center (mpeg1, jpeg, h263)";
 
  232         case AVCHROMA_LOC_TOPLEFT:
 
  234         case AVCHROMA_LOC_TOP:
 
  236         case AVCHROMA_LOC_BOTTOMLEFT:
 
  237             return "bottom left";
 
  238         case AVCHROMA_LOC_BOTTOM:
 
  240         case AVCHROMA_LOC_NB:
 
  250         throw std::runtime_error(
"unknown codec context");
 
  254         case AV_FIELD_UNKNOWN:
 
  256         case AV_FIELD_PROGRESSIVE:
 
  257             return "progressive";
 
  261             return "bottom bottom";
 
  274         throw std::runtime_error(
"unknown codec context");
 
  281     std::ostringstream os;
 
  282     if(startTimeCode == -1)
 
  286         os << std::setfill(
'0');
 
  287         os << std::setw(2) << (startTimeCode >> 19 & 0x1f) << 
":"; 
 
  288         os << std::setw(2) << (startTimeCode >> 13 & 0x3f) << 
":"; 
 
  289         os << std::setw(2) << (startTimeCode >> 6 & 0x3f);         
 
  290         os << (startTimeCode & 1 << 24 ? 
';' : 
':');               
 
  291         os << std::setw(2) << (startTimeCode & 0x3f);              
 
  299         throw std::runtime_error(
"unknown codec context");
 
  310         throw std::runtime_error(
"unknown codec context");
 
  324         throw std::runtime_error(
"unknown codec context");
 
  331         throw std::runtime_error(
"cannot compute bit rate: unknown format or codec context");
 
  334         throw std::runtime_error(
"cannot compute bit rate: invalid frame size");
 
  338         throw std::runtime_error(
"cannot compute bit rate: need to get info from the first gop (see eAnalyseLevelFirstGop)");
 
  345     av_init_packet(&pkt);
 
  350     int gopFramesSize = 0;
 
  352     while(!av_read_frame(const_cast<AVFormatContext*>(
_formatContext), &pkt))
 
  359 #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54, 7, 100) 
  362                 gopFramesSize += pkt.size;
 
  367         av_free_packet(&pkt);
 
  379         throw std::runtime_error(
"unknown codec context");
 
  386         throw std::runtime_error(
"unknown codec context");
 
  393         throw std::runtime_error(
"unknown format context");
 
  403         throw std::runtime_error(
"unknown codec context");
 
  410         throw std::runtime_error(
"unknown codec context");
 
  417         throw std::runtime_error(
"unknown codec context");
 
  424         throw std::runtime_error(
"unknown codec context");
 
  431         throw std::runtime_error(
"unknown codec context");
 
  438         throw std::runtime_error(
"unknown codec context");
 
  445         throw std::runtime_error(
"unknown codec context");
 
  457         throw std::runtime_error(
"unknown codec context");
 
  480             av_init_packet(&pkt);
 
  488             int positionOfFirstKeyFrame = -1;
 
  489             int positionOfLastKeyFrame = -1;
 
  491             while(!av_read_frame(const_cast<AVFormatContext*>(
_formatContext), &pkt))
 
  501                             std::make_pair(av_get_picture_type_char(avFrame.pict_type), frame.
getEncodedSize()));
 
  504                         if(avFrame.pict_type == AV_PICTURE_TYPE_I)
 
  506                             if(positionOfFirstKeyFrame == -1)
 
  507                                 positionOfFirstKeyFrame = count;
 
  509                                 positionOfLastKeyFrame = count;
 
  515                 av_free_packet(&pkt);
 
  518                 if(positionOfFirstKeyFrame != -1 && positionOfLastKeyFrame != -1)
 
  521                     _gopSize = positionOfLastKeyFrame - positionOfFirstKeyFrame;
 
  540     data.insert(data.begin(), basedProperty.begin(), basedProperty.end());
 
  578         std::stringstream gop;
 
  579         for(
size_t frameIndex = 0; frameIndex < 
_gopStructure.size(); ++frameIndex)
 
  597     data.insert(data.end(), pixelProperties.begin(), pixelProperties.end());
 
  608     for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
 
  610         flux << std::setw(
detail::keyWidth) << it->first << 
": " << it->second << std::endl;
 
Base class of Progress. Inherit this class to have your own way to manage a progress bar...
 
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) 
 
size_t getMinBitRate() const 
 
EAnalyseLevel
Level of file analysis. 
 
bool isInterlaced() const 
 
std::string getChromaSampleLocation() const 
 
std::vector< std::pair< char, int > > _gopStructure
picture type, encoded frame size in bytes 
 
bool isTopFieldFirst() const 
 
size_t getReferencesFrames() const 
 
int64_t getStartTimecode() const 
 
const std::string separator
 
std::string getStartTimecodeString() const 
 
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
 
AVCodec * _codec
Has link (no ownership) 
 
void analyseGopStructure(IProgress &progress)
frame type / is key frame 
 
PropertyVector & fillVector(PropertyVector &data) const 
To avoid copy of the vector. 
 
float getDuration() const 
in seconds 
 
size_t getBitRate() const 
in bits/s 
 
void addProperty(PropertyVector &dataVector, const std::string &key, T(VideoProperties::*getter)(void) const) const 
 
int getEncodedSize() const 
 
std::string getProfileName() const 
 
Wrapper of an AVFormatContext. 
 
EAnalyseLevel _levelAnalysis
Level of analysis asked. 
 
std::string getColorPrimaries() const 
 
std::string getColorRange() const 
 
float getFps() const 
Corresponds to the 'fps' returned by ffprobe. fps = the average framerate that has come from the AVSt...
 
virtual PropertyVector & fillVector(PropertyVector &data) const 
To avoid copy of the vector. 
 
size_t getTicksPerFrame() const 
 
std::string getFieldOrder() const 
 
int64_t _firstGopTimeCode
GOP timecode of the first frame. 
 
AVCodecContext * _codecContext
Has link (no ownership) 
 
This class describes decoded (raw) audio or video data. 
 
PropertyVector & fillVector(PropertyVector &data) const 
To avoid copy of the vector. 
 
std::string getColorTransfert() const 
 
size_t getMaxBitRate() const 
 
size_t getGopSize() const 
 
Virtual based class of properties for all types of stream. 
 
std::string getColorspace() const 
 
VideoProperties(const FormatContext &formatContext, const size_t index, IProgress &progress, const EAnalyseLevel level=eAnalyseLevelFirstGop)
 
size_t getDtgActiveFormat() const 
 
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
 
const std::string propertyValueIfError
 
PropertyVector asVector() const 
Same data with a specific order. 
 
size_t getNbFrames() const 
 
PixelProperties _pixelProperties
All the pixel properties contained in this stream.