added title/action safe areas
This commit is contained in:
+16
-1
@@ -18,7 +18,10 @@ Config::Config()
|
||||
paste_seeks(true),
|
||||
rectified_waveforms(false),
|
||||
default_transition_length(30),
|
||||
timecode_view(TIMECODE_DROP)
|
||||
timecode_view(TIMECODE_DROP),
|
||||
show_title_safe_area(false),
|
||||
use_custom_title_safe_ratio(false),
|
||||
custom_title_safe_ratio(1)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -64,6 +67,15 @@ void Config::load(QString path) {
|
||||
} else if (stream.name() == "TimecodeView") {
|
||||
stream.readNext();
|
||||
timecode_view = stream.text().toInt();
|
||||
}else if (stream.name() == "ShowTitleSafeArea") {
|
||||
stream.readNext();
|
||||
show_title_safe_area = (stream.text() == "1");
|
||||
} else if (stream.name() == "UseCustomTitleSafeRatio") {
|
||||
stream.readNext();
|
||||
use_custom_title_safe_ratio = (stream.text() == "1");
|
||||
} else if (stream.name() == "CustomTitleSafeRatio") {
|
||||
stream.readNext();
|
||||
custom_title_safe_ratio = stream.text().toDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,6 +133,9 @@ void Config::save(QString path) {
|
||||
stream.writeTextElement("RectifiedWaveforms", QString::number(rectified_waveforms));
|
||||
stream.writeTextElement("DefaultTransitionLength", QString::number(default_transition_length));
|
||||
stream.writeTextElement("TimecodeView", QString::number(timecode_view));
|
||||
stream.writeTextElement("ShowTitleSafeArea", QString::number(show_title_safe_area));
|
||||
stream.writeTextElement("UseCustomTitleSafeRatio", QString::number(use_custom_title_safe_ratio));
|
||||
stream.writeTextElement("CustomTitleSafeRatio", QString::number(custom_title_safe_ratio));
|
||||
|
||||
stream.writeEndElement();
|
||||
stream.writeEndDocument(); // doc
|
||||
|
||||
@@ -22,6 +22,9 @@ struct Config {
|
||||
bool rectified_waveforms;
|
||||
int default_transition_length;
|
||||
int timecode_view;
|
||||
bool show_title_safe_area;
|
||||
bool use_custom_title_safe_ratio;
|
||||
double custom_title_safe_ratio;
|
||||
|
||||
void load(QString path);
|
||||
void save(QString path);
|
||||
|
||||
+10
-3
@@ -12,7 +12,8 @@
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libswscale/swscale.h>
|
||||
}
|
||||
@@ -108,15 +109,21 @@ bool ExportThread::setupVideo() {
|
||||
vcodec_ctx->sample_aspect_ratio = av_d2q(video_width/video_height, INT_MAX);
|
||||
vcodec_ctx->pix_fmt = vcodec->pix_fmts[0]; // maybe be breakable code
|
||||
vcodec_ctx->framerate = av_d2q(video_frame_rate, INT_MAX);
|
||||
vcodec_ctx->bit_rate = video_bitrate * 1000000;
|
||||
vcodec_ctx->bit_rate = video_bitrate * 1000000;
|
||||
vcodec_ctx->time_base = av_inv_q(vcodec_ctx->framerate);
|
||||
|
||||
if (fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) {
|
||||
vcodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
}
|
||||
|
||||
if (vcodec_ctx->codec_id == AV_CODEC_ID_H264) {
|
||||
// av_opt_set(vcodec_ctx->priv_data, "preset", "veryslow", AV_OPT_SEARCH_CHILDREN);
|
||||
// av_opt_set(vcodec_ctx->priv_data, "crf", "0", AV_OPT_SEARCH_CHILDREN);
|
||||
av_opt_set(vcodec_ctx->priv_data, "x264-params", "nal-hrd=cbr", AV_OPT_SEARCH_CHILDREN);
|
||||
}
|
||||
|
||||
// open encoder
|
||||
vcodec_ctx->gop_size = 12; // ? does this help?
|
||||
vcodec_ctx->gop_size = 40; // ? does this help?
|
||||
ret = avcodec_open2(vcodec_ctx, vcodec, NULL);
|
||||
if (ret < 0) {
|
||||
qDebug() << "[ERROR] Could not open output video encoder." << ret;
|
||||
|
||||
+58
-1
@@ -6,6 +6,7 @@
|
||||
#include "project/sequence.h"
|
||||
|
||||
#include "ui/sourcetable.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "panels/project.h"
|
||||
@@ -34,6 +35,8 @@
|
||||
#include <QTimer>
|
||||
#include <QCloseEvent>
|
||||
#include <QMovie>
|
||||
#include <QInputDialog>
|
||||
#include <QRegExp>
|
||||
|
||||
#define OLIVE_FILE_FILTER "Olive Project (*.ove)"
|
||||
|
||||
@@ -540,8 +543,13 @@ void MainWindow::viewMenu_About_To_Be_Shown() {
|
||||
ui->actionTimeline_Track_Lines->setChecked(config.show_track_lines);
|
||||
ui->actionFrames->setChecked(config.timecode_view == TIMECODE_FRAMES);
|
||||
ui->actionDrop_Frame->setChecked(config.timecode_view == TIMECODE_DROP);
|
||||
// if (sequence != NULL) ui->actionDrop_Frame->setEnabled(frame_rate_is_droppable(sequence->frame_rate));
|
||||
ui->actionNon_Drop_Frame->setChecked(config.timecode_view == TIMECODE_NONDROP);
|
||||
|
||||
ui->actionOff->setChecked(!config.show_title_safe_area);
|
||||
ui->actionDefault->setChecked(config.show_title_safe_area && !config.use_custom_title_safe_ratio);
|
||||
ui->action4_3->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && config.custom_title_safe_ratio == 4.0/3.0);
|
||||
ui->action16_9->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && config.custom_title_safe_ratio == 16.0/9.0);
|
||||
ui->actionCustom->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && !ui->action4_3->isChecked() && !ui->action16_9->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFrames_triggered()
|
||||
@@ -715,3 +723,52 @@ void MainWindow::on_actionRectified_Waveforms_triggered()
|
||||
config.rectified_waveforms = !config.rectified_waveforms;
|
||||
panel_timeline->redraw_all_clips(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDefault_triggered() {
|
||||
config.show_title_safe_area = true;
|
||||
config.use_custom_title_safe_ratio = false;
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOff_triggered() {
|
||||
config.show_title_safe_area = false;
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void MainWindow::on_action4_3_triggered() {
|
||||
config.show_title_safe_area = true;
|
||||
config.use_custom_title_safe_ratio = true;
|
||||
config.custom_title_safe_ratio = 4.0/3.0;
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void MainWindow::on_action16_9_triggered() {
|
||||
config.show_title_safe_area = true;
|
||||
config.use_custom_title_safe_ratio = true;
|
||||
config.custom_title_safe_ratio = 16.0/9.0;
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCustom_triggered() {
|
||||
QString input;
|
||||
bool invalid = false;
|
||||
QRegExp arTest("[0-9.]+:[0-9.]+");
|
||||
|
||||
do {
|
||||
if (invalid) {
|
||||
QMessageBox::critical(this, "Invalid aspect ratio", "The aspect ratio '" + input + "' is invalid. Please try again.");
|
||||
}
|
||||
|
||||
input = QInputDialog::getText(this, "Enter custom aspect ratio", "Enter the aspect ratio to use for the title/action safe area (e.g. 16:9):");
|
||||
invalid = !arTest.exactMatch(input) && !input.isEmpty();
|
||||
} while (invalid);
|
||||
|
||||
if (!input.isEmpty()) {
|
||||
QStringList inputList = input.split(':');
|
||||
|
||||
config.show_title_safe_area = true;
|
||||
config.use_custom_title_safe_ratio = true;
|
||||
config.custom_title_safe_ratio = inputList.at(0).toDouble()/inputList.at(1).toDouble();
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -167,7 +167,17 @@ private slots:
|
||||
|
||||
void on_actionTimeline_Track_Lines_triggered();
|
||||
|
||||
void on_actionRectified_Waveforms_triggered();
|
||||
void on_actionRectified_Waveforms_triggered();
|
||||
|
||||
void on_actionDefault_triggered();
|
||||
|
||||
void on_actionOff_triggered();
|
||||
|
||||
void on_action4_3_triggered();
|
||||
|
||||
void on_action16_9_triggered();
|
||||
|
||||
void on_actionCustom_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
+53
-1
@@ -37,7 +37,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>20</height>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -120,6 +120,16 @@
|
||||
<property name="title">
|
||||
<string>&View</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuTitle_Action_Safe_Area">
|
||||
<property name="title">
|
||||
<string>Title/Action Safe Area</string>
|
||||
</property>
|
||||
<addaction name="actionOff"/>
|
||||
<addaction name="actionDefault"/>
|
||||
<addaction name="action4_3"/>
|
||||
<addaction name="action16_9"/>
|
||||
<addaction name="actionCustom"/>
|
||||
</widget>
|
||||
<addaction name="actionTimeline_Track_Lines"/>
|
||||
<addaction name="actionZoom_In"/>
|
||||
<addaction name="actionZoom_out"/>
|
||||
@@ -129,6 +139,8 @@
|
||||
<addaction name="actionFrames"/>
|
||||
<addaction name="actionDrop_Frame"/>
|
||||
<addaction name="actionNon_Drop_Frame"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuTitle_Action_Safe_Area"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuPlayback">
|
||||
<property name="title">
|
||||
@@ -709,6 +721,46 @@
|
||||
<string>Rectified Waveforms</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDefault">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOff">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action4_3">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>4:3</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action16_9">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>16:9</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCustom">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
||||
+2
-2
@@ -318,8 +318,8 @@ void open_clip_worker(Clip* clip) {
|
||||
av_dict_set(&opts, "threads", "auto", 0);
|
||||
}
|
||||
if (clip->stream->codecpar->codec_id == AV_CODEC_ID_H264) {
|
||||
av_dict_set(&opts, "tune", "fastdecode", 0);
|
||||
av_dict_set(&opts, "tune", "zerolatency", 0);
|
||||
av_dict_set(&opts, "tune", "fastdecode", 0);
|
||||
av_dict_set(&opts, "tune", "zerolatency", 0);
|
||||
}
|
||||
|
||||
// Open codec
|
||||
|
||||
+74
-1
@@ -12,6 +12,7 @@
|
||||
#include "io/media.h"
|
||||
#include "ui_timeline.h"
|
||||
#include "playback/cacher.h"
|
||||
#include "io/config.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
@@ -64,7 +65,75 @@ void ViewerWidget::paintEvent(QPaintEvent *e) {
|
||||
if (!rendering) {
|
||||
makeCurrent();
|
||||
QOpenGLWidget::paintEvent(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::drawTitleSafeArea() {
|
||||
double halfWidth = 0.5;
|
||||
double halfHeight = 0.5;
|
||||
double viewportAr = (double) width() / (double) height();
|
||||
double halfAr = viewportAr*0.5;
|
||||
|
||||
if (config.use_custom_title_safe_ratio && config.custom_title_safe_ratio > 0) {
|
||||
if (config.custom_title_safe_ratio > viewportAr) {
|
||||
halfHeight = (config.custom_title_safe_ratio/viewportAr)*0.5;
|
||||
} else {
|
||||
halfWidth = (viewportAr/config.custom_title_safe_ratio)*0.5;
|
||||
}
|
||||
}
|
||||
|
||||
glLoadIdentity();
|
||||
glOrtho(-halfWidth, halfWidth, halfHeight, -halfHeight, -1, 1);
|
||||
|
||||
glColor3f(0.5, 0.5, 0.5);
|
||||
glBegin(GL_LINES);
|
||||
|
||||
// action safe rectangle
|
||||
glVertex2d(-0.45, -0.45);
|
||||
glVertex2d(0.45, -0.45);
|
||||
glVertex2d(0.45, -0.45);
|
||||
glVertex2d(0.45, 0.45);
|
||||
glVertex2d(0.45, 0.45);
|
||||
glVertex2d(-0.45, 0.45);
|
||||
glVertex2d(-0.45, 0.45);
|
||||
glVertex2d(-0.45, -0.45);
|
||||
|
||||
// title safe rectangle
|
||||
glVertex2d(-0.4, -0.4);
|
||||
glVertex2d(0.4, -0.4);
|
||||
glVertex2d(0.4, -0.4);
|
||||
glVertex2d(0.4, 0.4);
|
||||
glVertex2d(0.4, 0.4);
|
||||
glVertex2d(-0.4, 0.4);
|
||||
glVertex2d(-0.4, 0.4);
|
||||
glVertex2d(-0.4, -0.4);
|
||||
|
||||
// horizontal centers
|
||||
glVertex2d(-0.45, 0);
|
||||
glVertex2d(-0.375, 0);
|
||||
glVertex2d(0.45, 0);
|
||||
glVertex2d(0.375, 0);
|
||||
|
||||
// vertical centers
|
||||
glVertex2d(0, -0.45);
|
||||
glVertex2d(0, -0.375);
|
||||
glVertex2d(0, 0.45);
|
||||
glVertex2d(0, 0.375);
|
||||
|
||||
glEnd();
|
||||
|
||||
// center cross
|
||||
glLoadIdentity();
|
||||
glOrtho(-halfAr, halfAr, 0.5, -0.5, -1, 1);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
glVertex2d(-0.05, 0);
|
||||
glVertex2d(0.05, 0);
|
||||
glVertex2d(0, -0.05);
|
||||
glVertex2d(0, 0.05);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture) {
|
||||
@@ -362,6 +431,10 @@ void ViewerWidget::paintGL() {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.show_title_safe_area) {
|
||||
drawTitleSafeArea();
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} while (loop);
|
||||
|
||||
@@ -29,6 +29,7 @@ protected:
|
||||
// void resizeGL(int w, int h);
|
||||
private:
|
||||
QTimer retry_timer;
|
||||
void drawTitleSafeArea();
|
||||
private slots:
|
||||
void retry();
|
||||
void deleteFunction();
|
||||
|
||||
Reference in New Issue
Block a user