Skip to content

Commit 18a8759

Browse files
author
Clement Champetier
committed
Merge branch 'master' of https://github.com/avTranscoder/avTranscoder into dev_clean_refactoring
Conflicts: src/AvTranscoder/common.hpp
2 parents eacd0ed + 0d9e4fa commit 18a8759

File tree

16 files changed

+95
-38
lines changed

16 files changed

+95
-38
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ add_definitions(-DAVTRANSCODER_VERSION_MICRO=${AVTRANSCODER_VERSION_MICRO})
1717
set(CMAKE_VERBOSE_MAKEFILE OFF)
1818

1919
# CPP flags on debug / release mode
20-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -pg -g")
21-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")
20+
if(NOT WIN32)
21+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fPIC -pg -g")
22+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3")
23+
endif()
24+
2225

2326
add_subdirectory(src)
2427
add_subdirectory(app)

app/avInfo/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
55
include(AvTranscoderMacros)
66

77
# Build app
8-
include_directories(${AVTRANSCODER_SRC_PATH})
8+
include_directories(${AVTRANSCODER_SRC_PATH} ${FFMPEG_INCLUDE_DIR})
99
add_executable(avinfo avInfo.cpp)
1010
set_target_properties(avinfo PROPERTIES VERSION ${AVTRANSCODER_VERSION})
1111
target_link_libraries(avinfo avtranscoder-shared)

cmake/FindFFmpeg.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ endmacro()
7979
# Get FFmpeg from custom install
8080
if(FFMPEG_LIBRARY_DIR AND FFMPEG_INCLUDE_DIR)
8181
set(FFMPEG_FOUND TRUE)
82-
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.so")
82+
if(WIN32)
83+
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.lib")
84+
else()
85+
file(GLOB FFMPEG_LIBRARIES "${FFMPEG_LIBRARY_DIR}/*.so")
86+
endif()
8387
# Get FFmpeg from system install
8488
else()
8589
# Check FFmpeg version

src/AvTranscoder/Profile.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _AV_TRANSCODER_PROFILE_HPP_
22
#define _AV_TRANSCODER_PROFILE_HPP_
33

4+
#include "common.hpp"
5+
46
#include <string>
57
#include <cstring>
68
#include <vector>
@@ -9,7 +11,7 @@
911
namespace avtranscoder
1012
{
1113

12-
class Profile
14+
class AvExport Profile
1315
{
1416
public:
1517
static const std::string avProfileIdentificator;

src/AvTranscoder/avTranscoder.i

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
%include "std_pair.i"
88
%include "std_map.i"
99

10-
1110
%include "AvTranscoder/swig/avException.i"
1211
%include "AvTranscoder/swig/avExport.i"
1312

@@ -49,11 +48,28 @@
4948

5049
#include <AvTranscoder/transcoder/StreamTranscoder.hpp>
5150
#include <AvTranscoder/transcoder/Transcoder.hpp>
52-
%}
5351

54-
%include "AvTranscoder/progress/progress.i"
52+
/* initialize static const members for binding */
53+
namespace avtranscoder {
54+
const std::string Profile::avProfileIdentificator = "avProfile";
55+
const std::string Profile::avProfileIdentificatorHuman = "avProfileLong";
56+
57+
const std::string Profile::avProfileType = "avProfileType";
58+
const std::string Profile::avProfileTypeFormat = "avProfileTypeFormat";
59+
const std::string Profile::avProfileTypeVideo = "avProfileTypeVideo";
60+
const std::string Profile::avProfileTypeAudio = "avProfileTypeAudio";
61+
62+
const std::string Profile::avProfileFormat = "format";
63+
const std::string Profile::avProfileCodec = "codec";
64+
const std::string Profile::avProfilePixelFormat = "pix_fmt";
65+
const std::string Profile::avProfileSampleFormat = "sample_fmt";
66+
const std::string Profile::avProfileFrameRate = "r";
67+
const std::string Profile::avProfileSampleRate = "ar";
68+
const std::string Profile::avProfileChannel = "ac";
69+
}
70+
%}
5571

