Skip to content

Commit

Permalink
Merge pull request #582 from cchampet/fix_audioVideoSetColorRangePara…
Browse files Browse the repository at this point in the history
…meter

AudioVideo: up to v4.9
  • Loading branch information
cchampet authored Aug 30, 2016
2 parents 9761bda + 4eec6d2 commit ffe3c17
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 51 deletions.
2 changes: 1 addition & 1 deletion plugins/image/io/AudioVideo/avTranscoder
Submodule avTranscoder updated 91 files
+4 −0 .gitignore
+1 −0 .travis.yml
+28 −9 INSTALL.md
+6 −23 README.md
+154 −22 USAGE.md
+9 −41 app/avProcessor/avProcessor.cpp
+3 −2 app/pyProcessor/pyprocessor.py
+2 −1 app/pyRewrap/pyrewrap.py
+1 −1 app/pyThumbnail/pythumbnail.py
+14 −0 cmake/AvTranscoderConfig.cmake.in
+17 −0 cmake/FindAvTranscoder.cmake
+1 −1 src/AvTranscoder/Library.hpp
+28 −17 src/AvTranscoder/Option.cpp
+5 −5 src/AvTranscoder/Option.hpp
+4 −10 src/AvTranscoder/avTranscoder.i
+1 −1 src/AvTranscoder/common.hpp
+7 −0 src/AvTranscoder/data/decoded/AudioFrame.cpp
+1 −0 src/AvTranscoder/data/decoded/AudioFrame.hpp
+14 −0 src/AvTranscoder/data/decoded/Frame.cpp
+12 −4 src/AvTranscoder/data/decoded/Frame.hpp
+53 −29 src/AvTranscoder/decoder/AudioDecoder.cpp
+1 −1 src/AvTranscoder/decoder/AudioDecoder.hpp
+7 −17 src/AvTranscoder/decoder/AudioGenerator.cpp
+11 −4 src/AvTranscoder/decoder/AudioGenerator.hpp
+2 −2 src/AvTranscoder/decoder/IDecoder.hpp
+4 −3 src/AvTranscoder/decoder/VideoDecoder.cpp
+1 −1 src/AvTranscoder/decoder/VideoDecoder.hpp
+16 −26 src/AvTranscoder/decoder/VideoGenerator.cpp
+11 −5 src/AvTranscoder/decoder/VideoGenerator.hpp
+0 −1 src/AvTranscoder/encoder/AudioEncoder.cpp
+0 −1 src/AvTranscoder/encoder/VideoEncoder.cpp
+8 −8 src/AvTranscoder/file/FormatContext.cpp
+2 −0 src/AvTranscoder/file/FormatContext.hpp
+3 −9 src/AvTranscoder/file/InputFile.cpp
+0 −10 src/AvTranscoder/file/InputFile.hpp
+33 −7 src/AvTranscoder/file/OutputFile.cpp
+7 −0 src/AvTranscoder/file/OutputFile.hpp
+68 −53 src/AvTranscoder/filter/FilterGraph.cpp
+16 −8 src/AvTranscoder/filter/FilterGraph.hpp
+7 −0 src/AvTranscoder/log.i
+6 −6 src/AvTranscoder/profile/ProfileLoader.cpp
+6 −6 src/AvTranscoder/profile/ProfileLoader.hpp
+2 −2 src/AvTranscoder/properties/AttachementProperties.hpp
+20 −18 src/AvTranscoder/properties/AudioProperties.cpp
+6 −6 src/AvTranscoder/properties/AudioProperties.hpp
+2 −2 src/AvTranscoder/properties/DataProperties.hpp
+40 −19 src/AvTranscoder/properties/FileProperties.cpp
+8 −5 src/AvTranscoder/properties/FileProperties.hpp
+2 −2 src/AvTranscoder/properties/PixelProperties.cpp
+31 −3 src/AvTranscoder/properties/StreamProperties.cpp
+20 −2 src/AvTranscoder/properties/StreamProperties.hpp
+2 −2 src/AvTranscoder/properties/SubtitleProperties.hpp
+2 −2 src/AvTranscoder/properties/UnknownProperties.hpp
+167 −84 src/AvTranscoder/properties/VideoProperties.cpp
+37 −9 src/AvTranscoder/properties/VideoProperties.hpp
+2 −2 src/AvTranscoder/properties/properties.i
+6 −6 src/AvTranscoder/reader/AudioReader.cpp
+5 −1 src/AvTranscoder/reader/IReader.cpp
+3 −3 src/AvTranscoder/reader/IReader.hpp
+6 −6 src/AvTranscoder/reader/VideoReader.cpp
+23 −0 src/AvTranscoder/transcoder/InputStreamDesc.cpp
+64 −0 src/AvTranscoder/transcoder/InputStreamDesc.hpp
+220 −146 src/AvTranscoder/transcoder/StreamTranscoder.cpp
+29 −20 src/AvTranscoder/transcoder/StreamTranscoder.hpp
+150 −235 src/AvTranscoder/transcoder/Transcoder.cpp
+43 −80 src/AvTranscoder/transcoder/Transcoder.hpp
+3 −0 src/AvTranscoder/transcoder/transcoder.i
+6 −4 src/AvTranscoder/transform/AudioTransform.cpp
+11 −0 src/CMakeLists.txt
+10 −10 test/pyTest/testEProcessMethod.py
+2 −2 test/pyTest/testFilter.py
+58 −6 test/pyTest/testInputFile.py
+33 −0 test/pyTest/testLog.py
+2 −2 test/pyTest/testNbFrames.py
+2 −2 test/pyTest/testNbSamples.py
+14 −12 test/pyTest/testOffset.py
+97 −0 test/pyTest/testOption.py
+28 −0 test/pyTest/testOutputFile.py
+1 −1 test/pyTest/testProcessStat.py
+46 −9 test/pyTest/testProperties.py
+13 −16 test/pyTest/testSetFrame.py
+67 −30 test/pyTest/testTranscoderAdd.py
+0 −111 test/pyTest/testTranscoderDummy.py
+97 −0 test/pyTest/testTranscoderGenerateStream.py
+44 −12 test/pyTest/testTranscoderRewrap.py
+36 −4 test/pyTest/testTranscoderTranscodeAudioMov.py
+5 −5 test/pyTest/testTranscoderTranscodeAudioWave.py
+2 −2 test/pyTest/testTranscoderTranscodeImage.py
+16 −7 test/pyTest/testTranscoderTranscodeVideo.py
+40 −24 tools/travis/linux.install.deps.sh
+1 −0 tools/travis/python.nosetests.sh
27 changes: 26 additions & 1 deletion plugins/image/io/AudioVideo/src/common/LibAVParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,36 @@ void addOptionsToGroup(OFX::ImageEffectDescriptor& desc, OFX::GroupParamDescript
}

OFX::ChoiceParamDescriptor* choiceParam = desc.defineChoiceParam(name);
choiceParam->setDefault(option.getDefaultInt());

// Translate the libav option default value to a value compliant with OpenFX
int ofxDefaultValue = 0;
const int libavDefaultValue = option.getDefaultInt();
if(libavDefaultValue >= 0 && libavDefaultValue < option.getChilds().size())
ofxDefaultValue = libavDefaultValue;
else if(option.getMin() > std::numeric_limits<int>::min())
{
const int computedDefaultValue = libavDefaultValue - option.getMin();
if(computedDefaultValue < option.getChilds().size())
ofxDefaultValue = computedDefaultValue;
}
choiceParam->setDefault(ofxDefaultValue);

// Added child options
BOOST_FOREACH(const avtranscoder::Option& child, option.getChilds())
{
choiceParam->appendOption(child.getName() + " " + child.getHelp());
}

// Fixed warning message in some host (ie. Nuke), about OFX Choice parameters without child options
if(option.getChilds().empty())
{
choiceParam->appendOption("unknown");
}

// Hide the OFX Choice parameter if it has only one option (not useful in the interface)
if(choiceParam->getNOptions() < 2)
choiceParam->setIsSecret(true);

param = choiceParam;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/image/io/AudioVideo/src/mainEntry.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFXPLUGIN_VERSION_MAJOR 4
#define OFXPLUGIN_VERSION_MINOR 8
#define OFXPLUGIN_VERSION_MINOR 9

#include <tuttle/plugin/Plugin.hpp>
#include "reader/AVReaderPluginFactory.hpp"
Expand Down
80 changes: 34 additions & 46 deletions plugins/image/io/AudioVideo/src/writer/AVWriterPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "AVWriterProcess.hpp"
#include "AVWriterDefinitions.hpp"

#include <AvTranscoder/transcoder/InputStreamDesc.hpp>
#include <AvTranscoder/codec/AudioCodec.hpp>
#include <AvTranscoder/progress/NoDisplayProgress.hpp>

#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -286,10 +286,8 @@ void AVWriterPlugin::updateAudioSelectStream(size_t indexAudioOutput)
const std::string inputFilePath = _paramAudioFilePath.at(indexAudioOutput)->getValue();
if(boost::filesystem::exists(inputFilePath))
{
avtranscoder::NoDisplayProgress progress;
const avtranscoder::FileProperties fileProperties =
avtranscoder::InputFile::analyseFile(inputFilePath, progress, avtranscoder::eAnalyseLevelHeader);
const size_t nbAudioStream = fileProperties.getAudioProperties().size();
const avtranscoder::InputFile inputFile(inputFilePath);
const size_t nbAudioStream = inputFile.getProperties().getNbAudioStreams();
_paramAudioStreamIndex.at(indexAudioOutput)->setRange(0, nbAudioStream);
_paramAudioStreamIndex.at(indexAudioOutput)->setDisplayRange(0, nbAudioStream);
}
Expand Down Expand Up @@ -330,17 +328,15 @@ void AVWriterPlugin::updateAudioFileInfo(size_t indexAudioOutput)
std::string inputFilePath = _paramAudioFilePath.at(indexAudioOutput)->getValue();
if(boost::filesystem::exists(inputFilePath))
{
avtranscoder::NoDisplayProgress progress;
const avtranscoder::FileProperties fileProperties =
avtranscoder::InputFile::analyseFile(inputFilePath, progress, avtranscoder::eAnalyseLevelHeader);
const size_t nbAudioStream = fileProperties.getAudioProperties().size();
const avtranscoder::InputFile inputFile(inputFilePath);
const std::vector<avtranscoder::AudioProperties>& audioPropertiesArray = inputFile.getProperties().getAudioProperties();
const size_t nbAudioStream = audioPropertiesArray.size();
std::string audioInfo = "Audio streams: ";
audioInfo += boost::lexical_cast<std::string>(nbAudioStream);
audioInfo += "\n";
for(size_t audioStreamIndex = 0; audioStreamIndex < nbAudioStream; ++audioStreamIndex)
{
const avtranscoder::AudioProperties& audioProperties =
fileProperties.getAudioProperties().at(audioStreamIndex);
const avtranscoder::AudioProperties& audioProperties = audioPropertiesArray.at(audioStreamIndex);

// stream
audioInfo += "Stream ";
Expand Down Expand Up @@ -564,6 +560,14 @@ void AVWriterPlugin::initVideo(const OFX::RenderArguments& args)

try
{
// get rod
const OfxRectI bounds = _clipSrc->getPixelRod(args.time, args.renderScale);
const int width = bounds.x2 - bounds.x1;
const int height = bounds.y2 - bounds.y1;

// set description of the frame set by the plugin
_videoDesc.reset(new avtranscoder::VideoFrameDesc(width, height, "rgb24"));

// Get custom video profile
avtranscoder::ProfileLoader::Profile profile;
profile[avtranscoder::constants::avProfileIdentificator] = "customVideoPreset";
Expand All @@ -586,6 +590,11 @@ void AVWriterPlugin::initVideo(const OFX::RenderArguments& args)
profile[avtranscoder::constants::avProfileWidth] = boost::to_string(_paramCustomSize->getValue().x);
profile[avtranscoder::constants::avProfileHeight] = boost::to_string(_paramCustomSize->getValue().y);
}
else
{
profile[avtranscoder::constants::avProfileWidth] = boost::to_string(width);
profile[avtranscoder::constants::avProfileHeight] = boost::to_string(height);
}

// video options
const avtranscoder::ProfileLoader::Profile videoProfile = _paramVideoCustom.getCorrespondingProfile();
Expand All @@ -598,19 +607,8 @@ void AVWriterPlugin::initVideo(const OFX::RenderArguments& args)

cleanProfile(profile, common::kPrefixVideo);

// get rod
const OfxRectI bounds = _clipSrc->getPixelRod(args.time, args.renderScale);
const int width = bounds.x2 - bounds.x1;
const int height = bounds.y2 - bounds.y1;

// describe input frame and codec of transcode
avtranscoder::VideoCodec videoCodec(avtranscoder::eCodecTypeEncoder,
profile[avtranscoder::constants::avProfileCodec]);
_videoDesc.reset(new avtranscoder::VideoFrameDesc(width, height, "rgb24"));
videoCodec.setImageParameters(*_videoDesc);

// add video stream
_transcoder->add("", 0, profile, videoCodec);
// add video stream (the frames to encode will be set by the plugin)
_transcoder->addGenerateStream(profile);
}
catch(std::exception& e)
{
Expand Down Expand Up @@ -702,18 +700,8 @@ void AVWriterPlugin::initAudio()
{
try
{
avtranscoder::AudioCodec audioCodec(avtranscoder::eCodecTypeEncoder,
profile.at(avtranscoder::constants::avProfileCodec));
const size_t sampleRate =
boost::lexical_cast<size_t>(profile.at(avtranscoder::constants::avProfileSampleRate));
const size_t channels =
boost::lexical_cast<size_t>(profile.at(avtranscoder::constants::avProfileChannel));
avtranscoder::AudioFrameDesc audioDesc(sampleRate, channels,
profile.at(avtranscoder::constants::avProfileSampleFormat));
audioCodec.setAudioParameters(audioDesc);

// add silent stream
_transcoder->add("", 1, profile, audioCodec);
_transcoder->addGenerateStream(profile);
}
catch(std::out_of_range& e)
{
Expand All @@ -729,10 +717,8 @@ void AVWriterPlugin::initAudio()
std::vector<int> indexAudioStreams;
if(inputStreamIndex == -1)
{
avtranscoder::NoDisplayProgress progress;
const avtranscoder::FileProperties fileProperties =
avtranscoder::InputFile::analyseFile(inputFileName, progress, avtranscoder::eAnalyseLevelHeader);
const std::vector<avtranscoder::AudioProperties> audioProperties = fileProperties.getAudioProperties();
const avtranscoder::InputFile inputFile(inputFileName);
const std::vector<avtranscoder::AudioProperties> audioProperties = inputFile.getProperties().getAudioProperties();
for(size_t propertiesIndex = 0; propertiesIndex < audioProperties.size(); ++propertiesIndex)
{
indexAudioStreams.push_back(audioProperties.at(propertiesIndex).getStreamIndex());
Expand All @@ -744,14 +730,14 @@ void AVWriterPlugin::initAudio()
{
if(inputStreamIndex != -1)
{
_transcoder->add(inputFileName, inputStreamIndex, presetName);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, inputStreamIndex), presetName);
}
else
{
for(std::vector<int>::iterator itStreamIndex = indexAudioStreams.begin();
itStreamIndex != indexAudioStreams.end(); ++itStreamIndex)
{
_transcoder->add(inputFileName, *itStreamIndex, presetName);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, *itStreamIndex), presetName);
}
}
}
Expand All @@ -767,14 +753,14 @@ void AVWriterPlugin::initAudio()
{
if(inputStreamIndex != -1)
{
_transcoder->add(inputFileName, inputStreamIndex, subStream, profile, offset);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, inputStreamIndex, subStream), profile, offset);
}
else
{
for(std::vector<int>::iterator itStreamIndex = indexAudioStreams.begin();
itStreamIndex != indexAudioStreams.end(); ++itStreamIndex)
{
_transcoder->add(inputFileName, *itStreamIndex, subStream, profile, offset);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, *itStreamIndex, subStream), profile, offset);
}
}
}
Expand All @@ -783,14 +769,14 @@ void AVWriterPlugin::initAudio()
{
if(inputStreamIndex != -1)
{
_transcoder->add(inputFileName, inputStreamIndex, subStream, presetName, offset);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, inputStreamIndex, subStream), presetName, offset);
}
else
{
for(std::vector<int>::iterator itStreamIndex = indexAudioStreams.begin();
itStreamIndex != indexAudioStreams.end(); ++itStreamIndex)
{
_transcoder->add(inputFileName, *itStreamIndex, subStream, presetName, offset);
_transcoder->addStream(avtranscoder::InputStreamDesc(inputFileName, *itStreamIndex, subStream), presetName, offset);
}
}
}
Expand Down Expand Up @@ -893,7 +879,9 @@ void AVWriterPlugin::updateVideoFromExistingProfile()
option.first == avtranscoder::constants::avProfileType ||
option.first == avtranscoder::constants::avProfileCodec ||
option.first == avtranscoder::constants::avProfilePixelFormat ||
option.first == avtranscoder::constants::avProfileFrameRate)
option.first == avtranscoder::constants::avProfileFrameRate ||
option.first == avtranscoder::constants::avProfileWidth ||
option.first == avtranscoder::constants::avProfileHeight)
continue;

if(!_paramVideoCustom.setOption(option.first, option.second))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,12 @@ void AVWriterPluginFactory::describeInContext(OFX::ImageEffectDescriptor& desc,
customWidth->setParent(videoCustomGroupParam);

int default_codec = 0;
std::string defaultVideoCodec("mpeg4");
OFX::ChoiceParamDescriptor* videoCodec = desc.defineChoiceParam(kParamVideoCodec);
avtranscoder::NamesMap videoCodecsNames(avtranscoder::getAvailableVideoCodecsNames());
for(avtranscoder::NamesMap::const_iterator itName = videoCodecsNames.begin(); itName != videoCodecsNames.end(); ++itName)
{
videoCodec->appendOption(itName->first + " " + itName->second);
if(itName->first == defaultVideoCodec)
if(itName->first == "mpeg4")
default_codec = videoCodec->getNOptions() - 1;
}
videoCodec->setLabel(kParamVideoCodecLabel);
Expand Down

0 comments on commit ffe3c17

Please sign in to comment.