You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.6 KiB
71 lines
2.6 KiB
#include "servaVideoComposer.h"
|
|
|
|
#define LOG( X ) m_pLog->Log( "MVC", this, X )
|
|
#ifdef DEBUG
|
|
#define LOG_ERROR( X ) {\
|
|
char _tBfrErrMSG234[256];\
|
|
sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
|
|
m_pLog->Log( "MVC", this, _LOG_ERROR, _tBfrErrMSG234 );\
|
|
}
|
|
#else
|
|
#define LOG_ERROR( X ) m_pLog->Log( "MVC", this, _LOG_ERROR, X );
|
|
#endif
|
|
|
|
|
|
servaVideoComposer::servaVideoComposer( uint64_t session_id ){
|
|
m_pLog = basicLogCollection::getInstance();
|
|
//Load Module Data
|
|
if ( tData ) {
|
|
memcpy(m_sComposerSettings, tData, sizeof(DBC_MEDIA_COMPOSER_DATA));
|
|
free( tData );
|
|
} else {
|
|
LOG_ERROR("Settings Load Failure!");
|
|
memset(m_sComposerSettings, 0, sizeof(DBC_MEDIA_COMPOSER_DATA));
|
|
};
|
|
//Load Session Data
|
|
|
|
// create supplimentary data
|
|
m_oNoVideoMat =
|
|
};
|
|
|
|
virtual void servaVideoComposer::m_fThreadProc(void){
|
|
uint8_t operc = 0;
|
|
#ifdef DEBUG_EXTRA
|
|
char tB[1024];
|
|
sprintf( tB, "Converting %s to %s", m_sDecoderVS.m_pFileName, m_sEncoderVS.m_pFileName );
|
|
LOG( tB );
|
|
#endif
|
|
cv::VideoCapture cap( m_sDecoderVS.m_pFileName );
|
|
if( cap.isOpened() ) {
|
|
cv::Mat mat;
|
|
cap >> mat;
|
|
if( !mat.empty() ){
|
|
cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 );
|
|
cv::VideoWriter out( m_sEncoderVS.m_pFileName, cv::VideoWriter::fourcc('a', 'v', 'c', '1'), 15.0, mat.size() );
|
|
size_t number_of_frames = 0;
|
|
m_bStatus = THREAD_INIT;
|
|
m_bThreadStatus = TH_WORKING;
|
|
while( cap.isOpened() && out.isOpened() && m_bThreadStatus < TH_ENDED ){
|
|
cap >> mat;
|
|
m_bStatus = ENCODER_ENCODING;
|
|
if( mat.empty() ){
|
|
m_bThreadStatus = TH_ENDED;
|
|
} else {
|
|
number_of_frames ++;
|
|
out.write(mat);
|
|
};
|
|
uint8_t perc = ( 100 * number_of_frames ) / 900;
|
|
if ( operc!= perc ) {
|
|
if ( perc > 100 ) perc = 100;
|
|
operc = perc;
|
|
m_pMaster->updateEncodeStatus(m_nRefID, MEDIA_ENCODE_PROGRESS, perc);
|
|
};
|
|
};
|
|
cap.release();
|
|
// Does it look reasonable? If so, then we can go ahead and delete the original file.
|
|
if( number_of_frames > 100 ){
|
|
unlink( m_sDecoderVS.m_pFileName );
|
|
};
|
|
};
|
|
};
|
|
};
|