56-
namespace std {
72+
namespace std {
5773
%template(IntPair) pair< size_t, size_t >;
5874
%template(VideoVector) vector< avtranscoder::VideoProperties >;
5975
%template(AudioVector) vector< avtranscoder::AudioProperties >;
@@ -68,6 +84,8 @@ namespace std {
6884

6985
%include <AvTranscoder/common.hpp>
7086

87+
%include "AvTranscoder/progress/progress.i"
88+
7189
%include <AvTranscoder/Profile.hpp>
7290

7391
%include <AvTranscoder/frame/Pixel.hpp>

src/AvTranscoder/common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ namespace avtranscoder
5353

5454
#define MAX_SWS_PLANE 4
5555

56-
void split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars = ";" );
57-
int getFilesInDir( const std::string& dir, std::vector< std::string >& files );
56+
void AvExport split( std::vector< std::string >& splitedString, const std::string& inputString, const std::string& splitChars = ";" );
57+
int AvExport getFilesInDir( const std::string& dir, std::vector< std::string >& files );
5858

59-
std::string getFormat( const std::string& filename );
60-
bool matchFormat( const std::string& format, const std::string& filename );
59+
std::string AvExport getFormat( const std::string& filename );
60+
bool AvExport matchFormat( const std::string& format, const std::string& filename );
6161

6262
}
6363

src/AvTranscoder/essenceStream/AvOutputAudio.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace avtranscoder
99
{
1010

11-
class AvOutputAudio : public IOutputEssence
11+
class AvExport AvOutputAudio : public IOutputEssence
1212
{
1313
public:
1414
AvOutputAudio();

src/AvTranscoder/frame/Pixel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum ESubsamplingType
2727
eSubsampling420 // 4:2:0
2828
};
2929

30-
class Pixel
30+
class AvExport Pixel
3131
{
3232
public:
3333
Pixel()

src/AvTranscoder/mediaProperty/mediaProperty.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ namespace detail
2424
/**
2525
* @brief Fill metadata parameter with the given AVDictionary.
2626
*/
27-
void fillMetadataDictionnary( AVDictionary* avdictionnary, MetadatasMap& metadata );
27+
void AvExport fillMetadataDictionnary( AVDictionary* avdictionnary, MetadatasMap& metadata );
2828
}
2929

30-
struct Channel
30+
struct AvExport Channel
3131
{
3232
size_t id;
3333
size_t chromaHeight;
3434
size_t bitStep;
3535
};
3636

37-
struct VideoProperties
37+
struct AvExport VideoProperties
3838
{
3939
VideoProperties()
4040
{
@@ -106,7 +106,7 @@ struct VideoProperties
106106
MetadatasMap getDataMap() const;
107107
};
108108

109-
struct AudioProperties
109+
struct AvExport AudioProperties
110110
{
111111
std::string codecName;
112112
std::string codecLongName;
@@ -126,7 +126,7 @@ struct AudioProperties
126126
MetadatasMap getDataMap() const;
127127
};
128128

129-
struct DataProperties
129+
struct AvExport DataProperties
130130
{
131131
size_t streamId;
132132
MetadatasMap metadatas;
@@ -135,7 +135,7 @@ struct DataProperties
135135
MetadatasMap getDataMap() const;
136136
};
137137

138-
struct SubtitleProperties
138+
struct AvExport SubtitleProperties
139139
{
140140
size_t streamId;
141141
MetadatasMap metadatas;
@@ -144,7 +144,7 @@ struct SubtitleProperties
144144
MetadatasMap getDataMap() const;
145145
};
146146

147-
struct AttachementProperties
147+
struct AvExport AttachementProperties
148148
{
149149
size_t streamId;
150150
MetadatasMap metadatas;
@@ -153,7 +153,7 @@ struct AttachementProperties
153153
MetadatasMap getDataMap() const;
154154
};
155155

156-
struct UnknownProperties
156+
struct AvExport UnknownProperties
157157
{
158158
size_t streamId;
159159
MetadatasMap metadatas;
@@ -162,7 +162,7 @@ struct UnknownProperties
162162
MetadatasMap getDataMap() const;
163163
};
164164

165-
struct Properties
165+
struct AvExport Properties
166166
{
167167
std::string filename;
168168
std::string formatName;

src/AvTranscoder/progress/ConsoleProgress.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace avtranscoder
99
/**
1010
* @brief Implementation of IProgress, to display a progress bar in console.
1111
*/
12-
class ConsoleProgress : public IProgress
12+
class AvExport ConsoleProgress : public IProgress
1313
{
1414
public:
1515
~ConsoleProgress();

src/AvTranscoder/progress/IProgress.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum EJobStatus
2222
* Inherit this class to have your own way to manage a progress bar.
2323
* You can inherit this class in C++, but also in python / Java binding.
2424
*/
25-
class IProgress
25+
class AvExport IProgress
2626
{
2727
public:
2828
virtual ~IProgress() {};

src/AvTranscoder/progress/NoDisplayProgress.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace avtranscoder
99
/**
1010
* @brief Implementation of IProgress, to manage cases when we need an IProgress but don't care of a progress bar.
1111
*/
12-
class NoDisplayProgress : public IProgress
12+
class AvExport NoDisplayProgress : public IProgress
1313
{
1414
public:
1515
~NoDisplayProgress()

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace avtranscoder
1818

1919
class ITransform;
2020

21-
class StreamTranscoder
21+
class AvExport StreamTranscoder
2222
{
2323
public:
2424
/**

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <limits>
44
#include <iostream>
5+
#include <algorithm>
56

67
namespace avtranscoder
78
{
@@ -17,6 +18,7 @@ Transcoder::Transcoder( OutputFile& outputFile )
1718
, _outputFps( 25 )
1819
, _finalisedStreams( 0 )
1920
, _eProcessMethod ( eProcessMethodLongest )
21+
, _mainStreamIndex( 0 )
2022
, _verbose( false )
2123
{
2224
_outputFile.setup();
@@ -275,6 +277,9 @@ void Transcoder::process( IProgress& progress )
275277
case eProcessMethodLongest :
276278
totalDuration = getMaxTotalDuration();
277279
break;
280+
case eProcessMethodBasedOnStream :
281+
totalDuration = getStreamDuration( _mainStreamIndex );
282+
break;
278283
case eProcessMethodInfinity :
279284
totalDuration = std::numeric_limits<double>::max();
280285
break;
@@ -304,9 +309,10 @@ void Transcoder::process( IProgress& progress )
304309
_outputFile.endWrap();
305310
}
306311

307-
void Transcoder::setProcessMethod( const EProcessMethod eProcessMethod )
312+
void Transcoder::setProcessMethod( const EProcessMethod eProcessMethod, const size_t indexBasedStream )
308313
{
309314
_eProcessMethod = eProcessMethod;
315+
_mainStreamIndex = indexBasedStream;
310316

311317
for( size_t i = 0; i < _streamTranscoders.size(); ++i )
312318
{
@@ -324,6 +330,12 @@ void Transcoder::setProcessMethod( const EProcessMethod eProcessMethod )
324330
else
325331
_streamTranscoders.at( i )->setInfinityStream( true );
326332
break;
333+
case eProcessMethodBasedOnStream :
334+
if( i != _mainStreamIndex )
335+
_streamTranscoders.at( i )->setInfinityStream( true );
336+
else
337+
_streamTranscoders.at( i )->setInfinityStream( false );
338+
break;
327339
case eProcessMethodInfinity :
328340
_streamTranscoders.at( i )->setInfinityStream( true );
329341
break;
@@ -447,13 +459,18 @@ InputFile* Transcoder::addInputFile( const std::string& filename, const size_t s
447459
return referenceFile;
448460
}
449461

462+
double Transcoder::getStreamDuration( size_t indexStream ) const
463+
{
464+
return _streamTranscoders.at( indexStream )->getDuration();
465+
}
466+
450467
double Transcoder::getMinTotalDuration() const
451468
{
452469
double minTotalDuration = std::numeric_limits<double>::max();
453470

454471
for( size_t i = 0; i < _streamTranscoders.size(); ++i )
455472
{
456-
minTotalDuration = std::min( _streamTranscoders.at( i )->getDuration(), minTotalDuration );
473+
minTotalDuration = std::min( getStreamDuration( i ), minTotalDuration );
457474
}
458475
return minTotalDuration;
459476
}
@@ -464,7 +481,7 @@ double Transcoder::getMaxTotalDuration() const
464481

465482
for( size_t i = 0; i < _streamTranscoders.size(); ++i )
466483
{
467-
maxTotalDuration = std::max( _streamTranscoders.at( i )->getDuration(), maxTotalDuration );
484+
maxTotalDuration = std::max( getStreamDuration( i ), maxTotalDuration );
468485
}
469486
return maxTotalDuration;
470487
}

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ namespace avtranscoder
2727
* @brief: Enum to set a policy of how we manage the transcode in case of several streams.
2828
* eProcessMethodShortest: stop transcode at the end of the shortest stream.
2929
* eProcessMethodLongest: stop transcode at the end of the longest stream (default method).
30+
* eProcessMethodBasedOnStream: stop transcode at the end of an indicated stream (@see _indexBasedStream).
3031
* eProcessMethodInfinity: stop transcode by outside of avTranscoder.
3132
*/
3233
enum EProcessMethod
3334
{
3435
eProcessMethodShortest = 0,
3536
eProcessMethodLongest,
37+
eProcessMethodBasedOnStream,
3638
eProcessMethodInfinity,
3739
};
3840

39-
class Transcoder
41+
class AvExport Transcoder
4042
{
4143
public:
4244

@@ -116,8 +118,9 @@ class Transcoder
116118
/**
117119
* @brief Set the transcodage politic.
118120
* @note If you call it before adding the streams, the process will stop at the end of the shortest stream.
121+
* @param indexBasedStream: in case of process method eProcessMethodBasedOnStream, stop transcode at the end of the indicated stream.
119122
*/
120-
void setProcessMethod( const EProcessMethod eProcessMethod );
123+
void setProcessMethod( const EProcessMethod eProcessMethod, const size_t indexBasedStream = 0 );
121124

122125
/**
123126
* @brief Set verbose mode for the Transcoder and his streams.
@@ -139,9 +142,14 @@ class Transcoder
139142

140143
InputFile* addInputFile( const std::string& filename, const size_t streamIndex );
141144

145+
/**
146+
* @brief Get the duration of the stream.
147+
*/
148+
double getStreamDuration( size_t indexStream ) const;
149+
142150
/**
143151
* @brief Get the duration of the shortest stream.
144-
* @note if there is only generated streams, return limit of double.
152+
* @note if there is only generated streams, return limit of double.
145153
*/
146154
double getMinTotalDuration() const;
147155

@@ -168,6 +176,8 @@ class Transcoder
168176
size_t _finalisedStreams;
169177
EProcessMethod _eProcessMethod;
170178

179+
size_t _mainStreamIndex; ///< Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream.
180+
171181
bool _verbose;
172182
};
173183

0 commit comments

Comments
 (0)