Add new information to the format properties side bar
Improve InputStream and LibAvHandle to detect the stream duration in order to present it on the side bar Improvements in the LibAvHandle to return NOFMT if format is unknown
This commit is contained in:
1 parent
2917ed175e
commit
7ccf255a94
6 files changed
+87
-24
No files matched your search
@@ -81,7 +81,7 @@ Void LibAvContextHandle::closeAvFormat()
|
||||
m_bHasStream = false;
|
||||
}
|
||||
|
||||
Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate )
|
||||
Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -152,9 +152,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
|
||||
video_dst_bufsize = ret;
|
||||
}
|
||||
|
||||
|
||||
const char *codec_name = avcodec_get_name(video_dec_ctx->codec_id);
|
||||
|
||||
sprintf(m_acCodecName, "%s", codec_name);
|
||||
|
||||
Double fr = 30;
|
||||
@@ -171,6 +169,18 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
|
||||
|
||||
frame_rate = ( UInt )fr;
|
||||
|
||||
if( fmt_ctx->duration != AV_NOPTS_VALUE )
|
||||
{
|
||||
Int64 duration = fmt_ctx->duration + 5000;
|
||||
m_uiSecs = duration / AV_TIME_BASE;
|
||||
num_frames = m_uiSecs * frame_rate;
|
||||
m_uiMicroSec = duration % AV_TIME_BASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
num_frames = 0;
|
||||
}
|
||||
|
||||
width = video_dec_ctx->width;
|
||||
height = video_dec_ctx->height;
|
||||
switch( video_dec_ctx->pix_fmt )
|
||||
@@ -191,6 +201,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
|
||||
pixel_format = PlaYUVerFrame::RGB8;
|
||||
break;
|
||||
default:
|
||||
pixel_format = PlaYUVerFrame::NO_FMT;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -269,7 +280,7 @@ Bool LibAvContextHandle::decodeAvFormat()
|
||||
|
||||
Void LibAvContextHandle::seekAvFormat( UInt64 frame_num )
|
||||
{
|
||||
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_ANY );
|
||||
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_FRAME );
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
@@ -53,10 +53,10 @@ class LibAvContextHandle
|
||||
{
|
||||
public:
|
||||
LibAvContextHandle() :
|
||||
m_bHasStream( false )
|
||||
m_bHasStream( false )
|
||||
{
|
||||
}
|
||||
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
|
||||
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames );
|
||||
Void closeAvFormat();
|
||||
Bool decodeAvFormat();
|
||||
|
||||
@@ -70,6 +70,10 @@ public:
|
||||
{
|
||||
return m_acCodecName;
|
||||
}
|
||||
UInt getStreamDuration( )
|
||||
{
|
||||
return m_uiSecs;
|
||||
}
|
||||
|
||||
uint8_t *video_dst_data[4];
|
||||
int video_dst_linesize[4];
|
||||
@@ -86,6 +90,8 @@ private:
|
||||
Bool m_bHasStream;
|
||||
|
||||
Char m_acCodecName[20];
|
||||
UInt m_uiSecs;
|
||||
UInt m_uiMicroSec;
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
Reference in new issue
Block a user