From: Jean-Baptiste Mardelle Date: Sun, 26 Oct 2008 15:46:54 +0000 (+0000) Subject: Allow audio capture through alsa for screen grabs. Should fix issue: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=55582dfa34f62d6d5df3ba28606dee10a2d69d46;p=kdenlive Allow audio capture through alsa for screen grabs. Should fix issue: http://www.kdenlive.org:80/mantis/view.php?id=248 svn path=/branches/KDE4/; revision=2570 --- diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index f17946a4..a7606ad6 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -208,19 +208,34 @@ false - + + + false + + + -f oss -i /dev/dsp + + + arecord -Dplughw:0 -c1 -q -r41000 -traw -fS16_LE - + + + + + -f s16le -i - -acodec copy + + - -f x11grab -r 15 -s %size -i :0.0%offset + -f x11grab -r 10 -s %size -i :0.0%offset - -vcodec mpeg4 + -pix_fmt yuv422p -vcodec huffyuv diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index 73b07d20..39b5aa39 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -98,6 +98,10 @@ 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))); + + m_configCapture.audio_group->setVisible(KdenliveSettings::screengrabenableaudio()); + connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication())); connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication())); connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication())); diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index b8d6ce71..9dae2933 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -85,6 +85,7 @@ 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))); @@ -118,6 +119,12 @@ RecMonitor::RecMonitor(QString name, QWidget *parent) kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId(); } +RecMonitor::~RecMonitor() { + delete captureProcess; + delete displayProcess; + delete alsaProcess; +} + QString RecMonitor::name() const { return m_name; } @@ -364,12 +371,16 @@ void RecMonitor::slotRecord() { m_recAction->setChecked(false); break; case VIDEO4LINUX: + captureProcess->terminate(); slotStopCapture(); //m_isCapturing = false; QTimer::singleShot(1000, this, SLOT(slotStartCapture())); break; case SCREENGRAB: captureProcess->write("q\n", 3); + captureProcess->terminate(); + alsaProcess->terminate(); + alsaProcess->kill(); // in case ffmpeg doesn't exit with the 'q' command, kill it one second later QTimer::singleShot(1000, captureProcess, SLOT(kill())); break; @@ -416,14 +427,20 @@ void RecMonitor::slotRecord() { 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()); - kDebug() << "// capture params: " << args; if (KdenliveSettings::screengrabenableaudio()) { // also capture audio - m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' '); + 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); + const QString alsaBinary = alsaArgs.takeFirst(); + alsaProcess->start(alsaBinary, alsaArgs); + } captureProcess->start("ffmpeg", m_captureArgs); } else { ui.video_frame->setText(i18n("Select region...")); @@ -445,6 +462,7 @@ void RecMonitor::slotRecord() { // stop capture displayProcess->kill(); captureProcess->kill(); + alsaProcess->kill(); QTimer::singleShot(1000, this, SLOT(slotRecord())); } } @@ -459,14 +477,19 @@ void RecMonitor::slotStartGrab(const QRect &rect) { if (width % 2 != 0) width--; if (height % 2 != 0) height--; QString args = KdenliveSettings::screengrabcapture().replace("%size", QString::number(width) + "x" + QString::number(height)).replace("%offset", "+" + QString::number(rect.x()) + "," + QString::number(rect.y())); - kDebug() << "// capture params: " << args; if (KdenliveSettings::screengrabenableaudio()) { // also capture audio - m_captureArgs << KdenliveSettings::screengrabaudiocapture().simplified().split(' '); + 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(); m_isCapturing = true; ui.video_frame->setText(i18n("Capturing...")); + if (KdenliveSettings::screengrabenableaudio() && !KdenliveSettings::useosscapture()) { + QStringList alsaArgs = KdenliveSettings::screengrabalsacapture().simplified().split(' '); + alsaProcess->setStandardOutputProcess(captureProcess); + alsaProcess->start(alsaArgs.takeFirst(), alsaArgs); + } captureProcess->start("ffmpeg", m_captureArgs); } diff --git a/src/recmonitor.h b/src/recmonitor.h index 6b89ae25..855acb13 100644 --- a/src/recmonitor.h +++ b/src/recmonitor.h @@ -40,6 +40,8 @@ class RecMonitor : public QWidget { public: RecMonitor(QString name, QWidget *parent = 0); + virtual ~RecMonitor(); + QString name() const; enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2}; @@ -61,6 +63,7 @@ private: QProcess *captureProcess; QProcess *displayProcess; + QProcess *alsaProcess; QTimer *m_initTimer; bool m_isCapturing; /** did the user capture something ? */ diff --git a/src/widgets/configcapture_ui.ui b/src/widgets/configcapture_ui.ui index e2ac9889..439d2d2f 100644 --- a/src/widgets/configcapture_ui.ui +++ b/src/widgets/configcapture_ui.ui @@ -5,8 +5,8 @@ 0 0 - 446 - 312 + 409 + 311 @@ -45,7 +45,7 @@ - 0 + 2 @@ -354,28 +354,63 @@ Screen Grab / FFmpeg - - + + Capture audio - - + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + ALSA + + + true + + + + + + + + + + + + + OSS + + + + + + + + - + Video capture params - + - + @@ -388,7 +423,7 @@ - + @@ -401,7 +436,7 @@ - + @@ -414,7 +449,7 @@ - + @@ -427,14 +462,14 @@ - + Full screen capture - + Qt::Vertical @@ -452,6 +487,9 @@ + label + kcfg_defaultcapture + tabWidget