From 7d58b3e254099385f5d4834eef6dee6bd8d1c424 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 15 Nov 2008 21:51:33 +0000 Subject: [PATCH] Screen grab now uses recordmydesktop svn path=/branches/KDE4/; revision=2704 --- src/kdenlivesettings.kcfg | 85 +++++++---- src/kdenlivesettingsdialog.cpp | 39 ++++- src/kdenlivesettingsdialog.h | 2 +- src/recmonitor.cpp | 72 ++++----- src/recmonitor.h | 3 +- src/widgets/configcapture_ui.ui | 256 ++++++++++++++++++++++---------- 6 files changed, 311 insertions(+), 146 deletions(-) diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 1e42c176..4aac71c6 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -70,7 +70,9 @@ 0 + + 0 @@ -203,53 +205,84 @@ - - - false + + + + + + + + + true - + false - - - -f oss -i /dev/dsp + + + system:capture_1 - - - -Dplughw:0 -c1 -q -r41000 -traw -fS16_LE - + + + 0 - - - -f s16le -i - -acodec copy + + + 0 - - - -f x11grab -r 10 -s %size -i :0.0%offset + + + false - - - -pix_fmt yuv422p -vcodec huffyuv + + + 1 - - - avi + + + 1 - - + + + 1280 + + + + + 720 + + + + + 1 + + + + + 15.0 + + + + false - - + + + + + + + diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index da997ca3..b95ce62c 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -98,9 +98,9 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog( connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands())); connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands())); - connect(m_configCapture.kcfg_screengrabenableaudio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool))); + connect(m_configCapture.kcfg_rmd_capture_audio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool))); - m_configCapture.audio_group->setVisible(KdenliveSettings::screengrabenableaudio()); + m_configCapture.audio_group->setVisible(KdenliveSettings::rmd_capture_audio()); connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication())); connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication())); @@ -116,12 +116,16 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog( } checkProfile(); - slotUpdateDisplay(); - m_audioDevice = KdenliveSettings::audio_device(); + initDevices(); connect(m_configMisc.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay())); + connect(m_configCapture.kcfg_rmd_capture_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateRmdRegionStatus())); + + slotUpdateRmdRegionStatus(); + + //HACK: check dvgrab version, because only dvgrab >= 3.3 supports // --timestamp option without bug double dvgrabVersion = 0; @@ -133,6 +137,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog( QString version = QString(versionCheck->readAll()).simplified(); if (version.contains(' ')) version = version.section(' ', -1); dvgrabVersion = version.toDouble(); + kDebug() << "// FOUND DVGRAB VERSION: " << dvgrabVersion; } if (versionCheck) delete versionCheck; @@ -140,10 +145,22 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog( KdenliveSettings::setFirewiretimestamp(false); m_configCapture.kcfg_firewiretimestamp->setEnabled(false); } + + QString rmdpath = KStandardDirs::findExe("recordmydesktop"); + if (rmdpath.isEmpty()) { + KdenliveSettings::setRmd_path(QString()); + m_configCapture.rmd_info->setText(i18n("Recordmydesktop utility not found, please install it for screen grabs")); + } else { + KdenliveSettings::setRmd_path(rmdpath); + m_configCapture.rmd_info->setText(i18n("Recordmydesktop found at: %1", rmdpath)); + } } KdenliveSettingsDialog::~KdenliveSettingsDialog() {} +void KdenliveSettingsDialog::slotUpdateRmdRegionStatus() { + m_configCapture.region_group->setHidden(m_configCapture.kcfg_rmd_capture_type->currentIndex() != 1); +} void KdenliveSettingsDialog::checkProfile() { if (!KdenliveSettings::default_profile().isEmpty()) { @@ -186,6 +203,7 @@ void KdenliveSettingsDialog::initDevices() { // Fill the list of audio playback devices m_configSdl.kcfg_audio_device->addItem(i18n("Default"), QString()); + m_configCapture.kcfg_rmd_alsa_device->addItem(i18n("Default"), QString()); if (KStandardDirs::findExe("aplay") != QString::null) { m_readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel); m_readProcess.setProgram("aplay", QStringList() << "-l"); @@ -197,12 +215,17 @@ void KdenliveSettingsDialog::initDevices() { if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); QString line; + QString deviceId; while (!stream.atEnd()) { line = stream.readLine(); if (line.contains("playback")) { - QString deviceId = line.section(":", 0, 0); + deviceId = line.section(":", 0, 0); m_configSdl.kcfg_audio_device->addItem(line.section(":", 1, 1), "plughw:" + QString::number(deviceId.section("-", 0, 0).toInt()) + "," + QString::number(deviceId.section("-", 1, 1).toInt())); } + if (line.contains("capture")) { + deviceId = line.section(":", 0, 0); + m_configCapture.kcfg_rmd_alsa_device->addItem(line.section(":", 1, 1), "plughw:" + QString::number(deviceId.section("-", 0, 0).toInt()) + "," + QString::number(deviceId.section("-", 1, 1).toInt())); + } } file.close(); } @@ -221,6 +244,7 @@ void KdenliveSettingsDialog::slotReadAudioDevices() { QString card = data.section(":", 0, 0).section(" ", -1); QString device = data.section(":", 1, 1).section(" ", -1); m_configSdl.kcfg_audio_device->addItem(data.section(":", -1), "plughw:" + card + "," + device); + m_configCapture.kcfg_rmd_alsa_device->addItem(data.section(":", -1), "plughw:" + card + "," + device); } } } @@ -344,6 +368,11 @@ void KdenliveSettingsDialog::updateSettings() { resetProfile = true; } + value = m_configCapture.kcfg_rmd_alsa_device->itemData(m_configCapture.kcfg_rmd_alsa_device->currentIndex()).toString(); + if (value != KdenliveSettings::rmd_alsadevicename()) { + KdenliveSettings::setRmd_alsadevicename(value); + } + value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString(); if (value != KdenliveSettings::audiodrivername()) { KdenliveSettings::setAudiodrivername(value); diff --git a/src/kdenlivesettingsdialog.h b/src/kdenlivesettingsdialog.h index 48352967..640ef953 100644 --- a/src/kdenlivesettingsdialog.h +++ b/src/kdenlivesettingsdialog.h @@ -56,6 +56,7 @@ private slots: void slotEditAudioApplication(); void slotEditVideoApplication(); void slotReadAudioDevices(); + void slotUpdateRmdRegionStatus(); private: KPageWidgetItem *page1; @@ -77,7 +78,6 @@ private: QString m_defaultPath; KProcess m_readProcess; void initDevices(); - uint m_audioDevice; signals: void customChanged(); diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index 828a5ea8..4160d102 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -85,7 +85,6 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) slotVideoDeviceChanged(ui.device_selector->currentIndex()); displayProcess = new QProcess; captureProcess = new QProcess; - alsaProcess = new QProcess; connect(captureProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(slotProcessStatus(QProcess::ProcessState))); @@ -123,7 +122,6 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) RecMonitor::~RecMonitor() { delete captureProcess; delete displayProcess; - delete alsaProcess; } QString RecMonitor::name() const { @@ -143,6 +141,11 @@ void RecMonitor::slotVideoDeviceChanged(int ix) { m_recAction->setEnabled(true); m_stopAction->setEnabled(false); m_playAction->setEnabled(false); + if (KdenliveSettings::rmd_path().isEmpty()) { + QString rmdpath = KStandardDirs::findExe("recordmydesktop"); + if (rmdpath.isEmpty()) ui.video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("Recordmydesktop utility not found, please install it for screen grabs"))); + else KdenliveSettings::setRmd_path(rmdpath); + } ui.video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder()))); //ui.video_frame->setText(i18n("Press record button\nto start screen capture")); break; @@ -381,12 +384,11 @@ void RecMonitor::slotRecord() { QTimer::singleShot(1000, this, SLOT(slotStartCapture())); break; case SCREENGRAB: - captureProcess->write("q\n", 3); + //captureProcess->write("q\n", 3); captureProcess->terminate(); - alsaProcess->terminate(); - alsaProcess->kill(); + ui.video_frame->setText(i18n("Encoding captured video...")); // in case ffmpeg doesn't exit with the 'q' command, kill it one second later - QTimer::singleShot(1000, captureProcess, SLOT(kill())); + //QTimer::singleShot(1000, captureProcess, SLOT(kill())); break; } return; @@ -399,7 +401,7 @@ void RecMonitor::slotRecord() { if (captureProcess->state() == QProcess::NotRunning) { m_recAction->setChecked(true); QString extension = "mpg"; - if (ui.device_selector->currentIndex() == SCREENGRAB) extension = KdenliveSettings::screengrabextension(); + if (ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension(); QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension; int i = 1; while (QFile::exists(path)) { @@ -430,36 +432,35 @@ void RecMonitor::slotRecord() { captureProcess->start("ffmpeg", m_captureArgs); break; case SCREENGRAB: - if (KdenliveSettings::fullscreengrab()) { - const QRect rect = QApplication::desktop()->screenGeometry(); - args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(rect.width()) + "x" + QString::number(rect.height())).replace("%offset", QString()); - if (KdenliveSettings::screengrabenableaudio()) { - // also capture audio - if (KdenliveSettings::useosscapture()) m_captureArgs << KdenliveSettings::screengrabosscapture().simplified().split(' '); - else m_captureArgs << KdenliveSettings::screengrabalsacapture2().simplified().split(' '); - } - m_captureArgs << args.simplified().split(' ') << KdenliveSettings::screengrabencoding().simplified().split(' ') << m_captureFile.path(); - ui.video_frame->setText(i18n("Capturing...")); - m_isCapturing = true; - if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) { - QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' '); - alsaProcess->setStandardOutputProcess(captureProcess); - kDebug() << "Capture: Running arecord " << alsaArgs.join(" "); - alsaProcess->start("arecord", alsaArgs); - } - kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" "); - captureProcess->start("ffmpeg", m_captureArgs); - } else { - ui.video_frame->setText(i18n("Select region...")); - rgnGrab = new RegionGrabber(); - connect(rgnGrab, SIGNAL(regionGrabbed(const QRect&)), SLOT(slotStartGrab(const QRect &))); + switch (KdenliveSettings::rmd_capture_type()) { + case 0: + // Full screen capture, nothing special to do + break; + default: + // Region capture + m_captureArgs << "-width" << QString::number(KdenliveSettings::rmd_width()) << "-height" << QString::number(KdenliveSettings::rmd_height()); + if (!KdenliveSettings::rmd_follow_mouse()) { + m_captureArgs << "-x" << QString::number(KdenliveSettings::rmd_offsetx()) << "-y" << QString::number(KdenliveSettings::rmd_offsety()); + } else m_captureArgs << "--follow-mouse"; + break; } + m_isCapturing = true; + if (KdenliveSettings::rmd_capture_audio()) { + if (KdenliveSettings::rmd_use_jack()) m_captureArgs << "-use-jack" << KdenliveSettings::rmd_jackports(); + else if (!KdenliveSettings::rmd_alsadevicename().isEmpty()) + m_captureArgs << "-device" << KdenliveSettings::rmd_alsadevicename(); + } else m_captureArgs << "--no-sound"; + + if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots"; + m_captureArgs << "-fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path(); + captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs); + kDebug() << "// RecordMyDesktop params: " << m_captureArgs; break; default: break; } - //ui.video_frame->setScaledContents(false); + if (ui.device_selector->currentIndex() != SCREENGRAB) { m_isCapturing = true; kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" "); @@ -469,12 +470,12 @@ void RecMonitor::slotRecord() { } else { // stop capture displayProcess->kill(); - captureProcess->kill(); - alsaProcess->kill(); + //captureProcess->kill(); QTimer::singleShot(1000, this, SLOT(slotRecord())); } } +/* void RecMonitor::slotStartGrab(const QRect &rect) { rgnGrab->deleteLater(); QApplication::restoreOverrideCursor(); @@ -501,7 +502,7 @@ void RecMonitor::slotStartGrab(const QRect &rect) { } kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" "); captureProcess->start("ffmpeg", m_captureArgs); -} +}*/ void RecMonitor::slotProcessStatus(QProcess::ProcessState status) { if (status == QProcess::NotRunning) { @@ -524,7 +525,8 @@ void RecMonitor::slotProcessStatus(QProcess::ProcessState status) { if (captureProcess && captureProcess->exitStatus() == QProcess::CrashExit) { ui.video_frame->setText(i18n("Capture crashed, please check your parameters")); } else { - ui.video_frame->setText(i18n("Not connected")); + if (ui.device_selector->currentIndex() != SCREENGRAB) ui.video_frame->setText(i18n("Not connected")); + else ui.video_frame->setPixmap(mergeSideBySide(KIcon("video-display").pixmap(QSize(50, 50)), i18n("Press record button\nto start screen capture\nFiles will be saved in:\n%1", KdenliveSettings::capturefolder()))); } m_isCapturing = false; } else { diff --git a/src/recmonitor.h b/src/recmonitor.h index 855acb13..ba44c305 100644 --- a/src/recmonitor.h +++ b/src/recmonitor.h @@ -63,7 +63,6 @@ private: QProcess *captureProcess; QProcess *displayProcess; - QProcess *alsaProcess; QTimer *m_initTimer; bool m_isCapturing; /** did the user capture something ? */ @@ -90,7 +89,7 @@ private slots: void slotRewind(); void slotForward(); void slotDisconnect(); - void slotStartGrab(const QRect &rect); + //void slotStartGrab(const QRect &rect); void slotConfigure(); public slots: diff --git a/src/widgets/configcapture_ui.ui b/src/widgets/configcapture_ui.ui index 439d2d2f..3928b5f2 100644 --- a/src/widgets/configcapture_ui.ui +++ b/src/widgets/configcapture_ui.ui @@ -6,10 +6,10 @@ 0 0 409 - 311 + 411 - + @@ -49,17 +49,30 @@ - Firewire / dvgrab + Firewire - + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Capture format - + @@ -83,7 +96,7 @@ - + Qt::Horizontal @@ -96,21 +109,21 @@ - + Automatically start a new file on scene cut - + Add recording time to captured file name - + Qt::Vertical @@ -127,7 +140,7 @@ - Video4Linux / FFmpeg + Video4Linux @@ -348,21 +361,47 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - Screen Grab / FFmpeg + Screen Grab - - - + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + Capture audio - + QFrame::StyledPanel @@ -381,95 +420,151 @@ - - - - - - - + - OSS + Jack - - + + + + + + + + + + Ports: + + - - - - Video capture params - + + + + + Full screen capture + + + + + Region capture + + - - - - - - - - 0 - 0 - + + + + QFrame::StyledPanel - - Encoding parameters + + QFrame::Raised + + + + + 1 + + + 5000 + + + + + + + 1 + + + 5000 + + + + + + + 5000 + + + + + + + 5000 + + + + + + + Offset + + + + + + + Size + + + + + + + Follow mouse + + + + - - - - - 0 - 0 - - + + - + Audio channels - - - - - 0 - 0 - + + + + + + + Qt::Horizontal - - File extension + + + 86 + 26 + - + - - - - - 0 - 0 - - + + - + Frame rate - - + + + + + - Full screen capture + Full shots - + Qt::Vertical @@ -487,9 +582,6 @@ - label - kcfg_defaultcapture - tabWidget @@ -497,6 +589,16 @@ QComboBox
kcombobox.h
+ + KDoubleNumInput + QWidget +
knuminput.h
+
+ + KIntSpinBox + QSpinBox +
knuminput.h
+
KLineEdit QLineEdit -- 2.39.5