From: Jean-Baptiste Mardelle Date: Sun, 19 Jun 2011 06:27:04 +0000 (+0000) Subject: Fix video4linux capture without audio X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=21b8b0afba36af9eea67dde87be0bf46fb26fcdf;p=kdenlive Fix video4linux capture without audio svn path=/trunk/kdenlive/; revision=5720 --- diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index 76c5714a..41ea6501 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -484,7 +484,6 @@ void RecMonitor::slotStartPreview(bool play) buildMltDevice(path); profile = ProfilesDialog::getVideoProfile(path); producer = QString("avformat-novalidate:video4linux2:%1?width:%2&height:%3&frame_rate:%4").arg(KdenliveSettings::video4vdevice()).arg(profile.width).arg(profile.height).arg((double) profile.frame_rate_num / profile.frame_rate_den); - kDebug()<< "PROD: "<slotStartPreview(producer)) { // v4l capture failed to start video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters...")); @@ -565,6 +564,7 @@ void RecMonitor::slotRecord() m_displayArgs.clear(); QString args; QString playlist; + QString v4lparameters; MltVideoProfile profile; QString capturename = KdenliveSettings::dvgrabfilename(); if (capturename.isEmpty()) capturename = "capture"; @@ -577,10 +577,39 @@ void RecMonitor::slotRecord() buildMltDevice(path); playlist = QString("producer100000pausevideo4linux2:%1?width:%2&height:%3&frame_rate:%4avformat-novalidate").arg(KdenliveSettings::video4vdevice()).arg(profile.width).arg(profile.height).arg((double) profile.frame_rate_num / profile.frame_rate_den); + v4lparameters = KdenliveSettings::v4l_parameters(); + // Add alsa audio capture if (KdenliveSettings::v4l_captureaudio()) { playlist.append(QString("producer100000pausealsa:%50-1avformat").arg(KdenliveSettings::v4l_alsadevicename())); } + else { + // if we do not want audio, make sure that we don't have audio encoding parameters + // this is required otherwise the MLT avformat consumer will not close properly + if (v4lparameters.contains("acodec")) { + QString endParam = v4lparameters.section("acodec", 1); + int vcodec = endParam.indexOf(" vcodec"); + int format = endParam.indexOf(" f="); + int cutPosition = -1; + if (vcodec > -1) { + if (format > -1) { + cutPosition = qMin(vcodec, format); + } + else cutPosition = vcodec; + } + else if (format > -1) { + cutPosition = format; + } + else { + // nothing interesting in end params + endParam.clear(); + } + if (cutPosition > -1) { + endParam.remove(0, cutPosition); + } + v4lparameters = QString(v4lparameters.section("acodec", 0, 0) + "an=1 " + endParam).simplified(); + } + } playlist.append(""); @@ -595,7 +624,7 @@ void RecMonitor::slotRecord() playlist.append(""); - if (m_captureDevice->slotStartCapture(KdenliveSettings::v4l_parameters(), m_captureFile.path(), playlist, recording_preview->currentIndex())) { + if (m_captureDevice->slotStartCapture(v4lparameters, m_captureFile.path(), playlist, recording_preview->currentIndex())) { m_videoBox->setHidden(false); m_isCapturing = true; m_recAction->setEnabled(false);