@@ -10,7 +10,11 @@ extern "C" {
10
10
#include < libavutil/avutil.h>
11
11
#include < libavutil/pixdesc.h>
12
12
}
13
+
13
14
#include < iostream>
15
+ #include < iomanip>
16
+ #include < sstream>
17
+
14
18
#ifdef _MSC_VER
15
19
#include < float.h>
16
20
#define isnan _isnan
@@ -73,6 +77,19 @@ void getGopProperties( VideoProperties& vp, AVFormatContext* formatContext, AVCo
73
77
74
78
}
75
79
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
+
76
93
VideoProperties videoStreamInfo ( AVFormatContext* formatContext, const size_t index )
77
94
{
78
95
VideoProperties vp;
@@ -104,11 +121,7 @@ VideoProperties videoStreamInfo( AVFormatContext* formatContext, const size_t in
104
121
vp.sar .num = codec_context->sample_aspect_ratio .num ;
105
122
vp.sar .den = codec_context->sample_aspect_ratio .den ;
106
123
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 );
112
125
113
126
int darNum, darDen;
114
127
av_reduce ( &darNum, &darDen,
@@ -285,7 +298,7 @@ VideoProperties videoStreamInfo( AVFormatContext* formatContext, const size_t in
285
298
vp.codecName = codec->name ;
286
299
vp.codecLongName = codec->long_name ;
287
300
288
- if ( codec_context->profile = = -99 )
301
+ if ( codec_context->profile ! = -99 )
289
302
{
290
303
const char * profile;
291
304
if ( ( profile = av_get_profile_name ( codec, codec_context->profile ) ) != NULL )
0 commit comments