Skip to content

The format specific options are passed as arguments to the file header writing function #300

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

Merged
merged 2 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 15 additions & 10 deletions src/AvTranscoder/file/OutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OutputFile::OutputFile(const std::string& filename, const std::string& formatNam
, _outputStreams()
, _frameCount()
, _previousProcessedStreamDuration(0.0)
, _profile()
, _profileOptions(NULL)
{
_formatContext.setFilename(filename);
_formatContext.setOutputFormat(filename, formatName, mimeType);
Expand All @@ -28,6 +28,7 @@ OutputFile::~OutputFile()
{
delete(*it);
}
av_dict_free(&_profileOptions);
}

IOutputStream& OutputFile::addVideoStream(const VideoCodec& videoDesc)
Expand Down Expand Up @@ -154,7 +155,7 @@ bool OutputFile::beginWrap()
LOG_DEBUG("Begin wrap of OutputFile")

_formatContext.openRessource(getFilename(), AVIO_FLAG_WRITE);
_formatContext.writeHeader();
_formatContext.writeHeader(&_profileOptions);

// set specific wrapping options
setupRemainingWrappingOptions();
Expand Down Expand Up @@ -296,28 +297,32 @@ void OutputFile::setupWrappingOptions(const ProfileLoader::Profile& profile)
catch(std::exception& e)
{
LOG_INFO("OutputFile - option " << (*it).first << " will be saved to be called when beginWrap")
_profile[(*it).first] = (*it).second;
av_dict_set(&_profileOptions, (*it).first.c_str(), (*it).second.c_str(), 0);
}
}
}

void OutputFile::setupRemainingWrappingOptions()
{
// set format options
for(ProfileLoader::Profile::const_iterator it = _profile.begin(); it != _profile.end(); ++it)
// set specific format options
AVDictionaryEntry* optionEntry = NULL;
while((optionEntry = av_dict_get(_profileOptions, "", optionEntry, AV_DICT_IGNORE_SUFFIX)))
{
if((*it).first == constants::avProfileIdentificator || (*it).first == constants::avProfileIdentificatorHuman ||
(*it).first == constants::avProfileType || (*it).first == constants::avProfileFormat)
const std::string optionKey(optionEntry->key);
const std::string optionValue(optionEntry->value);

if(optionKey == constants::avProfileIdentificator || optionKey == constants::avProfileIdentificatorHuman ||
optionKey == constants::avProfileType || optionKey == constants::avProfileFormat)
continue;

try
{
Option& formatOption = _formatContext.getOption((*it).first);
formatOption.setString((*it).second);
Option& formatOption = _formatContext.getOption(optionKey);
formatOption.setString(optionValue);
}
catch(std::exception& e)
{
LOG_WARN("OutputFile - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what())
LOG_WARN("OutputFile - can't set option " << optionKey << " to " << optionValue << ": " << e.what())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AvTranscoder/file/OutputFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class AvExport OutputFile : public IOutputFile
* @see setupWrapping
* @see beginWrap
*/
ProfileLoader::Profile _profile;
AVDictionary* _profileOptions;
};
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy