Skip to content

Release/v0.4.0 #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
304a28b
mediaProperty: refactore
Nov 12, 2014
bfd52eb
mediaProperties: use wrapper classes instead of structs of copies
Nov 12, 2014
b3a5e90
mediaProperty: rename file mediaProperty to util
Nov 12, 2014
2704ddb
mediaProperty: add swig interface file
Nov 12, 2014
f094292
swig: move template about mediaProperty in the corresponding interface
Nov 12, 2014
0068948
swig: add templates to mediaProperty interface
Nov 12, 2014
d59701c
file: add file util.hpp
Nov 12, 2014
08460e7
EAnalyseLevel: rename enum values
Nov 12, 2014
7157c0a
Swig: add file interface
Nov 12, 2014
9cb1b2d
InputFile: refactore analyse
Nov 17, 2014
2918b40
mediaProperty: remove default constructors of Properties
Nov 17, 2014
8df49bd
AudioProperties: get AVCodec attribute
Nov 17, 2014
129a8d1
AudioProperties: check formatContext/codecContext/codec pointers
Nov 17, 2014
104451e
AudioProperties: clean format result of getSampleFormatLongName
Nov 17, 2014
9fe1359
AudioProperties: clean getChannelDescription
Nov 17, 2014
e967cdc
VideoProperties: get AVCodec attribute
Nov 17, 2014
86b2d8a
VideoProperties: check formatContext/codecContext/codec pointers
Nov 17, 2014
2200f08
VideoProperties: use class initialiser list for Rational
Nov 17, 2014
7e16550
mediaProperty: clean output formatting of getDataMap
Nov 17, 2014
802004d
mediaProperty: fillMetadataDictionnary in constructor
Nov 17, 2014
3561f67
SWIG file interface: add EAnalyseLevel enum to binding
Nov 18, 2014
dd174c0
SWIG: clean interfaces
Nov 18, 2014
557e087
pyTests: fit to new way to get media properties
Nov 18, 2014
67475cc
Merge pull request #1 from valnoel/fix_audio_packets_management
cchampet Nov 24, 2014
2129ab2
Merge branch 'dev_setFrame_v2' of https://github.com/cchampet/avTrans…
Nov 24, 2014
bb16cbb
AudioTransform: suppress warning
Nov 24, 2014
d3fcd7d
StreamTranscoder: refactore processTranscode
Nov 24, 2014
37e28e3
Merge branch 'dev_refactore_media_properties_v2' of https://github.co…
Nov 24, 2014
265300f
Merge pull request #4 from mikrosimage/develop
valnoel Dec 3, 2014
76caaba
Transcoder: fix audio stream setting when demuxing without specified …
Dec 3, 2014
6c3ea36
AvInputStream: remove audio codec block_align setting
Dec 3, 2014
0011865
Pixel: add support of pixel formats 4:4:0, 4:1:1 and 4:1:0
Nov 28, 2014
6e5f044
Pixel: clean constructor from an AVPixelFormat
Nov 28, 2014
6edc602
Profile: update value of constants avProfileIdentificator
Nov 28, 2014
c8b1e6e
Update README
Nov 28, 2014
0e5eb7c
Merge pull request #5 from valnoel/fix_some_audio_process
cchampet Dec 3, 2014
a3ebb88
Merge pull request #6 from cchampet/dev_add_support_pixelFormats
valnoel Dec 3, 2014
0e8513a
Merge pull request #7 from cchampet/dev_update_avProfileIdentificator
valnoel Dec 3, 2014
01e578e
mediaProperty: skip unnecessary functions for SWIG
Dec 3, 2014
53d90bc
Progress: into OutputFile, add getProgressDuration method to compute …
Dec 3, 2014
31d7a0c
Progress: update Transcoder progress computing
Dec 3, 2014
6eb4b0a
Progress: into OutputFile, remove unused getFormatContext method
Dec 3, 2014
9c432e8
mediaProperty: check if access of properties is possible
Dec 3, 2014
ec7852c
VideoProperties: clean
Dec 3, 2014
362bf2b
Merge pull request #9 from valnoel/fix_transcoder_progress_computing
cchampet Dec 3, 2014
8efd1f1
OutputFile: make getProgressDuration method virtual
Dec 3, 2014
920c1cb
Merge pull request #11 from valnoel/develop
cchampet Dec 3, 2014
51cf36e
Transcoder: call init in process method
Dec 3, 2014
cfb3669
Transcoder: add private method getTotalDurationFromProcessMethod
Dec 3, 2014
50222f3
Transcoder: refactore process
Dec 3, 2014
3088120
Transcoder: add private method manageInfinityStreamFromProcessMethod
Dec 3, 2014
d6d9545
genericProcessor: clean
Dec 3, 2014
4be8bce
Transcoder: manage FFmpeg log level
Dec 3, 2014
3426082
InputFile: into readNextPacket, return expected data (instead of cach…
Dec 3, 2014
6f99c61
AvInputStream: extract data from file only if the stream cache is empty
Dec 3, 2014
34084cd
Clean use of av_strerror
Dec 3, 2014
4565048
Merge pull request #14 from valnoel/fix_read_next_packet
cchampet Dec 3, 2014
1ab31ca
Merge pull request #13 from cchampet/fix_message_error_buffer_size
valnoel Dec 3, 2014
1227622
Merge pull request #12 from cchampet/move_init_to_process
valnoel Dec 3, 2014
8d48d71
mediaProperty: rename type MetadatasMap to PropertiesMap
Dec 3, 2014
6f0532f
mediaProperty: rename getDataMap to getPropertiesAsMap
Dec 3, 2014
1a51ae4
Merge pull request #10 from cchampet/mediaProperty_check_NULL
valnoel Dec 3, 2014
f5a1b3f
AvInputStream: use std::queue instead of std::vector for stream cache
Dec 4, 2014
f7fb3a0
Merge pull request #15 from valnoel/fix_avinputstream_buffering
cchampet Dec 4, 2014
da3e09c
InputFile: refactore readNextPacket
Dec 3, 2014
3d5937f
Transcoder/StreamTranscoder: rename init to preProcessCodecLatency
Dec 5, 2014
7db5136
Transcoder: fix preProcessCodecLatency
Dec 5, 2014
e9cac6b
OutputFile: check if at least one stream exists when getProgressDuration
Dec 5, 2014
37a5b3f
InputFile / AvInputStream: rename functions about buffer
Dec 3, 2014
692a8da
FileProperties: remove SWIG warnings
Dec 4, 2014
a1ba17e
GeneratorVideo: set type of data to char
Dec 4, 2014
bb71d48
Pixel: fix init from AVPixelFormat
Dec 4, 2014
546d790
VideoTransform: fix fill plane data pointers
Dec 5, 2014
1bce569
Add SWIG interface for frame classes
Dec 4, 2014
f937dda
AvInputAudio: clean readNextFrame
Dec 5, 2014
a855ce9
InputFile: clean
Dec 5, 2014
c5e3186
Merge pull request #16 from cchampet/init_to_preprocessCodecLatency
valnoel Dec 5, 2014
0bdd391
Frame: add function copyData
Dec 5, 2014
42c8529
Merge pull request #17 from cchampet/fix_videoTransform
valnoel Dec 5, 2014
c223d84
Up to v0.4.0
Dec 5, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(AvTranscoder)

# Set AvTranscoder versions
set(AVTRANSCODER_VERSION_MAJOR "0")
set(AVTRANSCODER_VERSION_MINOR "3")
set(AVTRANSCODER_VERSION_MINOR "4")
set(AVTRANSCODER_VERSION_MICRO "0")
set(AVTRANSCODER_VERSION ${AVTRANSCODER_VERSION_MAJOR}.${AVTRANSCODER_VERSION_MINOR}.${AVTRANSCODER_VERSION_MICRO})

Expand Down
56 changes: 51 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
# avTranscoder

C++ API for LibAV / FFMpeg
C++ API for Libav / FFmpeg

Based on LibAV/FFMpeg libraries to support various video formats, avTranscoder provides the high level API to re-wrap or transcode media easily.
Based on Libav/FFmpeg libraries to support various video and audio formats, avTranscoder provides the high level API to re-wrap or transcode media easily.

You can also use its Java & Python bindings for simpler integration in your own projects.
#### What you need to know
* C++ library
* Java and Python bindings generated with SWIG
* multiplateform (Linux, MAC, Windows)
* your call to be based on Libav, FFmpeg, or your custom fork of one of these librairies

#### How to use
Check out applications contained in the project to see examples of how to use the library in C++, Java or Python.

To encode, avTranscoder manipulates profiles.
A profile is a text file which discribes, with a set of key-value, what we want as output for the format, the video, or the audio.
You can create your own profiles and export a variable called ```AVPROFILES``` to indicate the path to them.

The minimum format profile is:
```
avProfileName=profileName
avProfileLongName=profileLongName
avProfileType=avProfileTypeFormat
format=formatName
```

The minimum video profile is:
```
avProfileName=profileName
avProfileLongName=profileLongName
avProfileType=avProfileTypeVideo
codec=codecName
pix_fmt=pixelFormat
r=frameRate
```

The minimum audio profile is:
```
avProfileName=profileName
avProfileLongName=profileLongName
avProfileType=avProfileTypeAudio
codec=codecName
sample_fmt=sampleFormat
```

#### Continuous Integration

Expand All @@ -26,8 +64,16 @@ You can also use its Java & Python bindings for simpler integration in your own
Python tests using nosetests.

Create environment variables to use your files in tests.
* AVTRANSCODER_TEST_AUDIO_FILE
* AVTRANSCODER_TEST_VIDEO_FILE
* ```AVTRANSCODER_TEST_AUDIO_FILE```
* ```AVTRANSCODER_TEST_VIDEO_FILE```

Note: for continuous integration, we launch tests with media files contained in ```avTranscoder-data``` repository.

Launch the tests:
```
cd test/pyTest
nosetests
```

#### Packaging

Expand Down
4 changes: 2 additions & 2 deletions app/avMeta/avMeta.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <AvTranscoder/file/InputFile.hpp>
#include <AvTranscoder/mediaProperty/printMediaProperty.hpp>
#include <AvTranscoder/mediaProperty/print.hpp>

#include <AvTranscoder/progress/NoDisplayProgress.hpp>

Expand All @@ -16,7 +16,7 @@ int main( int argc, char** argv )
avtranscoder::NoDisplayProgress p;

avtranscoder::InputFile input( argv[1] );
input.analyse( p, avtranscoder::InputFile::eAnalyseLevelFull );
input.analyse( p, avtranscoder::eAnalyseLevelFirstGop );

// a simply metadata display
std::cout << input;
Expand Down
2 changes: 1 addition & 1 deletion app/avTranscoder/avTranscoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void transcodeVideo( const char* inputfilename, const char* outputFilename )
InputFile input( inputfilename );
input.analyse( p );

input.readStream( input.getProperties().videoStreams.at( 0 ).streamId );
input.activateStream( input.getProperties().getVideoProperties().at( 0 ).getStreamId() );

// init video decoders
AvInputVideo inputVideo( input.getStream( 0 ) );
Expand Down
12 changes: 6 additions & 6 deletions app/avplay/AvReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <AvTranscoder/essenceStream/AvInputAudio.hpp>
#include <AvTranscoder/essenceStream/AvInputVideo.hpp>
#include <AvTranscoder/transform/VideoTransform.hpp>
#include <AvTranscoder/mediaProperty/printMediaProperty.hpp>
#include <AvTranscoder/mediaProperty/print.hpp>

#include <AvTranscoder/progress/ConsoleProgress.hpp>

Expand All @@ -23,9 +23,9 @@ class AvReader : public Reader
avtranscoder::ConsoleProgress p;

_inputFile.analyse( p );
_videoStream = _inputFile.getProperties().videoStreams.at(0).streamId;
_videoStream = _inputFile.getProperties().getVideoProperties().at(0).getStreamId();

_inputFile.readStream( _videoStream );
_inputFile.activateStream( _videoStream );

_inputVideo = new avtranscoder::AvInputVideo( _inputFile.getStream( _videoStream ) );

Expand Down Expand Up @@ -58,17 +58,17 @@ class AvReader : public Reader

size_t getWidth()
{
return _inputFile.getProperties().videoStreams.at(0).width;
return _inputFile.getProperties().getVideoProperties().at(0).getWidth();
};

size_t getHeight()
{
return _inputFile.getProperties().videoStreams.at(0).height;
return _inputFile.getProperties().getVideoProperties().at(0).getHeight();
}

size_t getComponents()
{
return _inputFile.getProperties().videoStreams.at(0).componentsCount;
return _inputFile.getProperties().getVideoProperties().at(0).getComponentsCount();
}

size_t getBitDepth()
Expand Down
3 changes: 0 additions & 3 deletions app/genericProcessor/genericProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ int main( int argc, char** argv )
// set verbose of all stream
transcoder.setVerbose( verbose );
transcoder.setProcessMethod( avtranscoder::eProcessMethodLongest );
transcoder.init();

if( verbose )
std::cout << "start Transcode" << std::endl;

avtranscoder::ConsoleProgress progress;

// video re-wrapping or transcoding if necessary
transcoder.process( progress );

std::cout << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/ProfileLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace avtranscoder

namespace constants
{
const std::string avProfileIdentificator = "avProfile";
const std::string avProfileIdentificatorHuman = "avProfileLong";
const std::string avProfileIdentificator = "avProfileName";
const std::string avProfileIdentificatorHuman = "avProfileLongName";
const std::string avProfileType = "avProfileType";
const std::string avProfileTypeFormat = "avProfileTypeFormat";
const std::string avProfileTypeVideo = "avProfileTypeVideo";
Expand Down
31 changes: 4 additions & 27 deletions src/AvTranscoder/avTranscoder.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@
%{
#include <AvTranscoder/ProfileLoader.hpp>

#include <AvTranscoder/frame/Pixel.hpp>
#include <AvTranscoder/frame/Frame.hpp>
#include <AvTranscoder/frame/VideoFrame.hpp>
#include <AvTranscoder/frame/AudioFrame.hpp>

#include <AvTranscoder/codec/ICodec.hpp>
#include <AvTranscoder/codec/VideoCodec.hpp>
#include <AvTranscoder/codec/AudioCodec.hpp>
#include <AvTranscoder/codec/DataCodec.hpp>

#include <AvTranscoder/mediaProperty/mediaProperty.hpp>

#include <AvTranscoder/codedStream/IOutputStream.hpp>
#include <AvTranscoder/codedStream/AvOutputStream.hpp>

Expand All @@ -43,43 +36,28 @@
#include <AvTranscoder/essenceStream/GeneratorVideo.hpp>
#include <AvTranscoder/essenceStream/GeneratorAudio.hpp>

#include <AvTranscoder/file/InputFile.hpp>
#include <AvTranscoder/file/OutputFile.hpp>

#include <AvTranscoder/transcoder/StreamTranscoder.hpp>
#include <AvTranscoder/transcoder/Transcoder.hpp>
%}

namespace std {
namespace std {
%template(IntPair) pair< size_t, size_t >;
%template(VideoVector) vector< avtranscoder::VideoProperties >;
%template(AudioVector) vector< avtranscoder::AudioProperties >;
%template(MetadataPair) pair< string, string >;
%template(MetadatasVector) vector< pair< string, string > >;
%template(GopPair) pair< char, bool >;
%template(GopVector) vector< pair< char, bool > >;
%template(ChannelVector) vector< avtranscoder::Channel >;
%template(ProfileMap) map< string, string >;
%template(ProfilesVector) vector< map< string, string > >;
%template(DataBuffer) std::vector< unsigned char >;
}

%include "AvTranscoder/progress/progress.i"
%include "AvTranscoder/mediaProperty/mediaProperty.i"
%include "AvTranscoder/frame/frame.i"

%include <AvTranscoder/ProfileLoader.hpp>

%include <AvTranscoder/frame/Pixel.hpp>
%include <AvTranscoder/frame/Frame.hpp>
%include <AvTranscoder/frame/VideoFrame.hpp>
%include <AvTranscoder/frame/AudioFrame.hpp>

%include <AvTranscoder/codec/ICodec.hpp>
%include <AvTranscoder/codec/VideoCodec.hpp>
%include <AvTranscoder/codec/AudioCodec.hpp>
%include <AvTranscoder/codec/DataCodec.hpp>

%include <AvTranscoder/mediaProperty/mediaProperty.hpp>

%include <AvTranscoder/codedStream/IOutputStream.hpp>
%include <AvTranscoder/codedStream/AvOutputStream.hpp>

Expand All @@ -96,8 +74,7 @@ namespace std {
%include <AvTranscoder/essenceStream/GeneratorVideo.hpp>
%include <AvTranscoder/essenceStream/GeneratorAudio.hpp>

%include <AvTranscoder/file/InputFile.hpp>
%include <AvTranscoder/file/OutputFile.hpp>
%include "AvTranscoder/file/file.i"

%include <AvTranscoder/transcoder/StreamTranscoder.hpp>
%include <AvTranscoder/transcoder/Transcoder.hpp>
64 changes: 23 additions & 41 deletions src/AvTranscoder/codedStream/AvInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ AvInputStream::AvInputStream( InputFile& inputFile, const size_t streamIndex )
: IInputStream( )
, _inputFile( &inputFile )
, _codec( NULL )
, _streamCache()
, _streamIndex( streamIndex )
, _bufferized( false )
, _isActivated( false )
{
AVCodecContext* context = _inputFile->getFormatContext().streams[_streamIndex]->codec;

Expand All @@ -35,13 +36,6 @@ AvInputStream::AvInputStream( InputFile& inputFile, const size_t streamIndex )
}
case AVMEDIA_TYPE_AUDIO:
{
double outputFps = 25;
size_t bytePerSample = av_get_bytes_per_sample( context->sample_fmt );

context->block_align = 1.0 * context->sample_rate * context->channels * bytePerSample / outputFps;
// std::cout << "channels " << context->channel_layout << std::endl;
// std::cout << "audio buffer read size " << context->block_align << std::endl;

AudioCodec* audioCodec = new AudioCodec( eCodecTypeDecoder, context->codec_id );
audioCodec->setAudioParameters( context->sample_rate, context->channels, context->sample_fmt );

Expand All @@ -64,8 +58,9 @@ AvInputStream::AvInputStream( const AvInputStream& inputStream )
: IInputStream( )
, _inputFile( inputStream._inputFile )
, _codec( inputStream._codec )
, _streamCache()
, _streamIndex( inputStream._streamIndex )
, _bufferized( inputStream._bufferized )
, _isActivated( inputStream._isActivated )
{
}

Expand All @@ -76,46 +71,33 @@ AvInputStream::~AvInputStream( )

bool AvInputStream::readNextPacket( CodedData& data )
{
if( ! _bufferized )
throw std::runtime_error( "Can't read packet on non-bufferized input stream." );

if( _streamCache.empty() )
_inputFile->readNextPacket( _streamIndex );

if( _streamCache.empty() )
return false;
if( ! _isActivated )
throw std::runtime_error( "Can't read packet on non-activated input stream." );

_streamCache.front().getBuffer().swap( data.getBuffer() );

_streamCache.erase( _streamCache.begin() );
// if packet is already cached
if( ! _streamCache.empty() )
{
_streamCache.front().getBuffer().swap( data.getBuffer() );
_streamCache.pop();
}
// else read next packet
else
{
return _inputFile->readNextPacket( data, _streamIndex ) && _streamCache.empty();
}

return true;
}

void AvInputStream::addPacket( AVPacket& packet )
{
//std::cout << "add packet for stream " << _streamIndex << std::endl;
CodedData data;
_streamCache.push_back( data );

if( ! _bufferized )
// Do not cache data if the stream is declared as unused in process
if( ! _isActivated )
return;

// is it possible to remove this copy ?
// using : av_packet_unref ?
_streamCache.back().getBuffer().resize( packet.size );
if( packet.size != 0 )
memcpy( _streamCache.back().getPtr(), packet.data, packet.size );

// std::vector<unsigned char> tmpData( 0,0 );
// &tmpData[0] = packet.data;
// tmpData.size( packet.size );

// remove reference on packet because it's passed to CodedData
// packet.data = NULL;
// packet.size = 0;

// std::cout << this << " buffer size " << _streamCache.size() << std::endl;
CodedData data;
_streamCache.push( data );
_streamCache.back().copyData( packet.data, packet.size );
}

VideoCodec& AvInputStream::getVideoCodec()
Expand Down Expand Up @@ -166,7 +148,7 @@ double AvInputStream::getDuration() const

void AvInputStream::clearBuffering()
{
_streamCache.clear();
_streamCache = std::queue<CodedData>();
}

AVStream* AvInputStream::getAVStream() const
Expand Down
10 changes: 6 additions & 4 deletions src/AvTranscoder/codedStream/AvInputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "IInputStream.hpp"

#include <queue>

struct AVStream;

namespace avtranscoder
Expand Down Expand Up @@ -33,8 +35,8 @@ class AvExport AvInputStream : public IInputStream

void addPacket( AVPacket& packet );

void setBufferred( const bool bufferized ){ _bufferized = bufferized; };
bool getBufferred() const { return _bufferized; };
void activate( const bool activate = true ){ _isActivated = activate; };
bool isActivated() const { return _isActivated; };

void clearBuffering();

Expand All @@ -45,10 +47,10 @@ class AvExport AvInputStream : public IInputStream
InputFile* _inputFile; ///< Has link (no ownership)
ICodec* _codec; ///< Has ownership

std::vector<CodedData> _streamCache;
std::queue<CodedData> _streamCache; ///< Cache of packet data already read and corresponding to this stream

size_t _streamIndex; ///< Index of the stream in the input file
bool _bufferized; ///< If the stream is bufferized
bool _isActivated; ///< If the stream is activated, data read from it will be buffered
};

}
Expand Down
Loading