Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support external encoder#313

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MarcAntoine-Arnaud merged 10 commits intodevelopfromdev/support_external_encoder
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
38 changes: 23 additions & 15 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,23 +25,28 @@ env:
- DEPENDENCY_LOG_FILE=${TRAVIS_BUILD_DIR}/build-dependencies-log.txt

- YASM_VERSION=1.3.0
- LAME_VERSION=3.99.5
- FAAC_VERSION=1.28
- LAME_VERSION=3.100
#- FAAC_VERSION=1.28
- XVID_VERSION=1.3.3
- FDKAAC_VERSION=0.1.3
#- FDKAAC_VERSION=0.1.3
- OGG_VERSION=1.3.2
- VORBIS_VERSION=1.3.4
- THEORA_VERSION=1.1.1
- VORBIS_VERSION=1.3.6
#- THEORA_VERSION=1.1.1
- VPX_VERSION=1.4.0
matrix:
- DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=true
- DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.5.7 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.6.8 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.7.6 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.8.6 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.12 ENABLE_COVERAGE=true
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.12 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=12.3 ENABLE_COVERAGE=true
# - DEPENDENCY_NAME=libav DEPENDENCY_VERSION=12.3 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.5.7 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.6.8 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.7.6 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.8.6 ENABLE_COVERAGE=false
# - DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.0 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.1 ENABLE_COVERAGE=false
- DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=4.2 ENABLE_COVERAGE=true

matrix:
exclude:
Expand All@@ -57,6 +62,7 @@ matrix:
env: DEPENDENCY_NAME=ffmpeg DEPENDENCY_VERSION=2.4.2 ENABLE_COVERAGE=true
allow_failures:
# build with libav
- os: osx
- env: DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=true
- env: DEPENDENCY_NAME=libav DEPENDENCY_VERSION=11.3 ENABLE_COVERAGE=false
# build with ffmpeg-2.8.6
Expand All@@ -75,8 +81,10 @@ addons:
packages:
- cmake
- swig
- python-dev
- python-nose
- python3-dev
- python3
- python3-nose
- python3-coverage
- freeglut3-dev

cache:
Expand Down
9 changes: 9 additions & 0 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 2.8.11)

project(AvTranscoder)

# All libraries will be put in INSTALL_PREFIX/lib
# RPATH of host points INSTALL_PREFIX/lib
# see: http://www.cmake.org/Wiki/CMake_RPATH_handling
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


# Define AvTranscoder default path to profiles
add_definitions(-DAVTRANSCODER_DEFAULT_AVPROFILES="${CMAKE_INSTALL_PREFIX}/share/avprofiles")

Expand Down
1 change: 1 addition & 0 deletionsapp/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ add_subdirectory(avInfo)
add_subdirectory(avMeta)
add_subdirectory(avPlayer)
add_subdirectory(avProcessor)
add_subdirectory(customEncoder)

# Python apps
add_subdirectory(pyProcessor)
Expand Down
24 changes: 24 additions & 0 deletionsapp/customEncoder/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
### cpp/customEncoder

# Load custom cmake utilities
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(AvTranscoderMacros)

# Build app
add_executable(custom-encoder customEncoder.cpp)
set_target_properties(custom-encoder PROPERTIES VERSION ${AVTRANSCODER_VERSION})
target_link_libraries(custom-encoder avtranscoder-shared)

# Install app
if(WIN32)
set(BINARY_FILES "${CMAKE_CURRENT_BINARY_DIR}/custom-encoder.exe")
else()
set(BINARY_FILES "${CMAKE_CURRENT_BINARY_DIR}/custom-encoder" "${CMAKE_CURRENT_BINARY_DIR}/custom-encoder-${AVTRANSCODER_VERSION}")
endif()

install(
FILES ${BINARY_FILES}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
DESTINATION "bin/"
OPTIONAL
)
208 changes: 208 additions & 0 deletionsapp/customEncoder/customEncoder.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
#include <AvTranscoder/transcoder/Transcoder.hpp>
#include <AvTranscoder/file/OutputFile.hpp>
#include <AvTranscoder/progress/ConsoleProgress.hpp>

