+ switch (device_selector->currentIndex()) {
+ case Video4Linux:
+ if (rec_video->isChecked()) slotActivateMonitor();
+ path = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
+ profile = ProfilesDialog::getVideoProfile(path);
+ //m_videoBox->setRatio((double) profile.display_aspect_num / profile.display_aspect_den);
+ buildMltDevice(path);
+ playlist = getV4lXmlPlaylist(profile, &isXml);
+
+ v4lparameters = KdenliveSettings::v4l_parameters();
+
+ // TODO: when recording audio only, allow param configuration?
+ if (!rec_video->isChecked()) v4lparameters.clear();
+
+ // Add alsa audio capture
+ if (!rec_audio->isChecked()) {
+ // 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();
+ }
+ }
+
+ showPreview = m_previewSettings->isChecked();
+ if (!rec_video->isChecked()) showPreview = false;
+
+ if (m_captureDevice->slotStartCapture(v4lparameters, m_captureFile.path(), playlist, showPreview, isXml)) {
+ videoBox->setHidden(false);
+ m_isCapturing = true;
+ m_recAction->setEnabled(false);
+ m_stopAction->setEnabled(true);
+ m_previewSettings->setEnabled(false);
+ control_frame->setEnabled(false);
+ }
+ else {
+ video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters..."));
+ videoBox->setHidden(true);
+ m_recAction->blockSignals(true);
+ m_recAction->setChecked(false);
+ m_recAction->blockSignals(false);
+ m_isCapturing = false;
+ }
+ break;
+
+ case BlackMagic:
+ slotActivateMonitor();
+ path = KdenliveSettings::current_profile();
+ profile = ProfilesDialog::getVideoProfile(path);
+ //m_videoBox->setRatio((double) profile.display_aspect_num / profile.display_aspect_den);
+ buildMltDevice(path);
+
+ playlist = QString("<producer id=\"producer0\" in=\"0\" out=\"99999\"><property name=\"mlt_type\">producer</property><property name=\"length\">100000</property><property name=\"eof\">pause</property><property name=\"resource\">%1</property><property name=\"mlt_service\">decklink</property></producer>").arg(KdenliveSettings::decklink_capturedevice());
+
+ if (m_captureDevice->slotStartCapture(KdenliveSettings::decklink_parameters(), m_captureFile.path(), QString("decklink:%1").arg(KdenliveSettings::decklink_capturedevice()), m_previewSettings->isChecked(), false)) {
+ videoBox->setHidden(false);
+ m_isCapturing = true;
+ slotSetInfoMessage(i18n("Capturing to %1", m_captureFile.fileName()));
+ m_recAction->setEnabled(false);
+ m_stopAction->setEnabled(true);
+ m_previewSettings->setEnabled(false);
+ }
+ else {
+ video_frame->setText(i18n("Failed to start Decklink,\ncheck your parameters..."));
+ slotSetInfoMessage(i18n("Failed to start capture"));
+ videoBox->setHidden(true);
+ m_isCapturing = false;
+ }
+ break;
+
+ case ScreenBag:
+ m_captureArgs << "-f" << "x11grab";
+ if (KdenliveSettings::grab_follow_mouse()) m_captureArgs << "-follow_mouse" << "centered";
+ if (!KdenliveSettings::grab_hide_frame()) m_captureArgs << "-show_region" << "1";
+ captureSize = ":0.0";
+ if (KdenliveSettings::grab_capture_type() == 0) {
+ // Full screen capture
+ m_captureArgs << "-s" << QString::number(screenSize.width()) + "x" + QString::number(screenSize.height());
+ } else {
+ // Region capture
+ m_captureArgs << "-s" << QString::number(KdenliveSettings::grab_width()) + "x" + QString::number(KdenliveSettings::grab_height());
+ captureSize.append("+" + QString::number(KdenliveSettings::grab_offsetx()) + "." + QString::number(KdenliveSettings::grab_offsetx()));
+ }
+ // fps
+ m_captureArgs << "-r" << QString::number(KdenliveSettings::grab_fps());
+ if (KdenliveSettings::grab_hide_mouse()) captureSize.append("+nomouse");
+ m_captureArgs << "-i" << captureSize;
+ grabParameters = KdenliveSettings::grab_parameters().simplified().split(" ");
+ m_captureArgs << grabParameters;
+ m_captureArgs << path;
+
+ m_isCapturing = true;
+ m_recAction->setEnabled(false);
+ /*if (KdenliveSettings::rmd_capture_audio()) {
+ m_captureArgs << "--freq" << KdenliveSettings::rmd_freq();
+ m_captureArgs << "--channels" << QString::number(KdenliveSettings::rmd_audio_channels());
+ if (KdenliveSettings::rmd_use_jack()) {
+ m_captureArgs << "--use-jack";
+ QStringList ports = KdenliveSettings::rmd_jackports().split(' ', QString::SkipEmptyParts);
+ for (int i = 0; i < ports.count(); ++i) {
+ m_captureArgs << ports.at(i);
+ }
+ if (KdenliveSettings::rmd_jack_buffer() > 0.0)
+ m_captureArgs << "--ring-buffer-size" << QString::number(KdenliveSettings::rmd_jack_buffer());
+ } else {
+ if (!KdenliveSettings::rmd_alsadevicename().isEmpty())
+ m_captureArgs << "--device" << KdenliveSettings::rmd_alsadevicename();
+ if (KdenliveSettings::rmd_alsa_buffer() > 0)
+ m_captureArgs << "--buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
+ }
+ } else m_captureArgs << "--no-sound";*/
+
+ m_captureProcess->start(KdenliveSettings::ffmpegpath(), m_captureArgs);
+ if (!m_captureProcess->waitForStarted()) {
+ // Problem launching capture app
+ showWarningMessage(i18n("Failed to start the capture application:\n%1", KdenliveSettings::ffmpegpath()));
+ }
+ //kDebug() << "// Screen grab params: " << m_captureArgs;
+ break;
+ default:
+ break;