Skip to content

Commit 81bc674

Browse files
Merge branch 'master' of github.com:MarcAntoine-Arnaud/avTranscoder
2 parents 9d076b8 + e23f185 commit 81bc674

File tree

7 files changed

+40
-57
lines changed

7 files changed

+40
-57
lines changed

app/genericProcessor/genericProcessor.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
3232
configFile.close();
3333
}
3434

35-
avtranscoder::EJobStatus callBackProgress( const double processedDuration, const double programDuration )
36-
{
37-
std::string progress( 80, '-' );
38-
std::string done( 80.0 * processedDuration / programDuration, '#' );
39-
progress.replace( 0, done.size(), done );
40-
41-
std::cout << std::setprecision(2) << std::fixed << "\r[" << progress << "] " << processedDuration << "/" << programDuration << std::flush;
42-
43-
// if( processedFrames >= 100 )
44-
// return avtranscoder::eJobStatusCancel;
45-
46-
return avtranscoder::eJobStatusContinue;
47-
}
48-
4935
int main( int argc, char** argv )
5036
{
5137
if( argc != 3 )
@@ -61,7 +47,7 @@ int main( int argc, char** argv )
6147
std::cout << "start ..." << std::endl;
6248

6349
std::string inputConfigFile( argv[1] );
64-
std::string outputFile( argv[2] );
50+
avtranscoder::OutputFile outputFile( argv[2] );
6551

6652
avtranscoder::Transcoder::StreamsDefinition streams;
6753

src/AvTranscoder/Description.hpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extern "C" {
1010
}
1111

1212
#include <vector>
13+
#include <cstring>
1314

1415
std::vector<size_t> getVersion()
1516
{
@@ -24,26 +25,22 @@ std::vector<size_t> getVersion()
2425

2526
std::vector<std::string> getInputExtensions()
2627
{
27-
av_register_all(); // Warning: should be called only once
28+
av_register_all();
2829
std::vector<std::string> extensions;
29-
AVInputFormat* iFormat = av_iformat_next( NULL );
30-
while( iFormat != NULL )
30+
AVInputFormat* iFormat = NULL;
31+
32+
while( ( iFormat = av_iformat_next( iFormat ) ) )
3133
{
3234
if( iFormat->extensions != NULL )
3335
{
34-
const char* exts = iFormat->extensions;
35-
while( 1 )
36+
char* ext = const_cast<char*>( iFormat->extensions );
37+
38+
while( ext != NULL )
3639
{
37-
char* saveptr = NULL;
38-
char* ext = av_strtok( const_cast<char*>( exts ), ",", &saveptr );
39-
if( ! ext || ! saveptr )
40-
{
41-
break;
42-
}
4340
extensions.push_back( std::string( ext ) );
41+
ext = strtok( NULL, "," );
4442
}
4543
}
46-
iFormat = av_iformat_next( iFormat );
4744
}
4845
return extensions;
4946
}

src/AvTranscoder/Metadatas/DataStreamProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ DataProperties dataStreamInfo( AVFormatContext* formatContext, const size_t inde
7070
DataProperties dp;
7171
dp.streamId = index;
7272

73-
AVCodecContext* codec_context = formatContext->streams[index]->codec;
73+
// AVCodecContext* codec_context = formatContext->streams[index]->codec;
7474

7575
// dp.codecName = codec_context->codec_name;
7676
// dp.codecLongName = codec_context->codec_name;

src/AvTranscoder/ProgressListener.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#ifndef _AV_TRANSCODER_PROGRESS_LISTENER_HPP_
22
#define _AV_TRANSCODER_PROGRESS_LISTENER_HPP_
33

4+
#include <iostream>
5+
#include <iomanip>
6+
47
namespace avtranscoder
58
{
69

@@ -21,7 +24,15 @@ class ProgressListener
2124

2225
virtual EJobStatus progress( const double processedDuration, const double programDuration )
2326
{
24-
std::cout << "c++ progress " << processedDuration << "/" << programDuration << std::endl;
27+
std::string progress( 80, '-' );
28+
std::string done( 80.0 * processedDuration / programDuration, '#' );
29+
progress.replace( 0, done.size(), done );
30+
31+
std::cout << std::setprecision(2) << std::fixed << "\r[" << progress << "] " << processedDuration << "/" << programDuration << std::flush;
32+
33+
// if( processedFrames >= 100 )
34+
// return avtranscoder::eJobStatusCancel;
35+
2536
return eJobStatusContinue;
2637
}
2738
};

src/AvTranscoder/Transcoder.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class Transcoder
1717
public:
1818
typedef std::vector< std::pair< std::string, size_t > > StreamsDefinition;
1919

20-
Transcoder( const std::string& filename );
21-
Transcoder( OutputFile* outputFile );
20+
Transcoder( OutputFile& outputFile );
2221

2322
~Transcoder();
2423

@@ -29,7 +28,7 @@ class Transcoder
2928
void process( ProgressListener& progress );
3029

3130
private:
32-
OutputFile* _outputFile;
31+
OutputFile& _outputFile;
3332
std::vector< InputStream > _inputStreams;
3433
};
3534

src/AvTranscoder/Transcoder.tcc

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,14 @@
33
namespace avtranscoder
44
{
55

6-
Transcoder::Transcoder( const std::string& filename )
7-
: _outputFile( NULL )
6+
Transcoder::Transcoder( OutputFile& outputFile )
7+
: _outputFile( outputFile )
88
{
9-
_outputFile = new OutputFile( filename );
10-
_outputFile->setup();
11-
}
12-
13-
Transcoder::Transcoder( OutputFile* outputFile )
14-
: _outputFile( NULL )
15-
{
16-
_outputFile = outputFile;
17-
_outputFile->setup();
9+
_outputFile.setup();
1810
}
1911

2012
Transcoder::~Transcoder()
2113
{
22-
delete _outputFile;
23-
_outputFile = NULL;
2414
}
2515

2616
void Transcoder::add( const std::string& filename, const size_t streamIndex )
@@ -32,13 +22,13 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex )
3222
case AVMEDIA_TYPE_VIDEO:
3323
{
3424
_inputStreams.push_back( avtranscoder::InputStream( filename, streamIndex ) );
35-
_outputFile->addVideoStream( _inputStreams.back().getVideoDesc() );
25+
_outputFile.addVideoStream( _inputStreams.back().getVideoDesc() );
3626
break;
3727
}
3828
case AVMEDIA_TYPE_AUDIO:
3929
{
4030
_inputStreams.push_back( avtranscoder::InputStream( filename, streamIndex ) );
41-
_outputFile->addAudioStream( _inputStreams.back().getAudioDesc() );
31+
_outputFile.addAudioStream( _inputStreams.back().getAudioDesc() );
4232
break;
4333
}
4434
case AVMEDIA_TYPE_DATA:
@@ -75,7 +65,7 @@ void Transcoder::process( ProgressListener& progress )
7565
dataStreams.push_back( dataStream );
7666
}
7767

78-
_outputFile->beginWrap();
68+
_outputFile.beginWrap();
7969

8070
bool continueProcess( true );
8171

@@ -111,13 +101,13 @@ void Transcoder::process( ProgressListener& progress )
111101

112102
for( size_t streamIndex = 0; streamIndex < _inputStreams.size(); ++streamIndex )
113103
{
114-
_outputFile->wrap( dataStreams.at( streamIndex ), streamIndex );
104+
_outputFile.wrap( dataStreams.at( streamIndex ), streamIndex );
115105
}
116106

117107
++frame;
118108
}
119109

120-
_outputFile->endWrap();
110+
_outputFile.endWrap();
121111

122112
}
123113

src/SConscript

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Import( "installPrefix" )
88

99
env.Replace(SHLIBSUFFIX = '.so.$SHLIB_VERSION')
1010

11-
AvTranscoderVersion = '0.0.1'
11+
AvTranscoderVersion = "0.0.1"
1212

1313
sAvTranscoder = env.StaticLibrary(
1414
'sAvTranscoder',
@@ -59,13 +59,13 @@ pyAvTranscoder = envPy.SharedLibrary(
5959
],
6060
)
6161

62-
avTranscoder_class = env.Java(
63-
target='AvTranscoderClass',
64-
source= Glob( envJava['JARCHDIR'] ) )
62+
# avTranscoder_class = env.Java(
63+
# target='AvTranscoderClass',
64+
# source= Glob( envJava['JARCHDIR'] ) )
6565

66-
avTranscoder_jar = env.Jar(
67-
target='jAvTranscoder.jar',
68-
source=avTranscoder_class )
66+
# avTranscoder_jar = env.Jar(
67+
# target='jAvTranscoder.jar',
68+
# source=avTranscoder_class )
6969
#source= Glob( '#build/src/AvTranscoderClass' ) )
7070

7171

0 commit comments

Comments
 (0)