From 2596a4e9226e7fc093aa95f0d9f9cfd17e366be0 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 27 Apr 2015 10:48:01 +0200 Subject: [PATCH 01/54] Travis: deploy on tag --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index 08f7ca96..edec4773 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,3 +34,16 @@ script: - cd .. - chmod +x tools/travis.python.nosetests.sh - if [ "${TRAVIS_OS_NAME}" = "linux" && "${DEPENDENCY_MODE}" = "ffmpeg" ]; then ./tools/travis.python.nosetests.sh; fi + +before_deploy: + - cd ${TRAVIS_BUILD_DIR} + - tar -cvzf avtranscoder_install.tgz build/dist/ + +deploy: + provider: releases + api_key: + secure: "${GITHUB_RELEASE_API_KEY}" + file: avtranscoder_install.tgz + skip_cleanup: true + on: + tags: true From b526dd3e51975606b8702240040361b3e180bd0c Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 12:15:00 +0200 Subject: [PATCH 02/54] Travis: deploy ffmpeg/libav dependency --- .travis.yml | 11 ++++++----- tools/travis.linux.install.deps.sh | 4 ++-- tools/travis.python.nosetests.sh | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 011d7d28..c61aacaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ env: global: - - AVTRANSCODER_BUILD=${TRAVIS_BUILD_DIR}/build - - AVTRANSCODER_INSTALL=${TRAVIS_BUILD_DIR}/install + - AVTRANSCODER_BUILD=${TRAVIS_BUILD_DIR}/build-avtranscoder + - AVTRANSCODER_INSTALL=${TRAVIS_BUILD_DIR}/install-avtranscoder + - DEPENDENCY_INSTALL=${TRAVIS_BUILD_DIR}/install-dependency - J='-j3' matrix: - DEPENDENCY_MODE=libav @@ -35,7 +36,7 @@ script: # Build - mkdir -p ${AVTRANSCODER_BUILD} - cd ${AVTRANSCODER_BUILD} - - cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=True + - cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=True - make $J install # Launch tests @@ -48,8 +49,8 @@ after_success: - if [ "${CC}" = "gcc" ]; then ./tools/travis.gcc.generate.coverage.sh; fi before_deploy: - - cd ${AVTRANSCODER_INSTALL} - - tar -cvzf avtranscoder_install.tgz . + - cd ${TRAVIS_BUILD_DIR} + - tar -cvzf avtranscoder_install.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} deploy: provider: releases diff --git a/tools/travis.linux.install.deps.sh b/tools/travis.linux.install.deps.sh index c3af0376..a7b54427 100755 --- a/tools/travis.linux.install.deps.sh +++ b/tools/travis.linux.install.deps.sh @@ -16,13 +16,13 @@ if [[ ${DEPENDENCY_MODE} == "ffmpeg" ]]; then sudo bunzip2 ffmpeg-${FFMPEG_VERSION}.tar.bz2 sudo tar -xvf ffmpeg-${FFMPEG_VERSION}.tar cd ffmpeg-${FFMPEG_VERSION} - sudo ./configure --disable-yasm --enable-shared --disable-static && sudo make && sudo make install + sudo ./configure --prefix=${DEPENDENCY_INSTALL} --disable-yasm --enable-shared --disable-static && sudo make && sudo make install elif [[ ${DEPENDENCY_MODE} == "libav" ]]; then export LIBAV_VERSION=11.3 sudo wget https://libav.org/releases/libav-${LIBAV_VERSION}.tar.gz sudo tar -xvf libav-${LIBAV_VERSION}.tar.gz cd libav-${LIBAV_VERSION} - sudo ./configure --disable-yasm --enable-shared --disable-static && sudo make && sudo make install + sudo ./configure --prefix=${DEPENDENCY_INSTALL} --disable-yasm --enable-shared --disable-static && sudo make && sudo make install fi diff --git a/tools/travis.python.nosetests.sh b/tools/travis.python.nosetests.sh index e65a82e7..c1507c4b 100755 --- a/tools/travis.python.nosetests.sh +++ b/tools/travis.python.nosetests.sh @@ -1,6 +1,7 @@ #!/bin/bash # Get avtranscoder library +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${DEPENDENCY_INSTALL}/lib export PYTHONPATH=${AVTRANSCODER_INSTALL}/lib/python2.7.6/site-packages/:$PYTHONPATH # Get avtranscoder profiles From 6a62af45bde8d1084afc4971eb0b7c23148e49fa Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 15:18:38 +0200 Subject: [PATCH 03/54] ICodec: suppress swig warning with open method * Rename open to openCodec. * Swig warning 321: 'open' conflicts with a built-in name in python. --- src/AvTranscoder/codec/ICodec.cpp | 2 +- src/AvTranscoder/codec/ICodec.hpp | 2 +- src/AvTranscoder/decoder/AudioDecoder.cpp | 2 +- src/AvTranscoder/decoder/VideoDecoder.cpp | 2 +- src/AvTranscoder/encoder/AudioEncoder.cpp | 2 +- src/AvTranscoder/encoder/VideoEncoder.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/AvTranscoder/codec/ICodec.cpp b/src/AvTranscoder/codec/ICodec.cpp index e1a5949f..7cc51efa 100644 --- a/src/AvTranscoder/codec/ICodec.cpp +++ b/src/AvTranscoder/codec/ICodec.cpp @@ -51,7 +51,7 @@ ICodec::~ICodec() _avCodecContext = NULL; } -void ICodec::open() +void ICodec::openCodec() { if( ! _avCodecContext ) throw std::runtime_error( "unable to open a codec with no codec context" ); diff --git a/src/AvTranscoder/codec/ICodec.hpp b/src/AvTranscoder/codec/ICodec.hpp index 60add8bb..d1257bf8 100644 --- a/src/AvTranscoder/codec/ICodec.hpp +++ b/src/AvTranscoder/codec/ICodec.hpp @@ -36,7 +36,7 @@ class AvExport ICodec virtual ~ICodec() = 0; /// Initialize the codec context. - void open(); + void openCodec(); std::string getCodecName() const; AVCodecID getCodecId() const; diff --git a/src/AvTranscoder/decoder/AudioDecoder.cpp b/src/AvTranscoder/decoder/AudioDecoder.cpp index 21e91d16..fe6391e2 100644 --- a/src/AvTranscoder/decoder/AudioDecoder.cpp +++ b/src/AvTranscoder/decoder/AudioDecoder.cpp @@ -52,7 +52,7 @@ AudioDecoder::~AudioDecoder() void AudioDecoder::setup() { - _inputStream->getAudioCodec().open(); + _inputStream->getAudioCodec().openCodec(); } bool AudioDecoder::decodeNextFrame( Frame& frameBuffer ) diff --git a/src/AvTranscoder/decoder/VideoDecoder.cpp b/src/AvTranscoder/decoder/VideoDecoder.cpp index 8e8b4543..b551a334 100644 --- a/src/AvTranscoder/decoder/VideoDecoder.cpp +++ b/src/AvTranscoder/decoder/VideoDecoder.cpp @@ -50,7 +50,7 @@ VideoDecoder::~VideoDecoder() void VideoDecoder::setup() { - _inputStream->getVideoCodec().open(); + _inputStream->getVideoCodec().openCodec(); } bool VideoDecoder::decodeNextFrame( Frame& frameBuffer ) diff --git a/src/AvTranscoder/encoder/AudioEncoder.cpp b/src/AvTranscoder/encoder/AudioEncoder.cpp index bb3d6acb..c10fbd4c 100644 --- a/src/AvTranscoder/encoder/AudioEncoder.cpp +++ b/src/AvTranscoder/encoder/AudioEncoder.cpp @@ -37,7 +37,7 @@ AudioEncoder::~AudioEncoder() void AudioEncoder::setup() { - _codec.open(); + _codec.openCodec(); } bool AudioEncoder::encodeFrame( const Frame& sourceFrame, Frame& codedFrame ) diff --git a/src/AvTranscoder/encoder/VideoEncoder.cpp b/src/AvTranscoder/encoder/VideoEncoder.cpp index 1b462417..d0bd0064 100644 --- a/src/AvTranscoder/encoder/VideoEncoder.cpp +++ b/src/AvTranscoder/encoder/VideoEncoder.cpp @@ -38,7 +38,7 @@ VideoEncoder::~VideoEncoder() void VideoEncoder::setup() { - _codec.open(); + _codec.openCodec(); } From 22978723c7574f980ee615d8b037f24c0ac3b52f Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 15:20:07 +0200 Subject: [PATCH 04/54] Frame: hide methods to SWIG AVPacket is an unknown type for SWIG. --- src/AvTranscoder/frame/Frame.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AvTranscoder/frame/Frame.hpp b/src/AvTranscoder/frame/Frame.hpp index 432818cd..2814a3a9 100644 --- a/src/AvTranscoder/frame/Frame.hpp +++ b/src/AvTranscoder/frame/Frame.hpp @@ -19,8 +19,10 @@ class AvExport Frame /// Create a frame with a the given buffer size Frame( const size_t dataSize ); +#ifndef SWIG /// Create a frame from the given AVPAcket (copy data of given packet) Frame( const AVPacket& avPacket ); +#endif /// Override copy constructor in order to copy AVPacket data Frame( const Frame& other ); @@ -52,11 +54,11 @@ class AvExport Frame /// Clear existing data and set size to 0 void clear(); - AVPacket& getAVPacket() { return _packet; } unsigned char* getData() { return _packet.data; } size_t getSize() const { return _packet.size; } #ifndef SWIG + AVPacket& getAVPacket() { return _packet; } const AVPacket& getAVPacket() const { return _packet; } const unsigned char* getData() const { return _packet.data; } #endif From a9b634ceb92b612ab66cbc50feb003514f0cbd7d Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 15:22:05 +0200 Subject: [PATCH 05/54] SWIG: add avOperator.i to suppress swig warnings * operator= => "__assign__" in python. * operator= => "clone" in java. --- src/AvTranscoder/avTranscoder.i | 1 + src/AvTranscoder/swig/avOperator.i | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 src/AvTranscoder/swig/avOperator.i diff --git a/src/AvTranscoder/avTranscoder.i b/src/AvTranscoder/avTranscoder.i index 8d463428..c394ed13 100644 --- a/src/AvTranscoder/avTranscoder.i +++ b/src/AvTranscoder/avTranscoder.i @@ -13,6 +13,7 @@ %include "AvTranscoder/swig/avMediaType.i" %include "AvTranscoder/swig/avRational.i" %include "AvTranscoder/swig/avLogLevel.i" +%include "AvTranscoder/swig/avOperator.i" %{ #include diff --git a/src/AvTranscoder/swig/avOperator.i b/src/AvTranscoder/swig/avOperator.i new file mode 100644 index 00000000..215e3652 --- /dev/null +++ b/src/AvTranscoder/swig/avOperator.i @@ -0,0 +1,7 @@ +#if SWIGPYTHON + %rename(__assign__) *::operator=; +#endif + +#if SWIGJAVA + %rename(clone) *::operator=; +#endif From 0173f83fe46523376f3b61efbe7ffaff33affa54 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 15:30:58 +0200 Subject: [PATCH 06/54] SWIG: add flags when compile bindings * New flags: * fcompact - Compile in compact mode * small - Compile in virtual elimination & compact mode * O - Enable the optimization options: -fastdispatch -fvirtual * Werror - Treat warnings as errors * Fix #179 --- src/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e4ce98b..d0af291e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -76,6 +76,9 @@ if(SWIG_FOUND) set(AVTRANSCODER_BINDING_FILE "AvTranscoder/avTranscoder.i") set_source_files_properties(${AVTRANSCODER_BINDING_FILE} PROPERTIES CPLUSPLUS ON) + # Swig flags + set(CMAKE_SWIG_FLAGS -c++ -fcompact -small -O -Werror) + ### PYTHON BINDING if(AVTRANSCODER_DISABLE_PYTHON_BINDING) message("PYTHON binding disabled, will not build python binding.") @@ -84,9 +87,6 @@ if(SWIG_FOUND) if(PYTHONLIBS_FOUND) include_directories(${PYTHON_INCLUDE_PATH}) - # Swig flags - set(CMAKE_SWIG_FLAGS -c++ -fcompact) - # Create '_avtranscoder' shared lib (python) swig_add_module(avtranscoder-py python ${AVTRANSCODER_BINDING_FILE}) # For Python binding, need to compile the wrapper into a lib called "_.so" @@ -131,7 +131,7 @@ if(SWIG_FOUND) include_directories(${JNI_INCLUDE_DIRS}) # Swig flags - set(CMAKE_SWIG_FLAGS -c++ -fcompact -package org.avtranscoder) + set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -package org.avtranscoder) # Create 'avtranscoder-java' shared lib swig_add_module(avtranscoder-java java ${AVTRANSCODER_BINDING_FILE}) From 4e75c0cf9acce4198cb2daa08fa0886be9e7782f Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 12:20:19 +0200 Subject: [PATCH 07/54] Travis: deploy only if linux build --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c61aacaa..261f1d62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,14 +50,15 @@ after_success: before_deploy: - cd ${TRAVIS_BUILD_DIR} - - tar -cvzf avtranscoder_install.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} + - tar -cvzf avtranscoder-dev-${DEPENDENCY_MODE}.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} deploy: provider: releases api_key: secure: "${GITHUB_RELEASE_API_KEY}" - file: avtranscoder_install.tgz + file: avtranscoder-dev-${DEPENDENCY_MODE}.tgz skip_cleanup: true on: tags: true + condition: ${TRAVIS_OS_NAME} = "linux" From fc442c29babc759df9ab599a7a250719a922bac8 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 13:28:39 +0200 Subject: [PATCH 08/54] Travis: clean --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 261f1d62..bd4b494f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,8 +29,8 @@ before_script: - ./tools/travis.gcc.install.coverage.sh # install avtranscoder dependencies - - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./tools/travis.linux.install.deps.sh; fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis.osx.install.deps.sh; fi + - if [ ${TRAVIS_OS_NAME} = "linux" ]; then ./tools/travis.linux.install.deps.sh; fi + - if [ ${TRAVIS_OS_NAME} = "osx" ]; then ./tools/travis.osx.install.deps.sh; fi script: # Build @@ -40,13 +40,13 @@ script: - make $J install # Launch tests - - if [ "${DEPENDENCY_MODE}" = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi + - if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi after_success: - cd ${TRAVIS_BUILD_DIR} # generate coverage for coveralls - - if [ "${CC}" = "gcc" ]; then ./tools/travis.gcc.generate.coverage.sh; fi + - if [ ${CC} = "gcc" ]; then ./tools/travis.gcc.generate.coverage.sh; fi before_deploy: - cd ${TRAVIS_BUILD_DIR} @@ -55,7 +55,7 @@ before_deploy: deploy: provider: releases api_key: - secure: "${GITHUB_RELEASE_API_KEY}" + secure: ${GITHUB_RELEASE_API_KEY} file: avtranscoder-dev-${DEPENDENCY_MODE}.tgz skip_cleanup: true on: From 2fa03dbbdaf3adea96ffb8d5dff01af6ae1fd1cb Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 16:46:04 +0200 Subject: [PATCH 09/54] Profiles: remove 'g' option from dnxhd profiles Fix #182 --- ressource/v_dnxhd120.prf | 1 - ressource/v_dnxhd175x.prf | 1 - ressource/v_dnxhd185.prf | 1 - ressource/v_dnxhd185x.prf | 1 - ressource/v_dnxhd36.prf | 1 - 5 files changed, 5 deletions(-) diff --git a/ressource/v_dnxhd120.prf b/ressource/v_dnxhd120.prf index 6029313f..22a808d4 100644 --- a/ressource/v_dnxhd120.prf +++ b/ressource/v_dnxhd120.prf @@ -6,5 +6,4 @@ width=1920 height=1080 pix_fmt=yuv422p b=120M -g=1 r=25 diff --git a/ressource/v_dnxhd175x.prf b/ressource/v_dnxhd175x.prf index 06a4cbc6..bf87d586 100644 --- a/ressource/v_dnxhd175x.prf +++ b/ressource/v_dnxhd175x.prf @@ -6,5 +6,4 @@ width=1920 height=1080 pix_fmt=yuv422p10le b=175M -g=1 r=25 diff --git a/ressource/v_dnxhd185.prf b/ressource/v_dnxhd185.prf index 00c70558..38e9c93b 100644 --- a/ressource/v_dnxhd185.prf +++ b/ressource/v_dnxhd185.prf @@ -6,5 +6,4 @@ width=1920 height=1080 pix_fmt=yuv422p b=185M -g=1 r=25 diff --git a/ressource/v_dnxhd185x.prf b/ressource/v_dnxhd185x.prf index c8d2602e..652a882a 100644 --- a/ressource/v_dnxhd185x.prf +++ b/ressource/v_dnxhd185x.prf @@ -6,5 +6,4 @@ width=1920 height=1080 pix_fmt=yuv422p10le b=185M -g=1 r=25 diff --git a/ressource/v_dnxhd36.prf b/ressource/v_dnxhd36.prf index 63e96ea8..d11e32e0 100644 --- a/ressource/v_dnxhd36.prf +++ b/ressource/v_dnxhd36.prf @@ -6,5 +6,4 @@ width=1920 height=1080 pix_fmt=yuv422p b=36M -g=1 r=25 From 419439065c468e5768305a7017a3c9a2e4c67e1a Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 17:18:46 +0200 Subject: [PATCH 10/54] Travis: add documentation --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd4b494f..0e8c91e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,13 +33,13 @@ before_script: - if [ ${TRAVIS_OS_NAME} = "osx" ]; then ./tools/travis.osx.install.deps.sh; fi script: - # Build + # build - mkdir -p ${AVTRANSCODER_BUILD} - cd ${AVTRANSCODER_BUILD} - cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=True - make $J install - # Launch tests + # launch tests - if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi after_success: @@ -49,10 +49,12 @@ after_success: - if [ ${CC} = "gcc" ]; then ./tools/travis.gcc.generate.coverage.sh; fi before_deploy: + # create archive - cd ${TRAVIS_BUILD_DIR} - tar -cvzf avtranscoder-dev-${DEPENDENCY_MODE}.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} deploy: + # if the commit is tagged, deploy using github release service provider: releases api_key: secure: ${GITHUB_RELEASE_API_KEY} From 473d4386d4e8f7c152b345427821e81a3d965f96 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 30 Apr 2015 17:23:05 +0200 Subject: [PATCH 11/54] Travis: rename the archives deployed --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e8c91e5..e7d48439 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,14 +51,14 @@ after_success: before_deploy: # create archive - cd ${TRAVIS_BUILD_DIR} - - tar -cvzf avtranscoder-dev-${DEPENDENCY_MODE}.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} + - tar -cvzf avtranscoder-${TRAVIS_OS_NAME}-${CC}-${DEPENDENCY_MODE}.tgz ${DEPENDENCY_INSTALL} ${AVTRANSCODER_INSTALL} deploy: # if the commit is tagged, deploy using github release service provider: releases api_key: secure: ${GITHUB_RELEASE_API_KEY} - file: avtranscoder-dev-${DEPENDENCY_MODE}.tgz + file: avtranscoder-${TRAVIS_OS_NAME}-${CC}-${DEPENDENCY_MODE}.tgz skip_cleanup: true on: tags: true From 6e7756370b5c12963c06ef4d5f92286b60abf003 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Thu, 30 Apr 2015 19:46:56 +0200 Subject: [PATCH 12/54] FileProperties: StreamProperties pointers stored by streamIndex into a map --- .../mediaProperty/FileProperties.cpp | 20 +++++++++---------- .../mediaProperty/FileProperties.hpp | 4 +++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/AvTranscoder/mediaProperty/FileProperties.cpp b/src/AvTranscoder/mediaProperty/FileProperties.cpp index ed595bf2..de278187 100644 --- a/src/AvTranscoder/mediaProperty/FileProperties.cpp +++ b/src/AvTranscoder/mediaProperty/FileProperties.cpp @@ -82,22 +82,22 @@ void FileProperties::extractStreamProperties( IProgress& progress, const EAnalys // once the streams vectors are filled, add their references the base streams vector for( size_t streamIndex = 0; streamIndex < _videoStreams.size(); ++streamIndex ) - _streams.push_back( &_videoStreams.at( streamIndex ) ); + _streams[ _videoStreams.at( streamIndex ).getStreamIndex() ] = &_videoStreams.at( streamIndex ); for( size_t streamIndex = 0; streamIndex < _audioStreams.size(); ++ streamIndex ) - _streams.push_back( &_audioStreams.at(streamIndex) ); + _streams[ _audioStreams.at(streamIndex).getStreamIndex() ] = &_audioStreams.at(streamIndex); for( size_t streamIndex = 0; streamIndex < _dataStreams.size(); ++ streamIndex ) - _streams.push_back( &_dataStreams.at(streamIndex) ); + _streams[ _dataStreams.at(streamIndex).getStreamIndex() ] = &_dataStreams.at(streamIndex); for( size_t streamIndex = 0; streamIndex < _subtitleStreams.size(); ++ streamIndex ) - _streams.push_back( &_subtitleStreams.at(streamIndex) ); + _streams[ _subtitleStreams.at(streamIndex).getStreamIndex() ] = &_subtitleStreams.at(streamIndex); for( size_t streamIndex = 0; streamIndex < _attachementStreams.size(); ++ streamIndex ) - _streams.push_back( &_attachementStreams.at(streamIndex) ); + _streams[ _attachementStreams.at(streamIndex).getStreamIndex() ] = &_attachementStreams.at(streamIndex); for( size_t streamIndex = 0; streamIndex < _unknownStreams.size(); ++ streamIndex ) - _streams.push_back( &_unknownStreams.at(streamIndex) ); + _streams[ _unknownStreams.at(streamIndex).getStreamIndex() ] = &_unknownStreams.at(streamIndex); // if the analysis level has decoded some streams parts, return at the beginning if( level > eAnalyseLevelHeader ) @@ -162,11 +162,9 @@ size_t FileProperties::getPacketSize() const const avtranscoder::StreamProperties& FileProperties::getStreamPropertiesWithIndex( const size_t streamIndex ) const { - for( std::vector< StreamProperties* >::const_iterator it = _streams.begin(); it != _streams.end(); ++it ) - { - if( (*it)->getStreamIndex() == streamIndex ) - return *(*it); - } + avtranscoder::StreamProperties* properties = _streams.find( streamIndex )->second; + if( properties ) + return *properties; std::stringstream os; os << "No stream properties correspond to stream at index "; os << streamIndex; diff --git a/src/AvTranscoder/mediaProperty/FileProperties.hpp b/src/AvTranscoder/mediaProperty/FileProperties.hpp index 6ee440c1..14b71cff 100644 --- a/src/AvTranscoder/mediaProperty/FileProperties.hpp +++ b/src/AvTranscoder/mediaProperty/FileProperties.hpp @@ -16,6 +16,7 @@ #include #include +#include namespace avtranscoder { @@ -102,7 +103,8 @@ class AvExport FileProperties const FormatContext* _formatContext; ///< Has link (no ownership) const AVFormatContext* _avFormatContext; ///< Has link (no ownership) - std::vector< StreamProperties* > _streams; ///< Array of properties per stream (of all types) - only references to the following properties + std::map< size_t, StreamProperties* > _streams; ///< Map of properties per stream index (of all types) - only references to the following properties + std::vector< VideoProperties > _videoStreams; ///< Array of properties per video stream std::vector< AudioProperties > _audioStreams; ///< Array of properties per audio stream std::vector< DataProperties > _dataStreams; ///< Array of properties per data stream From 2e7d79110de9705d4e8bda0bdc716b0f4ece49f8 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Mon, 4 May 2015 17:01:05 +0200 Subject: [PATCH 13/54] FileProperties: add exception documentation about the getStreamPropertiesWithIndex method --- src/AvTranscoder/mediaProperty/FileProperties.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AvTranscoder/mediaProperty/FileProperties.hpp b/src/AvTranscoder/mediaProperty/FileProperties.hpp index 14b71cff..e90c3ab0 100644 --- a/src/AvTranscoder/mediaProperty/FileProperties.hpp +++ b/src/AvTranscoder/mediaProperty/FileProperties.hpp @@ -62,6 +62,7 @@ class AvExport FileProperties //@{ // @brief Get the properties at the indicated stream index + // @throws A runtime error if the streamIndex does not match any stream const avtranscoder::StreamProperties& getStreamPropertiesWithIndex( const size_t streamIndex ) const; //@} From 2b68780f3df10c62e11474cc6bde0205673bb112 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 May 2015 17:47:52 +0200 Subject: [PATCH 14/54] Travis: clean build optimization Fix #183 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7d48439..4ce8383e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ env: - AVTRANSCODER_BUILD=${TRAVIS_BUILD_DIR}/build-avtranscoder - AVTRANSCODER_INSTALL=${TRAVIS_BUILD_DIR}/install-avtranscoder - DEPENDENCY_INSTALL=${TRAVIS_BUILD_DIR}/install-dependency - - J='-j3' + - CI_NODE_TOTAL=2 matrix: - DEPENDENCY_MODE=libav - DEPENDENCY_MODE=ffmpeg @@ -37,7 +37,7 @@ script: - mkdir -p ${AVTRANSCODER_BUILD} - cd ${AVTRANSCODER_BUILD} - cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=True - - make $J install + - make -j${CI_NODE_TOTAL} install # launch tests - if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi From 6b53ed1692b0217452fe59088836ec648b0d1124 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Tue, 5 May 2015 12:18:17 +0200 Subject: [PATCH 15/54] hotfix: unset decoder (generator) after codec latency processing on rewrap --- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index 85b549d5..c871881b 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -322,6 +322,9 @@ void StreamTranscoder::preProcessCodecLatency() { processFrame(); } + + if( isRewrapCase() ) + _currentDecoder = NULL; } bool StreamTranscoder::processFrame() From 5fb1558437e10b8292f860336a0189c8469d94ca Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Tue, 5 May 2015 12:20:26 +0200 Subject: [PATCH 16/54] hotfix: fix to generator switch on BasedOnDuration process method --- src/AvTranscoder/transcoder/Transcoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index bcc3d906..4b6bef87 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -500,7 +500,7 @@ void Transcoder::manageSwitchToGenerator() _streamTranscoders.at( i )->canSwitchToGenerator( false ); break; case eProcessMethodBasedOnDuration : - if( _streamTranscoders.at( i )->getDuration() > _outputDuration ) + if( _streamTranscoders.at( i )->getDuration() >= _outputDuration ) _streamTranscoders.at( i )->canSwitchToGenerator( false ); else _streamTranscoders.at( i )->canSwitchToGenerator( true ); From a35585f8c34a7c37081c1076806d420caa9e23ab Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Tue, 5 May 2015 14:16:57 +0200 Subject: [PATCH 17/54] hotfix: InputFile::seek at the exact frame Update documentation of InputFile::seekxxx functions. --- src/AvTranscoder/file/InputFile.cpp | 4 ++-- src/AvTranscoder/file/InputFile.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AvTranscoder/file/InputFile.cpp b/src/AvTranscoder/file/InputFile.cpp index ace44270..1b105b80 100644 --- a/src/AvTranscoder/file/InputFile.cpp +++ b/src/AvTranscoder/file/InputFile.cpp @@ -86,13 +86,13 @@ bool InputFile::readNextPacket( CodedData& data, const size_t streamIndex ) void InputFile::seekAtFrame( const size_t frame ) { uint64_t position = frame / getFps() * AV_TIME_BASE; - _formatContext.seek( position, AVSEEK_FLAG_BACKWARD ); + _formatContext.seek( position, AVSEEK_FLAG_ANY ); } void InputFile::seekAtTime( const double time ) { uint64_t position = time * AV_TIME_BASE; - _formatContext.seek( position, AVSEEK_FLAG_BACKWARD ); + _formatContext.seek( position, AVSEEK_FLAG_ANY ); } void InputFile::activateStream( const size_t streamIndex, bool activate ) diff --git a/src/AvTranscoder/file/InputFile.hpp b/src/AvTranscoder/file/InputFile.hpp index 46cda564..604c8cc2 100644 --- a/src/AvTranscoder/file/InputFile.hpp +++ b/src/AvTranscoder/file/InputFile.hpp @@ -48,9 +48,9 @@ class AvExport InputFile bool readNextPacket( CodedData& data, const size_t streamIndex ); /** - * @brief Seek input stream at specified frame - * @note clean also buffers in each InputStream - * @return if next packet was read succefully + * @brief Seek at a specific frame / time (in seconds) + * @note Seek in file by using the default stream (according to ffmpeg) + * @warning If the seek is done to a non key-frame, the decoding will start from the next key-frame **/ void seekAtFrame( const size_t frame ); void seekAtTime( const double time ); From 6b4373c5f9bf6d37d5939ae6ac451bc182207ef5 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Tue, 5 May 2015 17:30:43 +0200 Subject: [PATCH 18/54] hotfix: encoders/decoders - by default set threads to the value expected by the codec If indicated in profile, force threads value. --- src/AvTranscoder/decoder/AudioDecoder.cpp | 2 +- src/AvTranscoder/decoder/VideoDecoder.cpp | 2 +- src/AvTranscoder/encoder/AudioEncoder.cpp | 2 +- src/AvTranscoder/encoder/VideoEncoder.cpp | 2 +- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/AvTranscoder/decoder/AudioDecoder.cpp b/src/AvTranscoder/decoder/AudioDecoder.cpp index 21e91d16..b140f44c 100644 --- a/src/AvTranscoder/decoder/AudioDecoder.cpp +++ b/src/AvTranscoder/decoder/AudioDecoder.cpp @@ -155,7 +155,7 @@ void AudioDecoder::setProfile( const ProfileLoader::Profile& profile ) if( profile.count( constants::avProfileThreads ) ) codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) ); else - codec.getOption( constants::avProfileThreads ).setString( "auto" ); + codec.getOption( constants::avProfileThreads ).setInt( codec.getAVCodecContext().thread_count ); // set decoder options for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it ) diff --git a/src/AvTranscoder/decoder/VideoDecoder.cpp b/src/AvTranscoder/decoder/VideoDecoder.cpp index 8e8b4543..6bc17a48 100644 --- a/src/AvTranscoder/decoder/VideoDecoder.cpp +++ b/src/AvTranscoder/decoder/VideoDecoder.cpp @@ -114,7 +114,7 @@ void VideoDecoder::setProfile( const ProfileLoader::Profile& profile ) if( profile.count( constants::avProfileThreads ) ) codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) ); else - codec.getOption( constants::avProfileThreads ).setString( "auto" ); + codec.getOption( constants::avProfileThreads ).setInt( codec.getAVCodecContext().thread_count ); // set decoder options for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it ) diff --git a/src/AvTranscoder/encoder/AudioEncoder.cpp b/src/AvTranscoder/encoder/AudioEncoder.cpp index bb3d6acb..5652d874 100644 --- a/src/AvTranscoder/encoder/AudioEncoder.cpp +++ b/src/AvTranscoder/encoder/AudioEncoder.cpp @@ -144,7 +144,7 @@ void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const Audi if( profile.count( constants::avProfileThreads ) ) _codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) ); else - _codec.getOption( constants::avProfileThreads ).setString( "auto" ); + _codec.getOption( constants::avProfileThreads ).setInt( _codec.getAVCodecContext().thread_count ); // set encoder options diff --git a/src/AvTranscoder/encoder/VideoEncoder.cpp b/src/AvTranscoder/encoder/VideoEncoder.cpp index 1b462417..6a867ddc 100644 --- a/src/AvTranscoder/encoder/VideoEncoder.cpp +++ b/src/AvTranscoder/encoder/VideoEncoder.cpp @@ -137,7 +137,7 @@ void VideoEncoder::setProfile( const ProfileLoader::Profile& profile, const avtr if( profile.count( constants::avProfileThreads ) ) _codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) ); else - _codec.getOption( constants::avProfileThreads ).setString( "auto" ); + _codec.getOption( constants::avProfileThreads ).setInt( _codec.getAVCodecContext().thread_count ); // set encoder options for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it ) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index c871881b..ae8267d4 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -133,7 +133,7 @@ StreamTranscoder::StreamTranscoder( { // input decoder VideoDecoder* inputVideo = new VideoDecoder( *static_cast( _inputStream ) ); - // set decoder options with empty profile to set some key options to specific values (example: threads to auto) + // set decoder options with empty profile to set some key options to specific values inputVideo->setProfile( ProfileLoader::Profile() ); inputVideo->setup(); _inputDecoder = inputVideo; @@ -168,7 +168,7 @@ StreamTranscoder::StreamTranscoder( { // input decoder AudioDecoder* inputAudio = new AudioDecoder( *static_cast( _inputStream ) ); - // set decoder options with empty profile to set some key options to specific values (example: threads to auto) + // set decoder options with empty profile to set some key options to specific values inputAudio->setProfile( ProfileLoader::Profile() ); inputAudio->setup(); _inputDecoder = inputAudio; From db08b2f27188bc6629f55e61bb7daf33a5af2b0a Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 May 2015 18:17:57 +0200 Subject: [PATCH 19/54] CMake: the install rule does not depend on all * "make install" does not imply "make all install". * Update Travis to build all the project, and install. * CMake install with 'Optional': Specify that it is not an error if the file to be installed does not exist. --- .travis.yml | 3 ++- CMakeLists.txt | 3 +++ src/CMakeLists.txt | 11 ++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ce8383e..eb5b6eb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,8 @@ script: - mkdir -p ${AVTRANSCODER_BUILD} - cd ${AVTRANSCODER_BUILD} - cmake .. -DCMAKE_INSTALL_PREFIX=${AVTRANSCODER_INSTALL} -DCMAKE_PREFIX_PATH=${DEPENDENCY_INSTALL} -DCMAKE_BUILD_TYPE=Release -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7 -DAVTRANSCODER_COVERAGE=True - - make -j${CI_NODE_TOTAL} install + - make -j${CI_NODE_TOTAL} + - make install # launch tests - if [ ${DEPENDENCY_MODE} = "ffmpeg" ]; then ./../tools/travis.python.nosetests.sh; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index aecf6b5c..21ed897e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,9 @@ add_definitions(-DAVTRANSCODER_DEFAULT_AVPROFILES="${CMAKE_INSTALL_PREFIX}/share # Diplay commands being ran by CMake set(CMAKE_VERBOSE_MAKEFILE OFF) +# The install rule does not depend on all, i.e. everything will not be built before installing +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE) + # CPP flags on debug / release mode if(MSVC) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d0af291e..1bfb01f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,8 +49,8 @@ install( PATTERN "*.hpp" PATTERN "*.i" ) -install(TARGETS avtranscoder-static DESTINATION lib/) -install(TARGETS avtranscoder-shared DESTINATION lib/) +install(TARGETS avtranscoder-static DESTINATION lib/ OPTIONAL) +install(TARGETS avtranscoder-shared DESTINATION lib/ OPTIONAL) ### Install AvTranscoder ressource install( @@ -110,9 +110,10 @@ if(SWIG_FOUND) install( FILES ${AVTRANSCODER_PYTHON_BINDING_FILE} ${AVTRANSCODER_PYTHON_INIT_FILE} DESTINATION ${AVTRANSCODER_PYTHON_MODULE_OUTPUT_DIR} + OPTIONAL ) # Install python lib and __init__.py files - install(TARGETS ${SWIG_MODULE_avtranscoder-py_REAL_NAME} DESTINATION "lib/python${PYTHONLIBS_VERSION_STRING}/site-packages/pyAvTranscoder/") + install(TARGETS ${SWIG_MODULE_avtranscoder-py_REAL_NAME} DESTINATION "lib/python${PYTHONLIBS_VERSION_STRING}/site-packages/pyAvTranscoder/" OPTIONAL) install(CODE "file(WRITE ${CMAKE_INSTALL_PREFIX}/${AVTRANSCODER_PYTHON_MODULE_OUTPUT_DIR}/__init__.py)") else() message("PYTHON not found, will not build python binding.") @@ -166,8 +167,8 @@ if(SWIG_FOUND) ) # Install java lib and jar files - install(TARGETS ${SWIG_MODULE_avtranscoder-java_REAL_NAME} DESTINATION "lib/java") - install(FILES ${AVTRANSCODER_JAR_PATH}/${AVTRANSCODER_JAR_NAME} DESTINATION "share/java/") + install(TARGETS ${SWIG_MODULE_avtranscoder-java_REAL_NAME} DESTINATION "lib/java" OPTIONAL) + install(FILES ${AVTRANSCODER_JAR_PATH}/${AVTRANSCODER_JAR_NAME} DESTINATION "share/java/" OPTIONAL) else() message("JAVA not found, will not build java binding.") endif() From 81e811fd252f69e8351fe95e5bae7c8ed3fa3664 Mon Sep 17 00:00:00 2001 From: Valentin NOEL Date: Tue, 12 May 2015 18:40:02 +0200 Subject: [PATCH 20/54] hotfix: store first AVCodecContext::timecode_frame_start * fixing VideoProperties::getStartTimecode method return value --- src/AvTranscoder/mediaProperty/VideoProperties.cpp | 6 +++++- src/AvTranscoder/mediaProperty/VideoProperties.hpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AvTranscoder/mediaProperty/VideoProperties.cpp b/src/AvTranscoder/mediaProperty/VideoProperties.cpp index bebf2904..4268b758 100644 --- a/src/AvTranscoder/mediaProperty/VideoProperties.cpp +++ b/src/AvTranscoder/mediaProperty/VideoProperties.cpp @@ -22,6 +22,7 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size , _pixelProperties() , _isInterlaced( false ) , _isTopFieldFirst( false ) + , _firstGopTimeCode( -1 ) , _gopStructure() { if( _formatContext ) @@ -39,7 +40,10 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size _codec = avcodec_find_decoder( _codecContext->codec_id ); if( _codecContext ) + { _pixelProperties = PixelProperties( _codecContext->pix_fmt ); + _firstGopTimeCode = _codecContext->timecode_frame_start; + } if( level == eAnalyseLevelFirstGop ) analyseGopStructure( progress ); @@ -310,7 +314,7 @@ int64_t VideoProperties::getStartTimecode() const { if( ! _codecContext ) throw std::runtime_error( "unknown codec context" ); - return _codecContext->timecode_frame_start; + return _firstGopTimeCode; } std::string VideoProperties::getStartTimecodeString() const diff --git a/src/AvTranscoder/mediaProperty/VideoProperties.hpp b/src/AvTranscoder/mediaProperty/VideoProperties.hpp index 8c3eba0b..c74e4f98 100644 --- a/src/AvTranscoder/mediaProperty/VideoProperties.hpp +++ b/src/AvTranscoder/mediaProperty/VideoProperties.hpp @@ -110,6 +110,12 @@ class AvExport VideoProperties : public StreamProperties bool _isTopFieldFirst; std::vector< std::pair< char, bool > > _gopStructure; //@} + + /** + * @brief GOP timecode of the first frame + * @note AVCodecContext stores the GOP timecode of the last decoded frame + */ + int64_t _firstGopTimeCode; }; } From b92c2b00471975eb4e43e863db521b184a1e1173 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 28 May 2015 12:10:27 +0200 Subject: [PATCH 21/54] Transcoder: log number of frame processed in debug Fix #190 --- src/AvTranscoder/transcoder/Transcoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index bcc3d906..fdb707cd 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -258,7 +258,7 @@ void Transcoder::process( IProgress& progress ) if( progressDuration >= outputDuration ) break; - LOG_INFO( "Process frame " << frame ) + LOG_DEBUG( "Process frame " << frame ) frameProcessed = processFrame(); ++frame; From 16b33771be1ec0886e6e773b1df7acadf16943f2 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 3 Jun 2015 17:24:09 +0200 Subject: [PATCH 22/54] Add USAGE.md * Fix #194 --- README.md | 30 +-------------------------- USAGE.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 USAGE.md diff --git a/README.md b/README.md index aa6bc5cd..58703ec1 100644 --- a/README.md +++ b/README.md @@ -21,35 +21,7 @@ See [**COPYING.md**](COPYING.md) See [**INSTALL.md**](INSTALL.md) #### 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 -``` - -The minimum audio profile is: -``` -avProfileName=profileName -avProfileLongName=profileLongName -avProfileType=avProfileTypeAudio -codec=codecName -``` +See [**USAGE.md**](USAGE.md) #### Tests diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 00000000..050c5a5c --- /dev/null +++ b/USAGE.md @@ -0,0 +1,62 @@ +# How to use avTranscoder + +Check out applications contained in the project to see examples of how to use the library in C++, Java or Python. + +#### In C++ +Set environment: +``` +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib:/path/to/avtranscoder/lib +export PATH=$PATH:/path/to/avtranscoder/bin +``` + +#### In Java +Add argument to the JVM: +``` +-Djava.library.path=/path/to/avtranscoder/lib/java +``` +Set environment: +``` +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib +``` + +#### In Python +Set environment: +``` +export PYTHONPATH=$PYTHONPATH:/path/to/avtranscoder/lib/python/site-packages/ +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib +``` + +#### Use profiles +To wrap/unwrap/encode/decode, avTranscoder manipulates profiles. +A profile is a set of key-value given as parameters to the InputFile(unwrap), the OutputFile(wrap), the Video/AudioDecoder(decode) or the Video/AudioEncoder(encode). +There are two ways to manipulate profiles: +* create profiles inside your code, by instanciate ```Map``` structures. +* create profiles outside your code, by create text files. +To indicate the path to the text files, export environment variable: +``` +export AVPROFILES=/path/to/profiles +``` + +The minimum format profile (wrap/unwrap) is: +``` +avProfileName=profileName +avProfileLongName=profileLongName +avProfileType=avProfileTypeFormat +format=formatName +``` + +The minimum video profile (encode/decode) is: +``` +avProfileName=profileName +avProfileLongName=profileLongName +avProfileType=avProfileTypeVideo +codec=codecName +``` + +The minimum audio profile (encode/decode) is: +``` +avProfileName=profileName +avProfileLongName=profileLongName +avProfileType=avProfileTypeAudio +codec=codecName +``` From 0b7fbdc12b6bfa764c883317d79e4f0605d7cf4d Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 3 Jun 2015 18:50:42 +0200 Subject: [PATCH 23/54] InputFile/OutputFile: can get format name/long name/mime type * Fix #193 --- src/AvTranscoder/file/InputFile.cpp | 22 ++++++++++++++++++++++ src/AvTranscoder/file/InputFile.hpp | 4 ++++ src/AvTranscoder/file/OutputFile.cpp | 21 +++++++++++++++++++++ src/AvTranscoder/file/OutputFile.hpp | 5 +++++ 4 files changed, 52 insertions(+) diff --git a/src/AvTranscoder/file/InputFile.cpp b/src/AvTranscoder/file/InputFile.cpp index ace44270..b7ce08b4 100644 --- a/src/AvTranscoder/file/InputFile.cpp +++ b/src/AvTranscoder/file/InputFile.cpp @@ -116,6 +116,28 @@ InputStream& InputFile::getStream( size_t index ) } } + +std::string InputFile::getFormatName() const +{ + if( _formatContext.getAVInputFormat().name == NULL ) + return "unknown"; + return std::string(_formatContext.getAVInputFormat().name); +} + +std::string InputFile::getFormatLongName() const +{ + if( _formatContext.getAVInputFormat().long_name == NULL ) + return "unknown"; + return std::string(_formatContext.getAVInputFormat().long_name); +} + +std::string InputFile::getFormatMimeType() const +{ + if( _formatContext.getAVInputFormat().mime_type == NULL ) + return "unknown"; + return std::string(_formatContext.getAVInputFormat().mime_type); +} + double InputFile::getFps() { double fps = 1; diff --git a/src/AvTranscoder/file/InputFile.hpp b/src/AvTranscoder/file/InputFile.hpp index 46cda564..a84e8ee7 100644 --- a/src/AvTranscoder/file/InputFile.hpp +++ b/src/AvTranscoder/file/InputFile.hpp @@ -80,6 +80,10 @@ class AvExport InputFile **/ InputStream& getStream( size_t index ); + std::string getFormatName() const; + std::string getFormatLongName() const; + std::string getFormatMimeType() const; + FormatContext& getFormatContext() { return _formatContext; } /** diff --git a/src/AvTranscoder/file/OutputFile.cpp b/src/AvTranscoder/file/OutputFile.cpp index e4185e62..bd0214ea 100644 --- a/src/AvTranscoder/file/OutputFile.cpp +++ b/src/AvTranscoder/file/OutputFile.cpp @@ -85,6 +85,27 @@ IOutputStream& OutputFile::getStream( const size_t streamId ) return *_outputStreams.at( streamId ); } +std::string OutputFile::getFormatName() const +{ + if( _formatContext.getAVOutputFormat().name == NULL ) + return "unknown"; + return std::string(_formatContext.getAVOutputFormat().name); +} + +std::string OutputFile::getFormatLongName() const +{ + if( _formatContext.getAVOutputFormat().long_name == NULL ) + return "unknown"; + return std::string(_formatContext.getAVOutputFormat().long_name); +} + +std::string OutputFile::getFormatMimeType() const +{ + if( _formatContext.getAVOutputFormat().mime_type == NULL ) + return "unknown"; + return std::string(_formatContext.getAVOutputFormat().mime_type); +} + bool OutputFile::beginWrap( ) { LOG_DEBUG( "Begin wrap of OutputFile" ) diff --git a/src/AvTranscoder/file/OutputFile.hpp b/src/AvTranscoder/file/OutputFile.hpp index 8acb3f35..51d77268 100644 --- a/src/AvTranscoder/file/OutputFile.hpp +++ b/src/AvTranscoder/file/OutputFile.hpp @@ -53,6 +53,11 @@ class AvExport OutputFile : public IOutputFile void addMetadata( const std::string& key, const std::string& value ); IOutputStream& getStream( const size_t streamId ); + + std::string getFormatName() const; + std::string getFormatLongName() const; + std::string getFormatMimeType() const; + FormatContext& getFormatContext() { return _formatContext; } /** From 166d24b1a101d873c00bdbb6351216b9ff1e843a Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 4 Jun 2015 12:17:16 +0200 Subject: [PATCH 24/54] pythumbnail app: use optparse if argparse module cannot be imported * Can run pythumbnail with python2.6! * Add the shebang line. * Fix #196 --- app/pyThumbnail/pythumbnail.py | 67 +++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/app/pyThumbnail/pythumbnail.py b/app/pyThumbnail/pythumbnail.py index afd9148d..fbc70faa 100644 --- a/app/pyThumbnail/pythumbnail.py +++ b/app/pyThumbnail/pythumbnail.py @@ -1,23 +1,56 @@ -import argparse # python2.7+ +#!/usr/bin/env python from pyAvTranscoder import avtranscoder as av -# Create command-line interface -parser = argparse.ArgumentParser( - prog='pythumbnail', - description='''Generate jpeg thumbnail from video/image.''', -) - -# requirements -parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.') -# options -parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!") -parser.add_argument("-t", "--time", dest="time", type=float, default=0, help="Set time (in seconds) of where to seek in the video stream to generate the thumbnail (0 by default).") -parser.add_argument("-f", "--frame", dest="frame", type=int, default=0, help="Set time (in frames) of where to seek in the video stream to generate the thumbnail (0 by default). Warning: priority to frame if user indicates both frame and time!") -parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).") -parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).") -# Parse command-line -args = parser.parse_args() + +# Get command line arguments +args = [] +try: + # python2.7+ + import argparse + + # Create command-line interface + parser = argparse.ArgumentParser( + prog='pythumbnail', + description='''Generate jpeg thumbnail from video/image.''', + ) + + # requirements + parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.') + # options + parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!") + parser.add_argument("-t", "--time", dest="time", type=float, default=0, help="Set time (in seconds) of where to seek in the video stream to generate the thumbnail (0 by default).") + parser.add_argument("-f", "--frame", dest="frame", type=int, default=0, help="Set time (in frames) of where to seek in the video stream to generate the thumbnail (0 by default). Warning: priority to frame if user indicates both frame and time!") + parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).") + parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).") + # Parse command-line + args = parser.parse_args() + +except ImportError: + import optparse + + # Create command-line interface + parser = optparse.OptionParser( + usage='usage: %prog -i -t|-f