export: fixed many export formats including still image and image sequence export
Still incomplete, but does a lot towards #1345
This commit is contained in:
+92
-3
@@ -22,10 +22,15 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "common/timecodefunctions.h"
|
||||
#include "ffmpeg/ffmpegencoder.h"
|
||||
#include "oiio/oiioencoder.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QRegularExpression Encoder::kImageSequenceContainsDigits = QRegularExpression(QStringLiteral("\\[[#]+\\]"));
|
||||
const QRegularExpression Encoder::kImageSequenceRemoveDigits = QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]"));
|
||||
|
||||
Encoder::Encoder(const EncodingParams ¶ms) :
|
||||
params_(params)
|
||||
{
|
||||
@@ -36,6 +41,47 @@ const EncodingParams &Encoder::params() const
|
||||
return params_;
|
||||
}
|
||||
|
||||
QString Encoder::GetFilenameForFrame(const rational &frame)
|
||||
{
|
||||
if (params().video_is_image_sequence()) {
|
||||
// Transform!
|
||||
int64_t frame_index = Timecode::time_to_timestamp(frame, params().video_params().frame_rate_as_time_base());
|
||||
int digits = GetImageSequencePlaceholderDigitCount(params().filename());
|
||||
QString frame_index_str = QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0'));
|
||||
|
||||
QString f = params_.filename();
|
||||
f.replace(kImageSequenceContainsDigits, frame_index_str);
|
||||
return f;
|
||||
} else {
|
||||
// Keep filename
|
||||
return params_.filename();
|
||||
}
|
||||
}
|
||||
|
||||
int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename)
|
||||
{
|
||||
int start = filename.indexOf(kImageSequenceContainsDigits);
|
||||
int digit_count = 0;
|
||||
for (int i=start+1; i<filename.size(); i++) {
|
||||
if (filename.at(i) == '#') {
|
||||
digit_count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return digit_count;
|
||||
}
|
||||
|
||||
bool Encoder::FilenameContainsDigitPlaceholder(const QString& filename)
|
||||
{
|
||||
return filename.contains(kImageSequenceContainsDigits);
|
||||
}
|
||||
|
||||
QString Encoder::FilenameRemoveDigitPlaceholder(QString filename)
|
||||
{
|
||||
return filename.remove(kImageSequenceRemoveDigits);
|
||||
}
|
||||
|
||||
void Encoder::WriteAudio(AudioParams pcm_info, const QString &pcm_filename)
|
||||
{
|
||||
QFile f(pcm_filename);
|
||||
@@ -49,6 +95,7 @@ EncodingParams::EncodingParams() :
|
||||
video_max_bit_rate_(0),
|
||||
video_buffer_size_(0),
|
||||
video_threads_(0),
|
||||
video_is_image_sequence_(false),
|
||||
audio_enabled_(false),
|
||||
audio_bit_rate_(0)
|
||||
{
|
||||
@@ -242,11 +289,53 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const
|
||||
writer->writeEndElement(); // audio
|
||||
}
|
||||
|
||||
Encoder* Encoder::CreateFromID(const QString &id, const EncodingParams& params)
|
||||
Encoder* Encoder::CreateFromID(Type id, const EncodingParams& params)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
switch (id) {
|
||||
case kEncoderTypeNone:
|
||||
break;
|
||||
case kEncoderTypeFFmpeg:
|
||||
return new FFmpegEncoder(params);
|
||||
case kEncoderTypeOIIO:
|
||||
return new OIIOEncoder(params);
|
||||
}
|
||||
|
||||
return new FFmpegEncoder(params);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Encoder::Type Encoder::GetTypeFromFormat(ExportFormat::Format f)
|
||||
{
|
||||
switch (f) {
|
||||
case ExportFormat::kFormatDNxHD:
|
||||
case ExportFormat::kFormatMatroska:
|
||||
case ExportFormat::kFormatQuickTime:
|
||||
case ExportFormat::kFormatMPEG4:
|
||||
case ExportFormat::kFormatWAV:
|
||||
case ExportFormat::kFormatAIFF:
|
||||
case ExportFormat::kFormatMP3:
|
||||
case ExportFormat::kFormatFLAC:
|
||||
case ExportFormat::kFormatOgg:
|
||||
case ExportFormat::kFormatWebM:
|
||||
return kEncoderTypeFFmpeg;
|
||||
case ExportFormat::kFormatOpenEXR:
|
||||
case ExportFormat::kFormatPNG:
|
||||
case ExportFormat::kFormatTIFF:
|
||||
return kEncoderTypeOIIO;
|
||||
case ExportFormat::kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return kEncoderTypeNone;
|
||||
}
|
||||
|
||||
Encoder *Encoder::CreateFromFormat(ExportFormat::Format f, const EncodingParams ¶ms)
|
||||
{
|
||||
return CreateFromID(GetTypeFromFormat(f), params);
|
||||
}
|
||||
|
||||
QStringList Encoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
-1
@@ -22,6 +22,7 @@
|
||||
#define ENCODER_H
|
||||
|
||||
#include <memory>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
@@ -53,6 +54,10 @@ public:
|
||||
void set_video_buffer_size(const int64_t& sz);
|
||||
void set_video_threads(const int& threads);
|
||||
void set_video_pix_fmt(const QString& s);
|
||||
void set_video_is_image_sequence(bool s)
|
||||
{
|
||||
video_is_image_sequence_ = s;
|
||||
}
|
||||
|
||||
const QString& filename() const;
|
||||
|
||||
@@ -66,6 +71,10 @@ public:
|
||||
const int64_t& video_buffer_size() const;
|
||||
const int& video_threads() const;
|
||||
const QString& video_pix_fmt() const;
|
||||
bool video_is_image_sequence() const
|
||||
{
|
||||
return video_is_image_sequence_;
|
||||
}
|
||||
|
||||
bool audio_enabled() const;
|
||||
const ExportCodec::Codec &audio_codec() const;
|
||||
@@ -99,6 +108,7 @@ private:
|
||||
int64_t video_buffer_size_;
|
||||
int video_threads_;
|
||||
QString video_pix_fmt_;
|
||||
bool video_is_image_sequence_;
|
||||
|
||||
bool audio_enabled_;
|
||||
ExportCodec::Codec audio_codec_;
|
||||
@@ -115,6 +125,12 @@ class Encoder : public QObject
|
||||
public:
|
||||
Encoder(const EncodingParams& params);
|
||||
|
||||
enum Type {
|
||||
kEncoderTypeNone = -1,
|
||||
kEncoderTypeFFmpeg,
|
||||
kEncoderTypeOIIO
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Create a Encoder instance using a Encoder ID
|
||||
*
|
||||
@@ -122,7 +138,13 @@ public:
|
||||
*
|
||||
* A Encoder instance or nullptr if a Decoder with this ID does not exist
|
||||
*/
|
||||
static Encoder *CreateFromID(const QString& id, const EncodingParams ¶ms);
|
||||
static Encoder *CreateFromID(Type id, const EncodingParams ¶ms);
|
||||
|
||||
static Type GetTypeFromFormat(ExportFormat::Format f);
|
||||
|
||||
static Encoder *CreateFromFormat(ExportFormat::Format f, const EncodingParams ¶ms);
|
||||
|
||||
virtual QStringList GetPixelFormatsForCodec(ExportCodec::Codec c) const;
|
||||
|
||||
const EncodingParams& params() const;
|
||||
|
||||
@@ -136,6 +158,16 @@ public:
|
||||
return error_;
|
||||
}
|
||||
|
||||
QString GetFilenameForFrame(const rational& frame);
|
||||
|
||||
static int GetImageSequencePlaceholderDigitCount(const QString& filename);
|
||||
|
||||
static bool FilenameContainsDigitPlaceholder(const QString &filename);
|
||||
static QString FilenameRemoveDigitPlaceholder(QString filename);
|
||||
|
||||
static const QRegularExpression kImageSequenceContainsDigits;
|
||||
static const QRegularExpression kImageSequenceRemoveDigits;
|
||||
|
||||
public slots:
|
||||
virtual bool Open() = 0;
|
||||
|
||||
|
||||
+12
-43
@@ -52,6 +52,14 @@ QString ExportCodec::GetCodecName(ExportCodec::Codec c)
|
||||
return tr("AAC");
|
||||
case kCodecPCM:
|
||||
return tr("PCM (Uncompressed)");
|
||||
case kCodecFLAC:
|
||||
return tr("FLAC");
|
||||
case kCodecOpus:
|
||||
return tr("Opus");
|
||||
case kCodecVorbis:
|
||||
return tr("Vorbis");
|
||||
case kCodecVP9:
|
||||
return tr("VP9");
|
||||
case kCodecCount:
|
||||
break;
|
||||
}
|
||||
@@ -70,6 +78,10 @@ bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c)
|
||||
case kCodecMP3:
|
||||
case kCodecAAC:
|
||||
case kCodecPCM:
|
||||
case kCodecVorbis:
|
||||
case kCodecOpus:
|
||||
case kCodecFLAC:
|
||||
case kCodecVP9:
|
||||
return false;
|
||||
case kCodecOpenEXR:
|
||||
case kCodecPNG:
|
||||
@@ -82,47 +94,4 @@ bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c)
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList ExportCodec::GetPixelFormatsForCodec(ExportCodec::Codec c)
|
||||
{
|
||||
QStringList pix_fmts;
|
||||
|
||||
AVCodec* codec_info = nullptr;
|
||||
|
||||
switch (c) {
|
||||
case kCodecH264:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_H264);
|
||||
break;
|
||||
case kCodecDNxHD:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_DNXHD);
|
||||
break;
|
||||
case kCodecProRes:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_PRORES);
|
||||
break;
|
||||
case kCodecH265:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_HEVC);
|
||||
break;
|
||||
case kCodecOpenEXR:
|
||||
case kCodecPNG:
|
||||
case kCodecTIFF:
|
||||
// FIXME: Add these in (these will most likely use an OIIOEncoder which doesn't exist yet)
|
||||
break;
|
||||
case kCodecMP2:
|
||||
case kCodecMP3:
|
||||
case kCodecAAC:
|
||||
case kCodecPCM:
|
||||
case kCodecCount:
|
||||
// These are audio or invalid codecs and therefore have no pixel formats
|
||||
break;
|
||||
}
|
||||
|
||||
if (codec_info) {
|
||||
for (int i=0; codec_info->pix_fmts[i]!=-1; i++) {
|
||||
const char* pix_fmt_name = av_get_pix_fmt_name(codec_info->pix_fmts[i]);
|
||||
pix_fmts.append(pix_fmt_name);
|
||||
}
|
||||
}
|
||||
|
||||
return pix_fmts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class ExportCodec : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Codec {
|
||||
// Video codecs
|
||||
kCodecDNxHD,
|
||||
kCodecH264,
|
||||
kCodecH265,
|
||||
@@ -40,11 +41,16 @@ public:
|
||||
kCodecPNG,
|
||||
kCodecProRes,
|
||||
kCodecTIFF,
|
||||
kCodecVP9,
|
||||
|
||||
// Audio codecs
|
||||
kCodecMP2,
|
||||
kCodecMP3,
|
||||
kCodecAAC,
|
||||
kCodecPCM,
|
||||
kCodecOpus,
|
||||
kCodecVorbis,
|
||||
kCodecFLAC,
|
||||
|
||||
kCodecCount
|
||||
};
|
||||
@@ -53,8 +59,6 @@ public:
|
||||
|
||||
static bool IsCodecAStillImage(Codec c);
|
||||
|
||||
static QStringList GetPixelFormatsForCodec(Codec c);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+65
-20
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "exportformat.h"
|
||||
|
||||
#include "encoder.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
QString ExportFormat::GetName(olive::ExportFormat::Format f)
|
||||
@@ -39,6 +41,19 @@ QString ExportFormat::GetName(olive::ExportFormat::Format f)
|
||||
return tr("TIFF");
|
||||
case kFormatQuickTime:
|
||||
return tr("QuickTime");
|
||||
case kFormatWAV:
|
||||
return tr("Wave Audio");
|
||||
case kFormatAIFF:
|
||||
return tr("AIFF");
|
||||
case kFormatMP3:
|
||||
return tr("MP3");
|
||||
case kFormatFLAC:
|
||||
return tr("FLAC");
|
||||
case kFormatOgg:
|
||||
return tr("Ogg");
|
||||
case kFormatWebM:
|
||||
return tr("WebM");
|
||||
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
@@ -63,25 +78,18 @@ QString ExportFormat::GetExtension(ExportFormat::Format f)
|
||||
return QStringLiteral("tiff");
|
||||
case kFormatQuickTime:
|
||||
return QStringLiteral("mov");
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString ExportFormat::GetEncoder(ExportFormat::Format f)
|
||||
{
|
||||
switch (f) {
|
||||
case kFormatDNxHD:
|
||||
case kFormatMatroska:
|
||||
case kFormatQuickTime:
|
||||
case kFormatMPEG4:
|
||||
return QStringLiteral("ffmpeg");
|
||||
case kFormatOpenEXR:
|
||||
case kFormatPNG:
|
||||
case kFormatTIFF:
|
||||
return QStringLiteral("oiio");
|
||||
case kFormatWAV:
|
||||
return QStringLiteral("wav");
|
||||
case kFormatAIFF:
|
||||
return QStringLiteral("aiff");
|
||||
case kFormatMP3:
|
||||
return QStringLiteral("mp3");
|
||||
case kFormatFLAC:
|
||||
return QStringLiteral("flac");
|
||||
case kFormatOgg:
|
||||
return QStringLiteral("ogg");
|
||||
case kFormatWebM:
|
||||
return QStringLiteral("webm");
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
@@ -106,6 +114,14 @@ QList<ExportCodec::Codec> ExportFormat::GetVideoCodecs(ExportFormat::Format f)
|
||||
return {ExportCodec::kCodecTIFF};
|
||||
case kFormatQuickTime:
|
||||
return {ExportCodec::kCodecH264, ExportCodec::kCodecH265, ExportCodec::kCodecProRes};
|
||||
case kFormatWebM:
|
||||
return {ExportCodec::kCodecVP9};
|
||||
case kFormatOgg:
|
||||
case kFormatWAV:
|
||||
case kFormatAIFF:
|
||||
case kFormatMP3:
|
||||
case kFormatFLAC:
|
||||
return {};
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
@@ -119,15 +135,31 @@ QList<ExportCodec::Codec> ExportFormat::GetAudioCodecs(ExportFormat::Format f)
|
||||
case kFormatDNxHD:
|
||||
return {ExportCodec::kCodecPCM};
|
||||
case kFormatMatroska:
|
||||
return {ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::kCodecPCM};
|
||||
return {ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus};
|
||||
case kFormatMPEG4:
|
||||
return {ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::kCodecPCM};
|
||||
case kFormatQuickTime:
|
||||
return {ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::kCodecPCM};
|
||||
case kFormatWebM:
|
||||
return {ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus};
|
||||
case kFormatOpenEXR:
|
||||
case kFormatPNG:
|
||||
case kFormatTIFF:
|
||||
return {};
|
||||
|
||||
|
||||
case kFormatWAV:
|
||||
return {ExportCodec::kCodecPCM};
|
||||
case kFormatAIFF:
|
||||
return {ExportCodec::kCodecPCM};
|
||||
case kFormatMP3:
|
||||
return {ExportCodec::kCodecMP3};
|
||||
case kFormatFLAC:
|
||||
return {ExportCodec::kCodecFLAC};
|
||||
case kFormatOgg:
|
||||
return {ExportCodec::kCodecOpus, ExportCodec::kCodecVorbis, ExportCodec::kCodecPCM};
|
||||
|
||||
|
||||
case kFormatCount:
|
||||
break;
|
||||
}
|
||||
@@ -135,4 +167,17 @@ QList<ExportCodec::Codec> ExportFormat::GetAudioCodecs(ExportFormat::Format f)
|
||||
return {};
|
||||
}
|
||||
|
||||
QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f, ExportCodec::Codec c)
|
||||
{
|
||||
Encoder* e = Encoder::CreateFromFormat(f, EncodingParams());
|
||||
QStringList list;
|
||||
|
||||
if (e) {
|
||||
list = e->GetPixelFormatsForCodec(c);
|
||||
delete e;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,16 +41,23 @@ public:
|
||||
kFormatQuickTime,
|
||||
kFormatPNG,
|
||||
kFormatTIFF,
|
||||
kFormatWAV,
|
||||
kFormatAIFF,
|
||||
kFormatMP3,
|
||||
kFormatFLAC,
|
||||
kFormatOgg,
|
||||
kFormatWebM,
|
||||
|
||||
kFormatCount
|
||||
};
|
||||
|
||||
static QString GetName(Format f);
|
||||
static QString GetExtension(Format f);
|
||||
static QString GetEncoder(Format f);
|
||||
static QList<ExportCodec::Codec> GetVideoCodecs(ExportFormat::Format f);
|
||||
static QList<ExportCodec::Codec> GetAudioCodecs(ExportFormat::Format f);
|
||||
|
||||
static QStringList GetPixelFormatsForCodec(Format f, ExportCodec::Codec c);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,59 @@ FFmpegEncoder::FFmpegEncoder(const EncodingParams ¶ms) :
|
||||
{
|
||||
}
|
||||
|
||||
QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const
|
||||
{
|
||||
QStringList pix_fmts;
|
||||
|
||||
AVCodec* codec_info = nullptr;
|
||||
|
||||
switch (c) {
|
||||
case ExportCodec::kCodecH264:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_H264);
|
||||
break;
|
||||
case ExportCodec::kCodecDNxHD:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_DNXHD);
|
||||
break;
|
||||
case ExportCodec::kCodecProRes:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_PRORES);
|
||||
break;
|
||||
case ExportCodec::kCodecH265:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_HEVC);
|
||||
break;
|
||||
case ExportCodec::kCodecVP9:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_VP9);
|
||||
break;
|
||||
case ExportCodec::kCodecOpenEXR:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_EXR);
|
||||
break;
|
||||
case ExportCodec::kCodecPNG:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_PNG);
|
||||
break;
|
||||
case ExportCodec::kCodecTIFF:
|
||||
codec_info = avcodec_find_encoder(AV_CODEC_ID_TIFF);
|
||||
break;
|
||||
case ExportCodec::kCodecMP2:
|
||||
case ExportCodec::kCodecMP3:
|
||||
case ExportCodec::kCodecAAC:
|
||||
case ExportCodec::kCodecPCM:
|
||||
case ExportCodec::kCodecFLAC:
|
||||
case ExportCodec::kCodecOpus:
|
||||
case ExportCodec::kCodecVorbis:
|
||||
case ExportCodec::kCodecCount:
|
||||
// These are audio or invalid codecs and therefore have no pixel formats
|
||||
break;
|
||||
}
|
||||
|
||||
if (codec_info) {
|
||||
for (int i=0; codec_info->pix_fmts[i]!=-1; i++) {
|
||||
const char* pix_fmt_name = av_get_pix_fmt_name(codec_info->pix_fmts[i]);
|
||||
pix_fmts.append(pix_fmt_name);
|
||||
}
|
||||
}
|
||||
|
||||
return pix_fmts;
|
||||
}
|
||||
|
||||
bool FFmpegEncoder::Open()
|
||||
{
|
||||
if (open_) {
|
||||
@@ -447,6 +500,18 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
|
||||
case ExportCodec::kCodecPCM:
|
||||
codec_id = AV_CODEC_ID_PCM_S16LE;
|
||||
break;
|
||||
case ExportCodec::kCodecVP9:
|
||||
codec_id = AV_CODEC_ID_VP9;
|
||||
break;
|
||||
case ExportCodec::kCodecOpus:
|
||||
codec_id = AV_CODEC_ID_OPUS;
|
||||
break;
|
||||
case ExportCodec::kCodecVorbis:
|
||||
codec_id = AV_CODEC_ID_VORBIS;
|
||||
break;
|
||||
case ExportCodec::kCodecFLAC:
|
||||
codec_id = AV_CODEC_ID_FLAC;
|
||||
break;
|
||||
case ExportCodec::kCodecCount:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ class FFmpegEncoder : public Encoder
|
||||
public:
|
||||
FFmpegEncoder(const EncodingParams ¶ms);
|
||||
|
||||
virtual QStringList GetPixelFormatsForCodec(ExportCodec::Codec c) const override;
|
||||
|
||||
virtual bool Open() override;
|
||||
|
||||
virtual bool WriteFrame(olive::FramePtr frame, olive::rational time) override;
|
||||
|
||||
@@ -18,5 +18,7 @@ set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
codec/oiio/oiiodecoder.cpp
|
||||
codec/oiio/oiiodecoder.h
|
||||
codec/oiio/oiioencoder.cpp
|
||||
codec/oiio/oiioencoder.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "oiioencoder.h"
|
||||
|
||||
#include "common/oiioutils.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
OIIOEncoder::OIIOEncoder(const EncodingParams ¶ms) :
|
||||
Encoder(params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool OIIOEncoder::Open()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OIIOEncoder::WriteFrame(FramePtr frame, rational time)
|
||||
{
|
||||
std::string filename = GetFilenameForFrame(time).toStdString();
|
||||
|
||||
auto output = OIIO::ImageOutput::create(filename);
|
||||
if (!output) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OIIO::TypeDesc type = OIIOUtils::GetOIIOBaseTypeFromFormat(frame->format());
|
||||
OIIO::ImageSpec spec(frame->width(), frame->height(), frame->channel_count(), type);
|
||||
|
||||
if (!output->open(filename, spec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!output->write_image(type, frame->data(), OIIO::AutoStride, frame->linesize_bytes())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!output->close()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OIIOEncoder::WriteAudio(AudioParams pcm_info, QIODevice *file)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void OIIOEncoder::Close()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OIIOENCODER_H
|
||||
#define OIIOENCODER_H
|
||||
|
||||
#include "codec/encoder.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class OIIOEncoder : public Encoder
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OIIOEncoder(const EncodingParams ¶ms);
|
||||
|
||||
public slots:
|
||||
virtual bool Open() override;
|
||||
|
||||
virtual bool WriteFrame(olive::FramePtr frame, olive::rational time) override;
|
||||
virtual void WriteAudio(olive::AudioParams pcm_info,
|
||||
QIODevice *file) override;
|
||||
|
||||
virtual void Close() override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OIIOENCODER_H
|
||||
Reference in New Issue
Block a user