Skip to content

Commit 6169265

Browse files
author
Clement Champetier
committed
OutputFile: add addMetadata
Can add metadata from a map or from key / value.
1 parent da3d155 commit 6169265

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/AvTranscoder/File/OutputFile.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,24 @@ bool OutputFile::endWrap( )
204204
return true;
205205
}
206206

207+
void OutputFile::addMetadata( const MetadatasMap& dataMap )
208+
{
209+
for( MetadatasMap::const_iterator it = dataMap.begin(); it != dataMap.end(); ++it )
210+
{
211+
addMetadata( it->first, it->second );
212+
}
213+
}
214+
215+
void OutputFile::addMetadata( const std::string& key, const std::string& value )
216+
{
217+
int ret = av_dict_set( &_formatContext->metadata, key.c_str(), value.c_str(), 0 );
218+
if( ret < 0 )
219+
{
220+
char err[250];
221+
av_strerror( ret, err, 250 );
222+
std::cout << err << std::endl;
223+
}
224+
}
207225

208226
void OutputFile::setProfile( const Profile::ProfileDesc& desc )
209227
{

src/AvTranscoder/File/OutputFile.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <AvTranscoder/common.hpp>
55

6+
#include <AvTranscoder/Metadatas/MediaMetadatasStructures.hpp>
7+
68
#include <AvTranscoder/CodedStructures/DataStream.hpp>
79
#include <AvTranscoder/CodedStructures/VideoDesc.hpp>
810
#include <AvTranscoder/CodedStructures/AudioDesc.hpp>
@@ -98,6 +100,13 @@ class AvExport OutputFile
98100
* @param desc: the profile of the output format
99101
*/
100102
virtual void setProfile( const Profile::ProfileDesc& desc );
103+
104+
/**
105+
* @brief Add metadata to the output file.
106+
* @note Depending on the format, you are not sure to find your metadata after the transcode.
107+
*/
108+
virtual void addMetadata( const MetadatasMap& dataMap );
109+
virtual void addMetadata( const std::string& key, const std::string& value );
101110

102111
virtual void setVerbose( bool verbose = false ){ _verbose = verbose; }
103112

0 commit comments

Comments
 (0)