#include <iostream>
#include <iomanip>
#include <vector>
#include <fstream>
#include <sstream>
#include <cstdlib>

void parseConfigFile(const std::string& configFilename, avtranscoder::Transcoder& transcoder)
{
std::ifstream configFile(configFilename.c_str(), std::ifstream::in);

std::string line;
while(std::getline(configFile, line))
{
std::istringstream is_line(line);
std::string filename;
if(std::getline(is_line, filename, '='))
{
std::string streamId;
if(std::getline(is_line, streamId, ':'))
{
std::string transcodeProfile;
std::getline(is_line, transcodeProfile);

std::stringstream ss(streamId);
size_t streamIndex = 0;
char separator = 'x';
std::vector<size_t> channelIndexArray;
ss >> streamIndex;
ss >> separator;
if(separator == '.')
{
int subStreamIndex = -1;
ss >> subStreamIndex;
channelIndexArray.push_back(subStreamIndex);
}

// generated stream
if(!filename.length())
transcoder.addGenerateStream(transcodeProfile);
else
{
avtranscoder::InputStreamDesc inputDesc(filename, streamIndex, channelIndexArray);
transcoder.addStream(inputDesc, transcodeProfile);
}
}
}
}

configFile.close();
}



class AvExport CustomCodec
: public avtranscoder::ICodec
{
public:
CustomCodec()
: avtranscoder::ICodec(avtranscoder::eCodecTypeEncoder, AV_CODEC_ID_PCM_S24LE)
{
}

void openCodec(){}
void closeCodec(){}

std::string getCodecName() const { return "Custom Encoder"; };
AVCodecID getCodecId() const { return AV_CODEC_ID_PCM_S24LE; }
avtranscoder::ECodecType getCodecType() const { return avtranscoder::eCodecTypeEncoder; }
int getLatency() const { return 0; }

avtranscoder::OptionArray getOptions() {
std::vector<avtranscoder::Option> options;
return options;
}
};


class AvExport CustomEncoder
: public avtranscoder::IEncoder
{
public:
CustomEncoder()
: _codec()
{}
/**
* @brief Setup the encoder
* @param profile: set encoder parameters from the given profile
* @note Open the encoder.
*/
void setupEncoder(const avtranscoder::ProfileLoader::Profile& profile = avtranscoder::ProfileLoader::Profile()) {
return;
};

/**
* @brief Encode a new frame, and get coded frame
* @param sourceFrame: frame that needs to be encoded
* @param codedFrame: output encoded coded data (first frames can be delayed)
* @return status of encoding
* @throw runtime_error if the encoded process failed.
*/
bool encodeFrame(const avtranscoder::IFrame& sourceFrame, avtranscoder::CodedData& codedFrame) {
codedFrame.assign(5760, 0);
return true;
};

/**
* @brief Get the frames remaining into the encoder
* @param codedFrame: output encoded data
* @return status of encoding
* @throw runtime_error if the encoded process failed.
*/
bool encodeFrame(avtranscoder::CodedData& codedFrame) {
return false;
};

/**
* @brief Get codec used for encoding.
* @return a reference to the codec
*/
avtranscoder::ICodec& getCodec() {
return _codec;
};

private:
CustomCodec _codec;
};


int main(int argc, char** argv)
{
std::string help;
help += "Usage\n";
help += "\tavprocessor INPUT_FILE_NAME OUTPUT_FILE_NAME [--verbose] [--logFile] [--help]\n";
help += "Command line options\n";
help += "\t--verbose: set log level to AV_LOG_DEBUG\n";
help += "\t--logFile: put log in 'avtranscoder.log' file\n";
help += "\t--help: display this help\n";

// Preload FFmpeg context
avtranscoder::preloadCodecsAndFormats();
avtranscoder::Logger::setLogLevel(AV_LOG_QUIET);

// List command line arguments
std::vector<std::string> arguments;
for(int argument = 1; argument < argc; ++argument)
{
arguments.push_back(argv[argument]);
}
for(size_t argument = 0; argument < arguments.size(); ++argument)
{
if(arguments.at(argument) == "--help")
{
std::cout << help << std::endl;
return 0;
}
else if(arguments.at(argument) == "--verbose")
{
avtranscoder::Logger::setLogLevel(AV_LOG_DEBUG);
}
else if(arguments.at(argument) == "--logFile")
{
avtranscoder::Logger::logInFile();
}
}

// Check required arguments
if(argc < 3)
{
std::cout << "avprocessor can rewrap or transcode inputs to create an output media file." << std::endl;
std::cout << "Use option --help to display help" << std::endl;
return (-1);
}

try
{
std::string output_format = "s24le";
avtranscoder::OutputFile outputFile(argv[2], output_format);

avtranscoder::Transcoder transcoder(outputFile);
transcoder.setProcessMethod(avtranscoder::eProcessMethodBasedOnStream);

CustomEncoder* customEncoder = new CustomEncoder;
avtranscoder::InputStreamDesc inputDescLeft(argv[1], 1, 0);
avtranscoder::InputStreamDesc inputDescRight(argv[1], 2, 0);

std::vector<avtranscoder::InputStreamDesc> inputDescriptors;
inputDescriptors.push_back(avtranscoder::InputStreamDesc(argv[1], 1, 0));
inputDescriptors.push_back(avtranscoder::InputStreamDesc(argv[1], 2, 0));

transcoder.addStream(inputDescriptors, customEncoder);

avtranscoder::ConsoleProgress progress;
transcoder.process(progress);
}
catch(std::exception& e)
{
std::cerr << "ERROR: during process, an error occured: " << e.what() << std::endl;
}
catch(...)
{
std::cerr << "ERROR: during process, an unknown error occured" << std::endl;
}
}
8 changes: 4 additions & 4 deletionsappveyor.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ platform:
environment:
global:
DEPENDENCY_NAME: ffmpeg
DEPENDENCY_VERSION:2.4.5
DEPENDENCY_VERSION:4.2.1
DEPENDENCY_INSTALL_PATH: C:\ProgramData\install-dependency
AVTRANSCODER_INSTALL_PATH: C:\projects\avtranscoder\build\install-avtranscoder

Expand All@@ -25,10 +25,10 @@ install:

# Get the correct python version
- ps: if($env:platform -eq 'x86') {
$env:PYTHON = "C:\Python27";
$env:PYTHON = "C:\Python35";
}
else {
$env:PYTHON = "C:\Python27-x64";
$env:PYTHON = "C:\Python35-x64";
}
# Prepend newly installed Python to the PATH of this build
- cmd: set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
Expand All@@ -37,7 +37,7 @@ install:
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
# Upgrade to the latest version of pip to avoid it displaying warnings about it being out of date.
- pip install --disable-pip-version-check --user --upgrade pip
-"python -mpip install --disable-pip-version-check --user --upgrade pip"

# Install tests dependencies
- pip install nose
Expand Down
4 changes: 4 additions & 0 deletionssrc/AvTranscoder/encoder/VideoEncoder.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,11 @@ void VideoEncoder::setupEncoder(const ProfileLoader::Profile& profile)
if(profile.count(constants::avProfileProcessStat))
{
LOG_INFO("SetUp video encoder to compute statistics during process")
#ifdef AV_CODEC_FLAG_PSNR
encoderFlags |= AV_CODEC_FLAG_PSNR;
#else
encoderFlags |= CODEC_FLAG_PSNR;
#endif
}
_codec.getAVCodecContext().flags |= encoderFlags;
_codec.openCodec();
Expand Down
9 changes: 9 additions & 0 deletionssrc/AvTranscoder/file/IOutputFile.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,6 +51,15 @@ class AvExport IOutputFile
throw std::logic_error("function is not implemented");
}

/**
* @brief Add a custom output stream
* @param iCodecDesc description of output codec
**/
virtual IOutputStream& addCustomStream(const ICodec& iCodecDesc)
{
throw std::logic_error("function is not implemented");
}

/**
* @brief Write the header of file (if necessary)
**/
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp