Skip to content

Commit

Permalink
Add recorder media format settings to mediaframeinputs command line
Browse files Browse the repository at this point in the history
Pick-to: 6.8
Change-Id: I65d70222d617af89dc3a094feb4813eda120f3ff
Reviewed-by: Jøger Hansegård <[email protected]>
Reviewed-by: Lars Sutterud <[email protected]>
Reviewed-by: Nils Petter Skålerud <[email protected]>
  • Loading branch information
Artemiy-d committed Oct 10, 2024
1 parent f95ab0a commit b6fe8bf
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/manual/mediaframeinputs/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ CommandLineParser::Result CommandLineParser::process()
m_recorderSettings.quality =
parsedValue(m_options.recorderQuality, noCheck, toEnum, m_recorderQualities);

m_recorderSettings.audioCodec =
parsedValue(m_options.recorderAudioCodec, noCheck, toEnum, m_audioCodecs);

m_recorderSettings.videoCodec =
parsedValue(m_options.recorderVideoCodec, noCheck, toEnum, m_videoCodecs);

m_recorderSettings.fileFormat =
parsedValue(m_options.recorderFileFormat, noCheck, toEnum, m_fileFormats);

return takeResult();
}

Expand Down Expand Up @@ -352,6 +361,18 @@ CommandLineParser::Options CommandLineParser::createOptions()
addOption({ QStringLiteral("recorder.resolution"),
QStringLiteral("Video resolution for media recorder.\nNo default value."),
QStringLiteral("WxH") });
result.recorderAudioCodec =
addOption({ { QStringLiteral("recorder.audioCodec"), QStringLiteral("audioCodec") },
QStringLiteral("Audio codec for media recorder. \nNo default value."),
QStringLiteral("enum") });
result.recorderVideoCodec =
addOption({ { QStringLiteral("recorder.videoCodec"), QStringLiteral("videoCodec") },
QStringLiteral("Video codec for media recorder.\nNo default value."),
QStringLiteral("enum") });
result.recorderFileFormat =
addOption({ { QStringLiteral("recorder.fileFormat"), QStringLiteral("fileFormat") },
QStringLiteral("File format for media recorder.\nNo default value."),
QStringLiteral("enum") });

return result;
}
46 changes: 46 additions & 0 deletions tests/manual/mediaframeinputs/commandlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class CommandLineParser
QString recorderFrameRate;
QString recorderQuality;
QString recorderResolution;
QString recorderAudioCodec;
QString recorderVideoCodec;
QString recorderFileFormat;
};

Options createOptions();
Expand Down Expand Up @@ -99,6 +102,49 @@ class CommandLineParser
{ QMediaRecorder::VeryHighQuality, u"veryHigh" },
};

const EnumMap<QMediaFormat::AudioCodec> m_audioCodecs = {
{ QMediaFormat::AudioCodec::MP3, u"mp3" },
{ QMediaFormat::AudioCodec::AAC, u"aac" },
{ QMediaFormat::AudioCodec::AC3, u"ac3" },
{ QMediaFormat::AudioCodec::EAC3, u"eac3" },
{ QMediaFormat::AudioCodec::FLAC, u"flac" },
{ QMediaFormat::AudioCodec::DolbyTrueHD, u"dolbyTrueHD" },
{ QMediaFormat::AudioCodec::Opus, u"opus" },
{ QMediaFormat::AudioCodec::Vorbis, u"vorbis" },
{ QMediaFormat::AudioCodec::Wave, u"wave" },
{ QMediaFormat::AudioCodec::WMA, u"wma" },
{ QMediaFormat::AudioCodec::ALAC, u"alac" },
};

const EnumMap<QMediaFormat::VideoCodec> m_videoCodecs = {
{ QMediaFormat::VideoCodec::MPEG1, u"mpeg1" },
{ QMediaFormat::VideoCodec::MPEG2, u"mpeg2" },
{ QMediaFormat::VideoCodec::MPEG4, u"mpeg4" },
{ QMediaFormat::VideoCodec::H264, u"h264" },
{ QMediaFormat::VideoCodec::H265, u"h265" },
{ QMediaFormat::VideoCodec::VP8, u"vp8" },
{ QMediaFormat::VideoCodec::VP9, u"vp9" },
{ QMediaFormat::VideoCodec::AV1, u"av1" },
{ QMediaFormat::VideoCodec::Theora, u"theora" },
{ QMediaFormat::VideoCodec::WMV, u"wmv" },
{ QMediaFormat::VideoCodec::MotionJPEG, u"motionJPEG" },
};

const EnumMap<QMediaFormat::FileFormat> m_fileFormats = {
{ QMediaFormat::FileFormat::WMV, u"wmv" },
{ QMediaFormat::FileFormat::AVI, u"avi" },
{ QMediaFormat::FileFormat::Matroska, u"matroska" },
{ QMediaFormat::FileFormat::MPEG4, u"mpeg4" },
{ QMediaFormat::FileFormat::Ogg, u"ogg" },
{ QMediaFormat::FileFormat::QuickTime, u"quickTime" },
{ QMediaFormat::FileFormat::WebM, u"webm" },
{ QMediaFormat::FileFormat::Mpeg4Audio, u"mpeg4Audio" },
{ QMediaFormat::FileFormat::AAC, u"aac" },
{ QMediaFormat::FileFormat::WMA, u"wma" },
{ QMediaFormat::FileFormat::MP3, u"mp3" },
{ QMediaFormat::FileFormat::FLAC, u"flac" },
};

AudioGeneratorSettings m_audioGenerationSettings;
VideoGeneratorSettings m_videoGenerationSettings;
PushModeSettings m_pushModeSettings;
Expand Down
10 changes: 10 additions & 0 deletions tests/manual/mediaframeinputs/recordingrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ RecordingRunner::RecordingRunner(const RecorderSettings &recorderSettings)
m_recorder.setQuality(*recorderSettings.quality);
if (!recorderSettings.outputLocation.isEmpty())
m_recorder.setOutputLocation(recorderSettings.outputLocation);
if (recorderSettings.fileFormat || recorderSettings.audioCodec || recorderSettings.videoCodec) {
QMediaFormat format;
if (recorderSettings.fileFormat)
format.setFileFormat(*recorderSettings.fileFormat);
if (recorderSettings.videoCodec)
format.setVideoCodec(*recorderSettings.videoCodec);
if (recorderSettings.audioCodec)
format.setAudioCodec(*recorderSettings.audioCodec);
m_recorder.setMediaFormat(format);
}

m_recorder.setAutoStop(true);

Expand Down
4 changes: 4 additions & 0 deletions tests/manual/mediaframeinputs/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <QAudioFormat>
#include <QMediaRecorder>
#include <QMediaFormat>
#include <QUrl>

#include <optional>
Expand Down Expand Up @@ -50,6 +51,9 @@ struct RecorderSettings
QSize resolution;
std::optional<QMediaRecorder::Quality> quality;
QUrl outputLocation;
std::optional<QMediaFormat::AudioCodec> audioCodec;
std::optional<QMediaFormat::VideoCodec> videoCodec;
std::optional<QMediaFormat::FileFormat> fileFormat;
};

struct PushModeSettings
Expand Down

0 comments on commit b6fe8bf

Please sign in to comment.