Skip to content

Commit 80e310c

Browse files
clean get video metadatas
1 parent ce46e1a commit 80e310c

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/AvTranscoder/Metadatas/VideoStreamProperties.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ extern "C" {
1010
#include <libavutil/avutil.h>
1111
#include <libavutil/pixdesc.h>
1212
}
13+
1314
#include <iostream>
15+
#include <iomanip>
16+
#include <sstream>
17+
1418
#ifdef _MSC_VER
1519
#include <float.h>
1620
#define isnan _isnan
@@ -73,6 +77,19 @@ void getGopProperties( VideoProperties& vp, AVFormatContext* formatContext, AVCo
7377

7478
}
7579

80+
std::string makeTimecodeMpegToString( uint32_t tc25bit )
81+
{
82+
std::ostringstream os;
83+
os << std::setfill( '0' );
84+
os << std::setw(2) << ( tc25bit >> 19 & 0x1f ) << ":"; // 5-bit hours
85+
os << std::setw(2) << ( tc25bit >> 13 & 0x3f ) << ":"; // 6-bit minutes
86+
os << std::setw(2) << ( tc25bit >> 6 & 0x3f ) ; // 6-bit seconds
87+
os << ( tc25bit & 1 << 24 ? ';' : ':' ); // 1-bit drop flag
88+
os << std::setw(2) << ( tc25bit & 0x3f ); // 6-bit frames
89+
return os.str();
90+
}
91+
92+
7693
VideoProperties videoStreamInfo( AVFormatContext* formatContext, const size_t index )
7794
{
7895
VideoProperties vp;
@@ -104,11 +121,7 @@ VideoProperties videoStreamInfo( AVFormatContext* formatContext, const size_t in
104121
vp.sar.num = codec_context->sample_aspect_ratio.num;
105122
vp.sar.den = codec_context->sample_aspect_ratio.den;
106123

107-
108-
//char tcbuf[AV_TIMECODE_STR_SIZE];
109-
//av_timecode_make_mpeg_tc_string( tcbuf, codec_context->timecode_frame_start );
110-
//std::string videoTimecode( tcbuf );
111-
//vp.startTimecode = videoTimecode;
124+
vp.startTimecode = makeTimecodeMpegToString( codec_context->timecode_frame_start );
112125

113126
int darNum, darDen;
114127
av_reduce( &darNum, &darDen,
@@ -285,7 +298,7 @@ VideoProperties videoStreamInfo( AVFormatContext* formatContext, const size_t in
285298
vp.codecName = codec->name;
286299
vp.codecLongName = codec->long_name;
287300

288-
if( codec_context->profile == -99 )
301+
if( codec_context->profile != -99 )
289302
{
290303
const char* profile;
291304
if( ( profile = av_get_profile_name( codec, codec_context->profile ) ) != NULL )

0 commit comments

Comments
 (0)