]> git.sesse.net Git - kdenlive/commitdiff
Allow audio capture through alsa for screen grabs. Should fix issue:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 26 Oct 2008 15:46:54 +0000 (15:46 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 26 Oct 2008 15:46:54 +0000 (15:46 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=248

svn path=/branches/KDE4/; revision=2570

src/kdenlivesettings.kcfg
src/kdenlivesettingsdialog.cpp
src/recmonitor.cpp
src/recmonitor.h
src/widgets/configcapture_ui.ui

index f17946a4eb9f133e49adc31383569f6991d0e0a2..a7606ad66dc2c72d0e65d0a12453eed9e5b8dc76 100644 (file)
       <default>false</default>
     </entry>
 
-    <entry name="screengrabaudiocapture" type="String">
+    <entry name="useosscapture" type="Bool">
+      <label>use ffmpeg oss audio capture instead of external program.</label>
+      <default>false</default>
+    </entry>
+
+    <entry name="screengrabosscapture" type="String">
       <label>ffmpeg arguments for x11 grab capture.</label>
       <default>-f oss -i /dev/dsp</default>
     </entry>
 
+    <entry name="screengrabalsacapture" type="String">
+      <label>external program audio capture piped into ffmpeg.</label>
+      <default>arecord -Dplughw:0 -c1 -q -r41000 -traw -fS16_LE -</default>
+    </entry>
+
+    <entry name="screengrabalsacapture2" type="String">
+      <label>external program audio capture piped into ffmpeg.</label>
+      <default>-f s16le -i - -acodec copy</default>
+    </entry>
+
     <entry name="screengrabcapture" type="String">
       <label>ffmpeg arguments for x11 grab capture.</label>
-      <default>-f x11grab -r 15 -s %size -i :0.0%offset</default>
+      <default>-f x11grab -r 10 -s %size -i :0.0%offset</default>
     </entry>
 
     <entry name="screengrabencoding" type="String">
       <label>ffmpeg arguments for x11 capture encoding.</label>
-      <default>-vcodec mpeg4</default>
+      <default>-pix_fmt yuv422p -vcodec huffyuv</default>
     </entry>
 
     <entry name="screengrabextension" type="String">
index 73b07d20de6bf802b3cbbad0701e0001b0ff2e8e..39b5aa39ccb7043256a439f641c73c2be2f28ce6 100644 (file)
@@ -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()));
index b8d6ce713ba9668a57b833b3fb1f24383b28f3a1..9dae2933e7382b427c66835751d5d613efed5ca6 100644 (file)
@@ -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);
 }
 
index 6b89ae255630eaac0c2eed61e641d7b21d2d382d..855acb13b5c04c5f63bfbbc10333606987d69043 100644 (file)
@@ -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 ? */
index e2ac988965a559c9d1abf48e03586f23b6ad72d9..439d2d2f81ebcf325a9084fdfa4691b8acbd6748 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>446</width>
-    <height>312</height>
+    <width>409</width>
+    <height>311</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout_3" >
@@ -45,7 +45,7 @@
       </size>
      </property>
      <property name="currentIndex" >
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="tab" >
       <attribute name="title" >
       <attribute name="title" >
        <string>Screen Grab / FFmpeg</string>
       </attribute>
-      <layout class="QGridLayout" name="gridLayout_4" >
-       <item row="0" column="0" >
+      <layout class="QGridLayout" name="gridLayout_5" >
+       <item row="0" column="0" colspan="2" >
         <widget class="QCheckBox" name="kcfg_screengrabenableaudio" >
          <property name="text" >
           <string>Capture audio</string>
          </property>
         </widget>
        </item>
-       <item row="0" column="2" >
-        <widget class="KLineEdit" name="kcfg_screengrabaudiocapture" />
+       <item row="1" column="0" colspan="3" >
+        <widget class="QFrame" name="audio_group" >
+         <property name="frameShape" >
+          <enum>QFrame::StyledPanel</enum>
+         </property>
+         <property name="frameShadow" >
+          <enum>QFrame::Raised</enum>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_4" >
+          <item row="0" column="0" >
+           <widget class="QRadioButton" name="radioButton_2" >
+            <property name="text" >
+             <string>ALSA</string>
+            </property>
+            <property name="checked" >
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1" >
+           <widget class="KLineEdit" name="kcfg_screengrabalsacapture" />
+          </item>
+          <item row="0" column="2" >
+           <widget class="KLineEdit" name="kcfg_screengrabalsacapture2" />
+          </item>
+          <item row="1" column="0" >
+           <widget class="QRadioButton" name="kcfg_useosscapture" >
+            <property name="text" >
+             <string>OSS</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1" colspan="2" >
+           <widget class="KLineEdit" name="kcfg_screengrabosscapture" />
+          </item>
+         </layout>
+        </widget>
        </item>
-       <item row="1" column="0" colspan="2" >
+       <item row="2" column="0" colspan="2" >
         <widget class="QLabel" name="label_17" >
          <property name="text" >
           <string>Video capture params</string>
          </property>
         </widget>
        </item>
-       <item row="1" column="2" >
+       <item row="2" column="2" >
         <widget class="KLineEdit" name="kcfg_screengrabcapture" />
        </item>
-       <item row="2" column="0" >
+       <item row="3" column="0" colspan="2" >
         <widget class="QLabel" name="label_8" >
          <property name="sizePolicy" >
           <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
          </property>
         </widget>
        </item>
-       <item row="2" column="2" >
+       <item row="3" column="2" >
         <widget class="KLineEdit" name="kcfg_screengrabencoding" >
          <property name="sizePolicy" >
           <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
          </property>
         </widget>
        </item>
-       <item row="3" column="0" >
+       <item row="4" column="0" >
         <widget class="QLabel" name="label_10" >
          <property name="sizePolicy" >
           <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
          </property>
         </widget>
        </item>
-       <item row="3" column="2" >
+       <item row="4" column="2" >
         <widget class="KLineEdit" name="kcfg_screengrabextension" >
          <property name="sizePolicy" >
           <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
          </property>
         </widget>
        </item>
-       <item row="4" column="0" colspan="3" >
+       <item row="5" column="0" colspan="3" >
         <widget class="QCheckBox" name="kcfg_fullscreengrab" >
          <property name="text" >
           <string>Full screen capture</string>
          </property>
         </widget>
        </item>
-       <item row="5" column="1" colspan="2" >
+       <item row="6" column="1" colspan="2" >
         <spacer name="verticalSpacer_3" >
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
     </widget>
    </item>
   </layout>
+  <zorder>label</zorder>
+  <zorder>kcfg_defaultcapture</zorder>
+  <zorder>tabWidget</zorder>
  </widget>
  <customwidgets>
   <customwidget>