From: Jean-Baptiste Mardelle Date: Sat, 28 May 2011 08:08:49 +0000 (+0000) Subject: Second part of the capture rewrite. Decklink capture now seems to work with latest MLT X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=05812d33728689c0c531b81e283cd4616ab07842;p=kdenlive Second part of the capture rewrite. Decklink capture now seems to work with latest MLT svn path=/trunk/kdenlive/; revision=5612 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4be9af35..3bb60c67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -135,6 +135,7 @@ kde4_add_ui_files(kdenlive_UI widgets/bezierspline_ui.ui widgets/monitoreditwidget_ui.ui widgets/archivewidget_ui.ui + widgets/manageencodingprofile_ui.ui ) set(kdenlive_SRCS @@ -284,6 +285,7 @@ set(kdenlive_SRCS archivewidget.cpp mltdevicecapture.cpp abstractmonitor.cpp + encodingprofilesdialog.cpp ) add_definitions(${KDE4_DEFINITIONS}) diff --git a/src/abstractmonitor.cpp b/src/abstractmonitor.cpp index b83765e6..4b2d5b7d 100644 --- a/src/abstractmonitor.cpp +++ b/src/abstractmonitor.cpp @@ -20,30 +20,52 @@ #include "abstractmonitor.h" +#include VideoPreviewContainer::VideoPreviewContainer(QWidget *parent) : - QFrame(parent), - m_image(new QImage()) + QFrame(parent) { setFrameShape(QFrame::NoFrame); setFocusPolicy(Qt::ClickFocus); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(update())); + m_refreshTimer.setSingleShot(false); + m_refreshTimer.setInterval(200); +} + +VideoPreviewContainer::~VideoPreviewContainer() +{ + qDeleteAll(m_imageQueue); } void VideoPreviewContainer::setImage(QImage img) { - if (m_image) delete m_image; - m_image = new QImage(img); - update(); + if (m_imageQueue.count() > 2) { + delete m_imageQueue.takeLast();//replace(10, new QImage(img)); + } + m_imageQueue.prepend(new QImage(img)); +} + +void VideoPreviewContainer::stop() +{ + m_refreshTimer.stop(); + qDeleteAll(m_imageQueue); + m_imageQueue.clear(); +} + +void VideoPreviewContainer::start() +{ + m_refreshTimer.start(); } // virtual void VideoPreviewContainer::paintEvent(QPaintEvent */*event*/) { - if (m_image->isNull()) return; + if (m_imageQueue.isEmpty()) return; + QImage *img = m_imageQueue.takeFirst(); QPainter painter(this); - double ar = (double) m_image->width() / m_image->height(); + double ar = (double) img->width() / img->height(); QRect rect = this->frameRect(); int paintW = rect.height() * ar + 0.5; if (paintW > rect.width()) { @@ -58,7 +80,8 @@ void VideoPreviewContainer::paintEvent(QPaintEvent */*event*/) rect.setWidth(paintW); } - painter.drawImage(rect, *m_image); + painter.drawImage(rect, *img); + delete img; } diff --git a/src/abstractmonitor.h b/src/abstractmonitor.h index 2f56ac4d..3cde7e04 100644 --- a/src/abstractmonitor.h +++ b/src/abstractmonitor.h @@ -26,20 +26,24 @@ #include #include #include +#include class VideoPreviewContainer : public QFrame { Q_OBJECT public: VideoPreviewContainer(QWidget *parent = 0); - + ~VideoPreviewContainer(); void setImage(QImage img); + void start(); + void stop(); protected: virtual void paintEvent(QPaintEvent */*event*/); private: - QImage *m_image; + QList m_imageQueue; + QTimer m_refreshTimer; }; diff --git a/src/blackmagic/capture.cpp b/src/blackmagic/capture.cpp index 5acec9dc..f57a48c6 100644 --- a/src/blackmagic/capture.cpp +++ b/src/blackmagic/capture.cpp @@ -805,14 +805,14 @@ void BmdCaptureHandler::startCapture(const QString &path) fprintf(stderr, "Could not open video output file \"%s\"\n", videopath.toUtf8().constData()); return; } - if (KdenliveSettings::hdmicaptureaudio()) { + /*if (KdenliveSettings::hdmicaptureaudio()) { audioOutputFile = open(audiopath.toUtf8().constData(), O_WRONLY | O_CREAT | O_TRUNC, 0664); if (audioOutputFile < 0) { emit gotMessage(i18n("Could not open audio output file %1", audiopath)); fprintf(stderr, "Could not open video output file \"%s\"\n", audiopath.toUtf8().constData()); return; } - } + }*/ } void BmdCaptureHandler::stopCapture() diff --git a/src/blackmagic/devices.cpp b/src/blackmagic/devices.cpp index 7277c6c3..b2196b41 100644 --- a/src/blackmagic/devices.cpp +++ b/src/blackmagic/devices.cpp @@ -29,7 +29,7 @@ BMInterface::BMInterface() } //static -bool BMInterface::getBlackMagicDeviceList(KComboBox *devicelist, KComboBox *modelist) +bool BMInterface::getBlackMagicDeviceList(KComboBox *devicelist) { IDeckLinkIterator* deckLinkIterator; IDeckLink* deckLink; @@ -138,10 +138,6 @@ bool BMInterface::getBlackMagicDeviceList(KComboBox *devicelist, KComboBox *mode } deckLinkIterator->Release(); - if(modelist != NULL && devicelist->count() > 0) { - QStringList modes = devicelist->itemData(devicelist->currentIndex()).toStringList(); - modelist->insertItems(0, modes); - } return found; } diff --git a/src/blackmagic/devices.h b/src/blackmagic/devices.h index 603ac1cd..fc75ed12 100644 --- a/src/blackmagic/devices.h +++ b/src/blackmagic/devices.h @@ -12,7 +12,7 @@ class BMInterface public: BMInterface(); ~BMInterface(); - static bool getBlackMagicDeviceList(KComboBox *devicelist, KComboBox *modelist); + static bool getBlackMagicDeviceList(KComboBox *devicelist); static bool getBlackMagicOutputDeviceList(KComboBox *devicelist); static bool isSupportedProfile(int card, QMap< QString, QString > properties); static QStringList supportedModes(int card); diff --git a/src/encodingprofilesdialog.cpp b/src/encodingprofilesdialog.cpp new file mode 100644 index 00000000..9a14e1c2 --- /dev/null +++ b/src/encodingprofilesdialog.cpp @@ -0,0 +1,187 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "encodingprofilesdialog.h" +#include "kdenlivesettings.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +EncodingProfilesDialog::EncodingProfilesDialog(int profileType, QWidget * parent) : + QDialog(parent), + m_configGroup(NULL) +{ + setupUi(this); + setWindowTitle(i18n("Manage Encoding Profiles")); + profile_type->addItem(i18n("Proxy clips"), 0); + profile_type->addItem(i18n("Video4Linux capture"), 1); + profile_type->addItem(i18n("Decklink capture"), 2); + + button_add->setIcon(KIcon("list-add")); + button_edit->setIcon(KIcon("document-edit")); + button_delete->setIcon(KIcon("list-remove")); + button_download->setIcon(KIcon("download")); + + QString profileFile = KStandardDirs::locateLocal("appdata", "encodingprofiles.rc"); + if (!QFile::exists(profileFile)) { + // todo: copy global config file to local + //KIO::NetAccess::copy() + } + m_configFile = new KConfig(profileFile, KConfig::SimpleConfig); + profile_type->setCurrentIndex(profileType); + connect(profile_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLoadProfiles())); + connect(profile_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotShowParams())); + connect(button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile())); + connect(button_add, SIGNAL(clicked()), this, SLOT(slotAddProfile())); + connect(button_edit, SIGNAL(clicked()), this, SLOT(slotEditProfile())); + profile_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5); + slotLoadProfiles(); +} + +EncodingProfilesDialog::~EncodingProfilesDialog() +{ + delete m_configGroup; + delete m_configFile; +} + +void EncodingProfilesDialog::slotLoadProfiles() +{ + profile_list->blockSignals(true); + profile_list->clear(); + QString group; + switch (profile_type->currentIndex()) { + case 0: + group = "proxy"; + break; + case 1: + group = "video4linux"; + break; + default: + case 2: + group = "decklink"; + break; + } + + + m_configGroup = new KConfigGroup(m_configFile, group); + QMap< QString, QString > values = m_configGroup->entryMap(); + QMapIterator i(values); + while (i.hasNext()) { + i.next(); + QListWidgetItem *item = new QListWidgetItem(i.key(), profile_list); + item->setData(Qt::UserRole, i.value()); + //cout << i.key() << ": " << i.value() << endl; + } + profile_list->blockSignals(false); + profile_list->setCurrentRow(0); + button_delete->setEnabled(profile_list->count() > 0); + button_edit->setEnabled(profile_list->count() > 0); +} + +void EncodingProfilesDialog::slotShowParams() +{ + profile_parameters->clear(); + QListWidgetItem *item = profile_list->currentItem(); + if (!item) return; + profile_parameters->setPlainText(item->data(Qt::UserRole).toString().section(";", 0, 0)); +} + +void EncodingProfilesDialog::slotDeleteProfile() +{ + QListWidgetItem *item = profile_list->currentItem(); + if (!item) return; + QString profile = item->text(); + m_configGroup->deleteEntry(profile); + slotLoadProfiles(); +} + +void EncodingProfilesDialog::slotAddProfile() +{ + QDialog *d = new QDialog(this); + QVBoxLayout *l = new QVBoxLayout; + l->addWidget(new QLabel(i18n("Profile name:"))); + QLineEdit *pname = new QLineEdit; + l->addWidget(pname); + l->addWidget(new QLabel(i18n("Parameters:"))); + QPlainTextEdit *pparams = new QPlainTextEdit; + l->addWidget(pparams); + l->addWidget(new QLabel(i18n("File extension:"))); + QLineEdit *pext = new QLineEdit; + l->addWidget(pext); + QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel); + connect(box, SIGNAL(accepted()), d, SLOT(accept())); + connect(box, SIGNAL(rejected()), d, SLOT(reject())); + l->addWidget(box); + d->setLayout(l); + + QListWidgetItem *item = profile_list->currentItem(); + if (item) { + QString data = item->data(Qt::UserRole).toString(); + pparams->setPlainText(data.section(";", 0, 0)); + pext->setText(data.section(";", 1, 1)); + } + if (d->exec() == QDialog::Accepted) { + m_configGroup->writeEntry(pname->text(), pparams->toPlainText() + ";" + pext->text()); + slotLoadProfiles(); + } + delete d; +} + +void EncodingProfilesDialog::slotEditProfile() +{ + QDialog *d = new QDialog(this); + QVBoxLayout *l = new QVBoxLayout; + l->addWidget(new QLabel(i18n("Profile name:"))); + QLineEdit *pname = new QLineEdit; + l->addWidget(pname); + l->addWidget(new QLabel(i18n("Parameters:"))); + QPlainTextEdit *pparams = new QPlainTextEdit; + l->addWidget(pparams); + l->addWidget(new QLabel(i18n("File extension:"))); + QLineEdit *pext = new QLineEdit; + l->addWidget(pext); + QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel); + connect(box, SIGNAL(accepted()), d, SLOT(accept())); + connect(box, SIGNAL(rejected()), d, SLOT(reject())); + l->addWidget(box); + d->setLayout(l); + + QListWidgetItem *item = profile_list->currentItem(); + if (item) { + pname->setText(item->text()); + QString data = item->data(Qt::UserRole).toString(); + pparams->setPlainText(data.section(";", 0, 0)); + pext->setText(data.section(";", 1, 1)); + pparams->setFocus(); + } + if (d->exec() == QDialog::Accepted) { + m_configGroup->writeEntry(pname->text(), pparams->toPlainText() + ";" + pext->text()); + slotLoadProfiles(); + } + delete d; +} + diff --git a/src/encodingprofilesdialog.h b/src/encodingprofilesdialog.h new file mode 100644 index 00000000..50b9a410 --- /dev/null +++ b/src/encodingprofilesdialog.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef ENCODINGPROFILESDIALOG_H +#define ENCODINGPROFILESDIALOG_H + + +#include "definitions.h" +#include "ui_manageencodingprofile_ui.h" + +class EncodingProfilesDialog : public QDialog, Ui::ManageEncodingProfile_UI +{ + Q_OBJECT + +public: + EncodingProfilesDialog(int profileType, QWidget * parent = 0); + ~EncodingProfilesDialog(); + +protected: + +private slots: + void slotLoadProfiles(); + void slotShowParams(); + void slotDeleteProfile(); + void slotAddProfile(); + void slotEditProfile(); + +private: + KConfig *m_configFile; + KConfigGroup *m_configGroup; +}; + + +#endif + diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 41720563..bac9fb88 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -117,6 +117,11 @@ ts + + + 0 + + -f mpegts -acodec libmp3lame -ac 2 -ab 92k -ar 48000 -vcodec mpeg2video -g 5 -deinterlace -s 480x270 -b 150k @@ -329,12 +334,12 @@ - f=mpeg acodec=mp2 ab=128k ar=48000 vcodec=mpeg2video minrate=0 b=4000k bf=2 b_strategy=1 trellis=1 + f=mpeg acodec=mp2 ab=128k ar=48000 vcodec=mpeg2video minrate=0 b=4000k - mpeg + mpg @@ -346,6 +351,11 @@ false + + + + 0 + @@ -477,25 +487,30 @@ - + 0 - - - + + + 0 - + capture - - - - true - + + + + vcodec=mpeg2video minrate=0 b=12000k acodec=mp2 ab=128k ar=48000 threads=2 + + + + + mpg + diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index c87fe9ca..83518f73 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -21,6 +21,7 @@ #include "profilesdialog.h" #include "v4l/v4lcapture.h" #include "blackmagic/devices.h" +#include "encodingprofilesdialog.h" #include "kdenlivesettings.h" #include @@ -68,7 +69,6 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map m_configProject.kcfg_proxyminsize->setEnabled(KdenliveSettings::generateproxy()); connect(m_configProject.kcfg_generateimageproxy, SIGNAL(toggled(bool)), m_configProject.kcfg_proxyimageminsize, SLOT(setEnabled(bool))); m_configProject.kcfg_proxyimageminsize->setEnabled(KdenliveSettings::generateimageproxy()); - m_configProject.kcfg_proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5); QWidget *p3 = new QWidget; m_configTimeline.setupUi(p3); @@ -94,7 +94,6 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map m_configCapture.setupUi(p4); #if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD) - m_configCapture.kcfg_v4l_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4); // Video 4 Linux device detection for (int i = 0; i < 10; i++) { @@ -194,6 +193,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication())); connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication())); + loadEncodingProfiles(); checkProfile(); slotUpdateDisplay(); @@ -215,9 +215,47 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap& map KdenliveSettings::setDvgrab_path(dvgrabpath); } - - BMInterface::getBlackMagicDeviceList(m_configCapture.kcfg_hdmi_capturedevice, m_configCapture.kcfg_hdmi_capturemode); - connect(m_configCapture.kcfg_hdmi_capturedevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateHDMIModes())); + // decklink profile + m_configCapture.decklink_showprofileinfo->setIcon(KIcon("help-about")); + m_configCapture.decklink_manageprofile->setIcon(KIcon("configure")); + m_configCapture.decklink_parameters->setVisible(false); + m_configCapture.decklink_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4); + m_configCapture.decklink_parameters->setPlainText(KdenliveSettings::decklink_parameters()); + connect(m_configCapture.decklink_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile())); + connect(m_configCapture.kcfg_decklink_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDecklinkProfile())); + connect(m_configCapture.decklink_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.decklink_parameters, SLOT(setVisible(bool))); + + // v4l profile + m_configCapture.v4l_showprofileinfo->setIcon(KIcon("help-about")); + m_configCapture.v4l_manageprofile->setIcon(KIcon("configure")); + m_configCapture.v4l_parameters->setVisible(false); + m_configCapture.v4l_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4); + m_configCapture.v4l_parameters->setPlainText(KdenliveSettings::v4l_parameters()); + connect(m_configCapture.v4l_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile())); + connect(m_configCapture.kcfg_v4l_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateV4lProfile())); + connect(m_configCapture.v4l_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.v4l_parameters, SLOT(setVisible(bool))); + + // proxy profile stuff + m_configProject.proxy_showprofileinfo->setIcon(KIcon("help-about")); + m_configProject.proxy_manageprofile->setIcon(KIcon("configure")); + m_configProject.proxyparams->setVisible(false); + m_configProject.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4); + m_configProject.proxyparams->setPlainText(KdenliveSettings::proxyparams()); + connect(m_configProject.proxy_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile())); + connect(m_configProject.proxy_showprofileinfo, SIGNAL(clicked(bool)), m_configProject.proxyparams, SLOT(setVisible(bool))); + connect(m_configProject.kcfg_proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyProfile())); + + + slotUpdateProxyProfile(-1); + slotUpdateV4lProfile(-1); + slotUpdateDecklinkProfile(-1); + + BMInterface::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice); + if (m_configCapture.kcfg_decklink_capturedevice->count() > 0) { + QStringList modes = m_configCapture.kcfg_decklink_capturedevice->itemData(m_configCapture.kcfg_decklink_capturedevice->currentIndex()).toStringList(); + m_configCapture.kcfg_decklink_capturedevice->setToolTip(i18n("Supported capture modes:\n") + modes.join("\n")); + } + connect(m_configCapture.kcfg_decklink_capturedevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateHDMIModes())); if (BMInterface::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device)) { // Found blackmagic card @@ -257,9 +295,8 @@ KdenliveSettingsDialog::~KdenliveSettingsDialog() {} void KdenliveSettingsDialog::slotUpdateHDMIModes() { - QStringList modes = m_configCapture.kcfg_hdmi_capturedevice->itemData(m_configCapture.kcfg_hdmi_capturedevice->currentIndex()).toStringList(); - m_configCapture.kcfg_hdmi_capturemode->clear(); - m_configCapture.kcfg_hdmi_capturemode->insertItems(0, modes); + QStringList modes = m_configCapture.kcfg_decklink_capturedevice->itemData(m_configCapture.kcfg_decklink_capturedevice->currentIndex()).toStringList(); + m_configCapture.kcfg_decklink_capturedevice->setToolTip(i18n("Supported capture modes:\n") + modes.join("\n")); } void KdenliveSettingsDialog::slotUpdateRmdRegionStatus() @@ -574,6 +611,23 @@ void KdenliveSettingsDialog::updateSettings() KdenliveSettings::setV4l_format(0); } + // Check encoding profiles + QString data = m_configCapture.kcfg_v4l_profile->itemData(m_configCapture.kcfg_v4l_profile->currentIndex()).toString(); + if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::v4l_parameters()) { + KdenliveSettings::setV4l_parameters(data.section(";", 0, 0)); + KdenliveSettings::setV4l_extension(data.section(";", 1, 1)); + } + data = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString(); + if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::decklink_parameters()) { + KdenliveSettings::setDecklink_parameters(data.section(";", 0, 0)); + KdenliveSettings::setDecklink_extension(data.section(";", 1, 1)); + } + data = m_configProject.kcfg_proxy_profile->itemData(m_configProject.kcfg_proxy_profile->currentIndex()).toString(); + if (!data.isEmpty() && data.section(";", 0, 0) != KdenliveSettings::proxyparams()) { + KdenliveSettings::setProxyparams(data.section(";", 0, 0)); + KdenliveSettings::setProxyextension(data.section(";", 1, 1)); + } + if (updateCapturePath) emit updateCaptureFolder(); @@ -633,18 +687,6 @@ void KdenliveSettingsDialog::updateSettings() resetProfile = true; } - if (m_configProject.kcfg_enableproxy->isChecked() != KdenliveSettings::enableproxy()) { - KdenliveSettings::setEnableproxy(m_configProject.kcfg_enableproxy->isChecked()); - } - - if (m_configProject.kcfg_generateproxy->isChecked() != KdenliveSettings::generateproxy()) { - KdenliveSettings::setGenerateproxy(m_configProject.kcfg_generateproxy->isChecked()); - } - - if (m_configProject.kcfg_proxyminsize->value() != KdenliveSettings::proxyminsize()) { - KdenliveSettings::setProxyminsize(m_configProject.kcfg_proxyminsize->value()); - } - if (m_modified) { // The transcoding profiles were modified, save. m_modified = false; @@ -870,6 +912,105 @@ void KdenliveSettingsDialog::saveCurrentV4lProfile() ProfilesDialog::saveProfile(profile, vl4ProfilePath); } +void KdenliveSettingsDialog::slotManageEncodingProfile() +{ + int type = 0; + if (currentPage() == m_page4) { + if (m_configCapture.tabWidget->currentIndex() == 1) type = 1; + else if (m_configCapture.tabWidget->currentIndex() == 3) type = 2; + } + EncodingProfilesDialog *d = new EncodingProfilesDialog(type); + d->exec(); + delete d; + loadEncodingProfiles(); +} + +void KdenliveSettingsDialog::loadEncodingProfiles() +{ + QString profileFile = KStandardDirs::locateLocal("appdata", "encodingprofiles.rc"); + KConfig conf(profileFile, KConfig::SimpleConfig); + if (!QFile::exists(profileFile)) { + KConfigGroup g1(&conf, "video4linux"); + g1.writeEntry("Normal MPEG", KdenliveSettings::v4l_parameters() + ";" + KdenliveSettings::v4l_extension()); + KConfigGroup g2(&conf, "decklink"); + g2.writeEntry("Normal MPEG", KdenliveSettings::decklink_parameters() + ";" + KdenliveSettings::decklink_extension()); + KConfigGroup g3(&conf, "proxy"); + g3.writeEntry("Normal MPEG", KdenliveSettings::proxyparams() + ";" + KdenliveSettings::proxyextension()); + } + + // Load v4l profiles + m_configCapture.kcfg_v4l_profile->blockSignals(true); + QString currentItem = m_configCapture.kcfg_v4l_profile->currentText(); + m_configCapture.kcfg_v4l_profile->clear(); + KConfigGroup group(&conf, "video4linux"); + QMap< QString, QString > values = group.entryMap(); + QMapIterator i(values); + while (i.hasNext()) { + i.next(); + if (!i.key().isEmpty()) m_configCapture.kcfg_v4l_profile->addItem(i.key(), i.value()); + } + m_configCapture.kcfg_v4l_profile->blockSignals(false); + if (!currentItem.isEmpty()) m_configCapture.kcfg_v4l_profile->setCurrentIndex(m_configCapture.kcfg_v4l_profile->findText(currentItem)); + + // Load Decklink profiles + m_configCapture.kcfg_decklink_profile->blockSignals(true); + currentItem = m_configCapture.kcfg_decklink_profile->currentText(); + m_configCapture.kcfg_decklink_profile->clear(); + KConfigGroup group2(&conf, "decklink"); + values = group2.entryMap(); + QMapIterator j(values); + while (j.hasNext()) { + j.next(); + if (!j.key().isEmpty()) m_configCapture.kcfg_decklink_profile->addItem(j.key(), j.value()); + } + m_configCapture.kcfg_decklink_profile->blockSignals(false); + if (!currentItem.isEmpty()) m_configCapture.kcfg_decklink_profile->setCurrentIndex(m_configCapture.kcfg_decklink_profile->findText(currentItem)); + + // Load Proxy profiles + m_configProject.kcfg_proxy_profile->blockSignals(true); + currentItem = m_configProject.kcfg_proxy_profile->currentText(); + m_configProject.kcfg_proxy_profile->clear(); + KConfigGroup group3(&conf, "proxy"); + values = group3.entryMap(); + QMapIterator k(values); + while (k.hasNext()) { + k.next(); + if (!k.key().isEmpty()) m_configProject.kcfg_proxy_profile->addItem(k.key(), k.value()); + } + m_configProject.kcfg_proxy_profile->blockSignals(false); + if (!currentItem.isEmpty()) m_configProject.kcfg_proxy_profile->setCurrentIndex(m_configProject.kcfg_proxy_profile->findText(currentItem)); +} + +void KdenliveSettingsDialog::slotUpdateDecklinkProfile(int ix) +{ + if (ix == -1) ix = KdenliveSettings::decklink_profile(); + else ix = m_configCapture.kcfg_decklink_profile->currentIndex(); + QString data = m_configCapture.kcfg_decklink_profile->itemData(ix).toString(); + if (data.isEmpty()) return; + m_configCapture.decklink_parameters->setPlainText(data.section(";", 0, 0)); + // +} + +void KdenliveSettingsDialog::slotUpdateV4lProfile(int ix) +{ + if (ix == -1) ix = KdenliveSettings::v4l_profile(); + else ix = m_configCapture.kcfg_v4l_profile->currentIndex(); + QString data = m_configCapture.kcfg_v4l_profile->itemData(ix).toString(); + if (data.isEmpty()) return; + m_configCapture.v4l_parameters->setPlainText(data.section(";", 0, 0)); + // +} + +void KdenliveSettingsDialog::slotUpdateProxyProfile(int ix) +{ + if (ix == -1) ix = KdenliveSettings::v4l_profile(); + else ix = m_configProject.kcfg_proxy_profile->currentIndex(); + QString data = m_configProject.kcfg_proxy_profile->itemData(ix).toString(); + if (data.isEmpty()) return; + m_configProject.proxyparams->setPlainText(data.section(";", 0, 0)); + // +} + #include "kdenlivesettingsdialog.moc" diff --git a/src/kdenlivesettingsdialog.h b/src/kdenlivesettingsdialog.h index e305d870..7692fc07 100644 --- a/src/kdenlivesettingsdialog.h +++ b/src/kdenlivesettingsdialog.h @@ -71,6 +71,10 @@ private slots: void slotUpdateHDMIModes(); void slotUpdatev4lDevice(); void slotUpdatev4lCaptureProfile(); + void slotManageEncodingProfile(); + void slotUpdateDecklinkProfile(int ix = 0); + void slotUpdateProxyProfile(int ix = 0); + void slotUpdateV4lProfile(int ix = 0); private: KPageWidgetItem *m_page1; @@ -101,6 +105,7 @@ private: void saveTranscodeProfiles(); void loadCurrentV4lProfileInfo(); void saveCurrentV4lProfile(); + void loadEncodingProfiles(); signals: void customChanged(); diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index 07063312..172dd432 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -163,6 +163,7 @@ void MltDeviceCapture::buildConsumer(const QString &profileName) void MltDeviceCapture::stop() { bool isPlaylist = false; + m_captureDisplayWidget->stop(); if (m_mltConsumer) { m_mltConsumer->set("refresh", 0); m_mltConsumer->stop(); @@ -346,7 +347,7 @@ void MltDeviceCapture::captureFrame(const QString &path) doCapture = 5; } -bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &path, const QString &playlist) +bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &path, const QString &playlist, bool xmlPlaylist) { stop(); if (m_mltProfile) delete m_mltProfile; @@ -381,7 +382,14 @@ bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &pa // FIXME: the event object returned by the listen gets leaked... m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) rec_consumer_frame_show); tmp = qstrdup(playlist.toUtf8().constData()); - m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", tmp); + if (xmlPlaylist) { + // create an xml producer + m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", tmp); + } + else { + // create a producer based on mltproducer parameter + m_mltProducer = new Mlt::Producer(*m_mltProfile, tmp); + } delete[] tmp; if (m_mltProducer == NULL || !m_mltProducer->is_valid()) { @@ -395,6 +403,7 @@ bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &pa m_mltConsumer = NULL; return 0; } + m_captureDisplayWidget->start(); return 1; } diff --git a/src/mltdevicecapture.h b/src/mltdevicecapture.h index da341ebc..158b7159 100644 --- a/src/mltdevicecapture.h +++ b/src/mltdevicecapture.h @@ -76,7 +76,7 @@ Q_OBJECT public: /** @brief Starts the MLT Video4Linux process. * @param surface The widget onto which the frame should be painted */ - bool slotStartCapture(const QString ¶ms, const QString &path, const QString &playlist); + bool slotStartCapture(const QString ¶ms, const QString &path, const QString &playlist, bool xmlPlaylist = true); bool slotStartPreview(const QString &producer, bool xmlFormat = false); /** @brief A frame arrived from the MLT Video4Linux process. */ void gotCapturedFrame(Mlt::Frame& frame); diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index af5a14cd..0c5e1a87 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -64,14 +64,12 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor) void MonitorManager::activateMonitor(QString name) { - kDebug()<<"//ACTIVATING MON: "<name() == name) return; m_activeMonitor = NULL; for (int i = 0; i < m_monitorsList.count(); i++) { - kDebug()<<"PARSING: "<name(); if (m_monitorsList.at(i)->name() == name) { m_activeMonitor = m_monitorsList.at(i); emit raiseMonitor(m_activeMonitor); diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index 1e239b49..8149d5d1 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -247,7 +247,7 @@ void RecMonitor::slotVideoDeviceChanged(int ix) capturefile = m_capturePath; if (!capturefile.endsWith("/")) capturefile.append("/"); - capturename = KdenliveSettings::hdmifilename(); + capturename = KdenliveSettings::decklink_filename(); capturename.append("xxx.raw"); capturefile.append(capturename); video_frame->setPixmap(mergeSideBySide(KIcon("camera-photo").pixmap(QSize(50, 50)), i18n("Plug your camcorder and\npress play button\nto start preview.\nFiles will be saved in:\n%1", capturefile))); @@ -520,7 +520,7 @@ void RecMonitor::slotStartCapture(bool play) m_manager->updateScopeSource(); } profile = ProfilesDialog::getVideoProfile(path); - producer = QString("decklink:%1").arg(KdenliveSettings::hdmi_capturedevice()); + producer = QString("decklink:%1").arg(KdenliveSettings::decklink_capturedevice()); if (!m_captureDevice->slotStartPreview(producer)) { // v4l capture failed to start video_frame->setText(i18n("Failed to start Decklink,\ncheck your parameters...")); @@ -531,7 +531,7 @@ void RecMonitor::slotStartCapture(bool play) m_playAction->setEnabled(false); m_stopAction->setEnabled(true); } - //m_bmCapture->startPreview(KdenliveSettings::hdmi_capturedevice(), KdenliveSettings::hdmi_capturemode()); + //m_bmCapture->startPreview(KdenliveSettings::decklink_capturedevice(), KdenliveSettings::hdmi_capturemode()); m_playAction->setEnabled(false); m_stopAction->setEnabled(true); m_recAction->setEnabled(true); @@ -580,6 +580,7 @@ void RecMonitor::slotRecord() m_recAction->setChecked(false); break; case VIDEO4LINUX: + case BLACKMAGIC: slotStopCapture(); m_isCapturing = false; m_recAction->setChecked(false); @@ -606,9 +607,10 @@ void RecMonitor::slotRecord() } if (m_captureProcess->state() == QProcess::NotRunning) { m_recAction->setChecked(true); - QString extension = "mp4"; + QString extension = "mpg"; if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension(); else if (device_selector->currentIndex() == VIDEO4LINUX) extension = KdenliveSettings::v4l_extension(); + else if (device_selector->currentIndex() == BLACKMAGIC) extension = KdenliveSettings::decklink_extension(); QString path = KUrl(m_capturePath).path(KUrl::AddTrailingSlash) + "capture0000." + extension; int i = 1; while (QFile::exists(path)) { @@ -683,9 +685,9 @@ void RecMonitor::slotRecord() m_manager->updateScopeSource(); } - playlist = QString("producer100000pause%1decklink").arg(KdenliveSettings::hdmi_capturedevice()); + playlist = QString("producer100000pause%1decklink").arg(KdenliveSettings::decklink_capturedevice()); - if (m_captureDevice->slotStartCapture(KdenliveSettings::v4l_parameters(), m_captureFile.path(), playlist)) { + if (m_captureDevice->slotStartCapture(KdenliveSettings::decklink_parameters(), m_captureFile.path(), QString("decklink:%1").arg(KdenliveSettings::decklink_capturedevice()), false)) { m_videoBox->setHidden(false); m_isCapturing = true; } diff --git a/src/stopmotion/stopmotion.cpp b/src/stopmotion/stopmotion.cpp index 28ce8a89..6d473277 100644 --- a/src/stopmotion/stopmotion.cpp +++ b/src/stopmotion/stopmotion.cpp @@ -251,7 +251,7 @@ StopmotionWidget::StopmotionWidget(MonitorManager *manager, KUrl projectFolder, layout->addWidget(m_videoBox); - if (BMInterface::getBlackMagicDeviceList(capture_device, NULL)) { + if (BMInterface::getBlackMagicDeviceList(capture_device)) { // Found a BlackMagic device } if (QFile::exists(KdenliveSettings::video4vdevice())) { diff --git a/src/widgets/configcapture_ui.ui b/src/widgets/configcapture_ui.ui index 2697db9f..b8c838b6 100644 --- a/src/widgets/configcapture_ui.ui +++ b/src/widgets/configcapture_ui.ui @@ -7,7 +7,7 @@ 0 0 405 - 563 + 532 @@ -181,30 +181,40 @@ Video4Linux - + Detected devices - + - + Video device - + + + + + Capture format + + + + + + @@ -212,70 +222,77 @@ - + 720x576 - + + + + Frame rate: + + + + 25/1 - + Pixel aspect ratio: - + 59/54 - + Display aspect ratio: - + 4/3 - + Colorspace - + - + Interlaced - + Qt::Horizontal @@ -288,29 +305,36 @@ - + Edit - + Qt::Horizontal - + + + + Capture audio (ALSA) + + + + Qt::Horizontal - - + + 0 @@ -318,21 +342,34 @@ - Encoding parameters + Encoding profile - - + + + + + 0 + 0 + + + + + + 0 0 + + true + - + Qt::Vertical @@ -345,54 +382,33 @@ - - - - File extension - - - - - - - 5 + + + + false - - - - - - Capture format + + + 0 + 0 + - - - - - + + - Frame rate: + ... - - + + - Capture audio (ALSA) + ... - - - - - - false - - - - 0 - 0 - + + true @@ -789,7 +805,7 @@ Blackmagic - + @@ -797,8 +813,8 @@ - - + + 0 @@ -807,27 +823,30 @@ - - - - Capture mode + + + + + 0 + 0 + + + + true - - - - + Capture file name - - + + - + Qt::Vertical @@ -840,10 +859,43 @@ - - + + + + + 0 + 0 + + - Capture audio + Encoding profile + + + + + + + + 0 + 0 + + + + + + + + ... + + + + + + + ... + + + true diff --git a/src/widgets/configproject_ui.ui b/src/widgets/configproject_ui.ui index 1b0d0b5b..03e948fd 100644 --- a/src/widgets/configproject_ui.ui +++ b/src/widgets/configproject_ui.ui @@ -6,8 +6,8 @@ 0 0 - 333 - 353 + 329 + 332 @@ -151,14 +151,14 @@ false - + Generate for videos larger than - + pixels @@ -171,14 +171,14 @@ - + Generate for images larger than - + pixels @@ -194,34 +194,56 @@ - - + + + + + 0 + 0 + + - FFmpeg video transcoding parameters + Encoding profile - - + + - + 0 0 - - + + - File extension + ... + + + true - - + + - avi + ... + + + + + + + + 0 + 0 + + + + true @@ -249,11 +271,6 @@ QSpinBox
knuminput.h
- - KLineEdit - QLineEdit -
klineedit.h
-
KComboBox QComboBox diff --git a/src/widgets/manageencodingprofile_ui.ui b/src/widgets/manageencodingprofile_ui.ui new file mode 100644 index 00000000..cd7ed216 --- /dev/null +++ b/src/widgets/manageencodingprofile_ui.ui @@ -0,0 +1,136 @@ + + + ManageEncodingProfile_UI + + + + 0 + 0 + 444 + 337 + + + + Dialog + + + + + + Editing profiles for + + + + + + + + + + true + + + + + + + true + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + Qt::Horizontal + + + + 155 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+
+ + + + buttonBox + accepted() + ManageEncodingProfile_UI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ManageEncodingProfile_UI + reject() + + + 316 + 260 + + + 286 + 274 + + + + +