diff --git a/app/codec/exportformat.cpp b/app/codec/exportformat.cpp index 9b6997d78a..eb155f513b 100644 --- a/app/codec/exportformat.cpp +++ b/app/codec/exportformat.cpp @@ -121,7 +121,7 @@ QList ExportFormat::GetVideoCodecs(ExportFormat::Format f) case kFormatTIFF: return {ExportCodec::kCodecTIFF}; case kFormatQuickTime: - return {ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, ExportCodec::kCodecH265, ExportCodec::kCodecProRes, ExportCodec::kCodecCineform}; + return {ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, ExportCodec::kCodecH265, ExportCodec::kCodecProRes, ExportCodec::kCodecCineform, ExportCodec::kCodecDNxHD}; case kFormatWebM: return {ExportCodec::kCodecVP9}; case kFormatOgg: diff --git a/app/codec/ffmpeg/ffmpegencoder.cpp b/app/codec/ffmpeg/ffmpegencoder.cpp index 403bfab711..6457c2407a 100644 --- a/app/codec/ffmpeg/ffmpegencoder.cpp +++ b/app/codec/ffmpeg/ffmpegencoder.cpp @@ -770,6 +770,7 @@ bool FFmpegEncoder::SetupCodecContext(AVStream* stream, AVCodecContext* codec_ct if (codec->type == AVMEDIA_TYPE_VIDEO) { stream->avg_frame_rate = codec_ctx->framerate; + stream->time_base = av_add_q(codec_ctx->time_base, {0, 1}); } return true; diff --git a/app/dialog/export/codec/CMakeLists.txt b/app/dialog/export/codec/CMakeLists.txt index f00ce26903..116fcfe5ff 100644 --- a/app/dialog/export/codec/CMakeLists.txt +++ b/app/dialog/export/codec/CMakeLists.txt @@ -22,6 +22,8 @@ set(OLIVE_SOURCES dialog/export/codec/codecsection.h dialog/export/codec/codecstack.cpp dialog/export/codec/codecstack.h + dialog/export/codec/dnxhdsection.cpp + dialog/export/codec/dnxhdsection.h dialog/export/codec/h264section.cpp dialog/export/codec/h264section.h dialog/export/codec/imagesection.cpp diff --git a/app/dialog/export/codec/dnxhdsection.cpp b/app/dialog/export/codec/dnxhdsection.cpp new file mode 100644 index 0000000000..048a11df0e --- /dev/null +++ b/app/dialog/export/codec/dnxhdsection.cpp @@ -0,0 +1,70 @@ +/*** + 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 . +***/ + +#include "dnxhdsection.h" + +#include +#include + +namespace olive { + +DNxHDSection::DNxHDSection(QWidget *parent) : + CodecSection(parent) +{ + QGridLayout *layout = new QGridLayout(this); + + layout->setMargin(0); + + int row = 0; + + layout->addWidget(new QLabel(tr("Profile:")), row, 0); + + preset_combobox_ = new QComboBox(); + + preset_combobox_->setToolTip(tr("While using DNxHD you may need to manually change pixel format. \n\n" + "dnxhr_hqx profile will need you to manually specify pixel format `422p10le` in the advanced menu. \n\n" + "dnxhr_444 profile will need you to manually specify pixel format `444p10le` or `gbrp10le` in the advanced menu.")); + + /* Correspond to the following indexes for FFmpeg + * + *-profile E..V....... (from 0 to 5) (default dnxhd) + * dnxhd 0 E..V....... + * dnxhr_444 5 E..V....... + * dnxhr_hqx 4 E..V....... + * dnxhr_hq 3 E..V....... + * dnxhr_sq 2 E..V....... + * dnxhr_lb 1 E..V....... + * + */ + + //preset_combobox_->addItem(tr("dnxhd")); + preset_combobox_->addItem(tr("dnxhr_lb")); + preset_combobox_->addItem(tr("dnxhr_sq")); + preset_combobox_->addItem(tr("dnxhr_hq")); + preset_combobox_->addItem(tr("dnxhr_hqx")); + preset_combobox_->addItem(tr("dnxhr_444")); + + + preset_combobox_->setCurrentIndex(1); + + layout->addWidget(preset_combobox_, row, 1); +} + +void DNxHDSection::AddOpts(EncodingParams *params) +{ + params->set_video_option(QStringLiteral("profile"), QString::number(preset_combobox_->currentIndex() + 1)); +} + +} diff --git a/app/dialog/export/codec/dnxhdsection.h b/app/dialog/export/codec/dnxhdsection.h new file mode 100644 index 0000000000..06ff69eb13 --- /dev/null +++ b/app/dialog/export/codec/dnxhdsection.h @@ -0,0 +1,40 @@ +/*** + 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 . +***/ + +#ifndef DNXHDSECTION_H +#define DNXHDSECTION_H + +#include + +#include "codecsection.h" + +namespace olive { + +class DNxHDSection : public CodecSection +{ + Q_OBJECT +public: + DNxHDSection(QWidget *parent = nullptr); + + virtual void AddOpts(EncodingParams* params) override; + +private: + QComboBox *preset_combobox_; + +}; + +} + +#endif // DNXHDSECTION_H diff --git a/app/dialog/export/exportvideotab.cpp b/app/dialog/export/exportvideotab.cpp index 56ecfcdfc5..9623ffcdbc 100644 --- a/app/dialog/export/exportvideotab.cpp +++ b/app/dialog/export/exportvideotab.cpp @@ -195,6 +195,9 @@ QWidget *ExportVideoTab::SetupCodecSection() cineform_section_ = new CineformSection(); codec_stack_->addWidget(cineform_section_); + dnxhd_section_ = new DNxHDSection(); + codec_stack_->addWidget(dnxhd_section_); + row++; QPushButton* advanced_btn = new QPushButton(tr("Advanced")); @@ -255,6 +258,9 @@ void ExportVideoTab::VideoCodecChanged() case ExportCodec::kCodecCineform: SetCodecSection(cineform_section_); break; + case ExportCodec::kCodecDNxHD: + SetCodecSection(dnxhd_section_); + break; default: SetCodecSection(ExportCodec::IsCodecAStillImage(codec) ? image_section_ : nullptr); } diff --git a/app/dialog/export/exportvideotab.h b/app/dialog/export/exportvideotab.h index 1a23837f62..e5ac8a2774 100644 --- a/app/dialog/export/exportvideotab.h +++ b/app/dialog/export/exportvideotab.h @@ -30,6 +30,7 @@ #include "dialog/export/codec/cineformsection.h" #include "dialog/export/codec/codecstack.h" #include "dialog/export/codec/h264section.h" +#include "dialog/export/codec/dnxhdsection.h" #include "dialog/export/codec/imagesection.h" #include "node/color/colormanager/colormanager.h" #include "widget/colorwheel/colorspacechooser.h" @@ -181,6 +182,7 @@ public slots: H264Section* h264_section_; H264Section* h265_section_; CineformSection *cineform_section_; + DNxHDSection *dnxhd_section_; ColorSpaceChooser* color_space_chooser_;