Skip to content
Snippets Groups Projects
Commit b4c6a219 authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin
Browse files

encoder: add file metadata


Allows title and description to be specified when muxing to a file.

Change-Id: Ie48c185a0177e09872867520ab1aabfddeacbb8a
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent d1546c4e
No related branches found
No related tags found
No related merge requests found
...@@ -160,6 +160,12 @@ MediaEncoder::openFileOutput(const std::string& filename, std::map<std::string, ...@@ -160,6 +160,12 @@ MediaEncoder::openFileOutput(const std::string& filename, std::map<std::string,
{ {
avformat_free_context(outputCtx_); avformat_free_context(outputCtx_);
avformat_alloc_output_context2(&outputCtx_, nullptr, nullptr, filename.c_str()); avformat_alloc_output_context2(&outputCtx_, nullptr, nullptr, filename.c_str());
if (!options["title"].empty())
av_dict_set(&outputCtx_->metadata, "title", options["title"].c_str(), 0);
if (!options["description"].empty())
av_dict_set(&outputCtx_->metadata, "description", options["description"].c_str(), 0);
auto bitrate = SystemCodecInfo::DEFAULT_MAX_BITRATE; auto bitrate = SystemCodecInfo::DEFAULT_MAX_BITRATE;
auto quality = SystemCodecInfo::DEFAULT_CODEC_QUALITY; auto quality = SystemCodecInfo::DEFAULT_CODEC_QUALITY;
// ensure all options retrieved later on are in options_ (insert does nothing if key exists) // ensure all options retrieved later on are in options_ (insert does nothing if key exists)
......
...@@ -150,6 +150,8 @@ MediaEncoderTest::testMultiStream() ...@@ -150,6 +150,8 @@ MediaEncoderTest::testMultiStream()
const constexpr int width = 320; const constexpr int width = 320;
const constexpr int height = 240; const constexpr int height = 240;
std::map<std::string, std::string> options; std::map<std::string, std::string> options;
options["title"] = "Encoder Unit Test";
options["description"] = "Description goes here";
options["sample_rate"] = std::to_string(sampleRate); options["sample_rate"] = std::to_string(sampleRate);
options["channels"] = std::to_string(nbChannels); options["channels"] = std::to_string(nbChannels);
options["width"] = std::to_string(width); options["width"] = std::to_string(width);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment