#include <QToolButton>
#include <QFile>
#include <QDir>
+#include <QDesktopWidget>
RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidget *parent) :
void RecMonitor::stop()
{
+ // Special case: when recording audio only, do not stop so that we can do voiceover.
+ if (device_selector->currentIndex() == SCREENGRAB || (device_selector->currentIndex() == VIDEO4LINUX && !rec_video->isChecked())) return;
slotStopCapture();
}
QString capturename;
m_previewSettings->setEnabled(ix == VIDEO4LINUX || ix == BLACKMAGIC);
control_frame->setVisible(ix == VIDEO4LINUX);
+ m_playAction->setVisible(ix != SCREENGRAB);
m_fwdAction->setVisible(ix == FIREWIRE);
m_discAction->setVisible(ix == FIREWIRE);
m_rewAction->setVisible(ix == FIREWIRE);
m_fwdAction->setEnabled(false);
m_stopAction->setEnabled(false);
m_playAction->setEnabled(false);
- if (KdenliveSettings::rmd_path().isEmpty()) {
- QString rmdpath = KStandardDirs::findExe("recordmydesktop");
- if (rmdpath.isEmpty()) video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("Recordmydesktop utility not found,\n please install it for screen grabs")));
- else KdenliveSettings::setRmd_path(rmdpath);
- }
- if (!KdenliveSettings::rmd_path().isEmpty()) 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", m_capturePath)));
+ if (KdenliveSettings::ffmpegpath().isEmpty()) {
+ QString exepath = KStandardDirs::findExe("ffmpeg");
+ if (exepath.isEmpty()) {
+ // Check for libav version
+ exepath = KStandardDirs::findExe("avconv");
+ }
+ if (exepath.isEmpty()) video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("ffmpeg or avconv not found,\n please install it for screen grabs")));
+ else KdenliveSettings::setFfmpegpath(exepath);
+ }
+ if (!KdenliveSettings::ffmpegpath().isEmpty()) {
+ if (!Render::checkX11Grab()) {
+ // FFmpeg does not support screen grab
+ video_frame->setPixmap(mergeSideBySide(KIcon("dialog-warning").pixmap(QSize(50, 50)), i18n("Your FFmpeg / Libav installation\n does not support screen grab")));
+ m_recAction->setEnabled(false);
+ }
+ else 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", m_capturePath)));
+ }
//video_frame->setText(i18n("Press record button\nto start screen capture"));
break;
case VIDEO4LINUX:
if (!m_isCapturing && !m_isPlaying) return;
videoBox->setHidden(true);
control_frame->setEnabled(true);
+ slotActivateMonitor();
switch (device_selector->currentIndex()) {
case FIREWIRE:
m_captureProcess->write("\e", 2);
case SCREENGRAB:
m_captureProcess->write("q\n", 3);
m_captureProcess->terminate();
- video_frame->setText(i18n("Encoding captured video..."));
+ //video_frame->setText(i18n("Encoding captured video..."));
QTimer::singleShot(1000, m_captureProcess, SLOT(kill()));
break;
case VIDEO4LINUX:
QString producer;
QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(' ', QString::SkipEmptyParts);
int ix = device_selector->currentIndex();
+ bool isXml;
videoBox->setHidden(ix != VIDEO4LINUX && ix != BLACKMAGIC && ix != FIREWIRE);
switch (ix) {
case FIREWIRE:
path = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
buildMltDevice(path);
profile = ProfilesDialog::getVideoProfile(path);
- producer = getV4lXmlPlaylist(profile);
+ producer = getV4lXmlPlaylist(profile, &isXml);
//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);
- if (!m_captureDevice->slotStartPreview(producer, true)) {
+ if (!m_captureDevice->slotStartPreview(producer, isXml)) {
// v4l capture failed to start
video_frame->setText(i18n("Failed to start Video4Linux,\ncheck your parameters..."));
videoBox->setHidden(true);
void RecMonitor::slotRecord()
{
- control_frame->setEnabled(false);
-
if (m_captureProcess->state() == QProcess::NotRunning && device_selector->currentIndex() == FIREWIRE) {
slotStartPreview();
}
m_logger.clear();
m_recAction->setChecked(true);
QString extension = "mpg";
- if (device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
+ if (device_selector->currentIndex() == SCREENGRAB) {
+ extension = KdenliveSettings::grab_extension();
+ }
else if (device_selector->currentIndex() == VIDEO4LINUX) {
// TODO: when recording audio only, allow configuration?
if (!rec_video->isChecked()) extension = "wav";
QString args;
QString playlist;
QString v4lparameters;
+ QStringList grabParameters;
MltVideoProfile profile;
bool showPreview;
+ bool isXml;
+ QString captureSize;
+ QRect screenSize = QApplication::desktop()->screenGeometry();
QString capturename = KdenliveSettings::dvgrabfilename();
if (capturename.isEmpty()) capturename = "capture";
switch (device_selector->currentIndex()) {
case VIDEO4LINUX:
- slotActivateMonitor();
+ 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);
+ playlist = getV4lXmlPlaylist(profile, &isXml);
v4lparameters = KdenliveSettings::v4l_parameters();
showPreview = m_previewSettings->isChecked();
if (!rec_video->isChecked()) showPreview = false;
- if (m_captureDevice->slotStartCapture(v4lparameters, m_captureFile.path(), playlist, showPreview)) {
+ 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;
break;
case SCREENGRAB:
- switch (KdenliveSettings::rmd_capture_type()) {
- case 0:
- // Full screen capture, nothing special to do
- break;
- default:
+ m_captureArgs << "-f" << "x11grab";
+ if (KdenliveSettings::grab_follow_mouse()) m_captureArgs << "-follow_mouse" << "centered";
+ if (!KdenliveSettings::grab_hide_frame()) m_captureArgs << "-show_region" << "1";
+ if (KdenliveSettings::grab_capture_type() == 0) {
+ // Full screen capture
+ captureSize = ":0.0";
+ m_captureArgs << "-s" << QString::number(screenSize.width()) + "x" + QString::number(screenSize.height());
+ } else {
// 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";
- if (KdenliveSettings::rmd_hide_frame()) m_captureArgs << "--no-frame";
- }
- break;
+ m_captureArgs << "-s" << QString::number(KdenliveSettings::grab_width()) + "x" + QString::number(KdenliveSettings::grab_height());
+ captureSize = ":" + QString::number(KdenliveSettings::grab_offsetx()) + "." + QString::number(KdenliveSettings::grab_offsetx());
}
- if (KdenliveSettings::rmd_hide_mouse()) m_captureArgs << "--no-cursor";
+ // 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;
- if (KdenliveSettings::rmd_capture_audio()) {
+ 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()) {
if (KdenliveSettings::rmd_alsa_buffer() > 0)
m_captureArgs << "--buffer-size" << QString::number(KdenliveSettings::rmd_alsa_buffer());
}
- } else m_captureArgs << "--no-sound";
-
- if (KdenliveSettings::rmd_fullshots()) m_captureArgs << "--full-shots";
- m_captureArgs << "--v_bitrate" << QString::number(KdenliveSettings::rmd_bitrate());
- m_captureArgs << "--v_quality" << QString::number(KdenliveSettings::rmd_quality());
- m_captureArgs << "--workdir" << KdenliveSettings::currenttmpfolder();
- m_captureArgs << "--fps" << QString::number(KdenliveSettings::rmd_fps()) << "-o" << m_captureFile.path();
- m_captureProcess->start(KdenliveSettings::rmd_path(), m_captureArgs);
- kDebug() << "// RecordMyDesktop params: " << m_captureArgs;
+ } else m_captureArgs << "--no-sound";*/
+
+ m_captureProcess->start(KdenliveSettings::ffmpegpath(), m_captureArgs);
+ //kDebug() << "// Screen grab params: " << m_captureArgs;
break;
default:
break;
}
}
-const QString RecMonitor::getV4lXmlPlaylist(MltVideoProfile profile) {
-
- QString playlist = QString("<mlt title=\"capture\" LC_NUMERIC=\"C\"><profile description=\"v4l\" width=\"%1\" height=\"%2\" progressive=\"%3\" sample_aspect_num=\"%4\" sample_aspect_den=\"%5\" display_aspect_num=\"%6\" display_aspect_den=\"%7\" frame_rate_num=\"%8\" frame_rate_den=\"%9\" colorspace=\"%10\"/>").arg(profile.width).arg(profile.height).arg(profile.progressive).arg(profile.sample_aspect_num).arg(profile.sample_aspect_den).arg(profile.display_aspect_num).arg(profile.display_aspect_den).arg(profile.frame_rate_num).arg(profile.frame_rate_den).arg(profile.colorspace);
+const QString RecMonitor::getV4lXmlPlaylist(MltVideoProfile profile, bool *isXml)
+{
+ QString playlist;
+ if (rec_video->isChecked() && rec_audio->isChecked()) {
+ // We want to capture audio and video, use xml playlist
+ *isXml = true;
+ playlist = QString("<mlt title=\"capture\" LC_NUMERIC=\"C\"><profile description=\"v4l\" width=\"%1\" height=\"%2\" progressive=\"%3\" sample_aspect_num=\"%4\" sample_aspect_den=\"%5\" display_aspect_num=\"%6\" display_aspect_den=\"%7\" frame_rate_num=\"%8\" frame_rate_den=\"%9\" colorspace=\"%10\"/>").arg(profile.width).arg(profile.height).arg(profile.progressive).arg(profile.sample_aspect_num).arg(profile.sample_aspect_den).arg(profile.display_aspect_num).arg(profile.display_aspect_den).arg(profile.frame_rate_num).arg(profile.frame_rate_den).arg(profile.colorspace);
- if (rec_video->isChecked()) {
playlist.append(QString("<producer id=\"producer0\" in=\"0\" out=\"999999\"><property name=\"mlt_type\">producer</property><property name=\"length\">1000000</property><property name=\"eof\">loop</property><property name=\"resource\">video4linux2:%1?width:%2&height:%3&frame_rate:%4</property><property name=\"mlt_service\">avformat-novalidate</property></producer><playlist id=\"playlist0\"><entry producer=\"producer0\" in=\"0\" out=\"999999\"/></playlist>").arg(KdenliveSettings::video4vdevice()).arg(profile.width).arg(profile.height).arg((double) profile.frame_rate_num / profile.frame_rate_den));
- }
+
+ playlist.append(QString("<producer id=\"producer1\" in=\"0\" out=\"999999\"><property name=\"mlt_type\">producer</property><property name=\"length\">1000000</property><property name=\"resource\">alsa:%1?channels=%2</property><property name=\"audio_index\">0</property><property name=\"video_index\">-1</property><property name=\"mlt_service\">avformat-novalidate</property></producer><playlist id=\"playlist1\"><entry producer=\"producer1\" in=\"0\" out=\"999999\"/></playlist>").arg(KdenliveSettings::v4l_alsadevicename()).arg(KdenliveSettings::alsachannels()));
- if (rec_audio->isChecked()) {
- playlist.append(QString("<producer id=\"producer1\" in=\"0\" out=\"999999\"><property name=\"mlt_type\">producer</property><property name=\"length\">1000000</property><property name=\"eof\">loop</property><property name=\"resource\">alsa:%5</property><property name=\"audio_index\">0</property><property name=\"video_index\">-1</property><property name=\"mlt_service\">avformat-novalidate</property></producer><playlist id=\"playlist1\"><entry producer=\"producer1\" in=\"0\" out=\"999999\"/></playlist>").arg(KdenliveSettings::v4l_alsadevicename()));
+ playlist.append("<tractor id=\"tractor0\" title=\"video0\" global_feed=\"1\" in=\"0\" out=\"999999\">");
+ playlist.append("<track producer=\"playlist0\"/><track producer=\"playlist1\"/>");
+ playlist.append("</tractor></mlt>");
}
- playlist.append("<tractor id=\"tractor0\" title=\"video0\" global_feed=\"1\" in=\"0\" out=\"999999\">");
- if (rec_video->isChecked()) playlist.append("<track producer=\"playlist0\"/>");
- if (rec_audio->isChecked()) playlist.append("<track producer=\"playlist1\"/>");
- playlist.append("</tractor></mlt>");
-
+ else if (rec_audio->isChecked()) {
+ // Audio only recording
+ *isXml = false;
+ playlist =QString("alsa:%1?channels=%2").arg(KdenliveSettings::v4l_alsadevicename()).arg(KdenliveSettings::alsachannels());
+ }
+ else {
+ // Video only recording
+ *isXml = false;
+ playlist =QString("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);
+
+ }
+
return playlist;
}
m_fwdAction->setEnabled(false);
m_recAction->setEnabled(false);
}
+ else {
+ m_recAction->setEnabled(true);
+ }
m_isPlaying = false;
m_playAction->setIcon(m_playIcon);
m_recAction->setChecked(false);
if (device_selector->currentIndex() != SCREENGRAB) {
video_frame->setText(i18n("Not connected"));
} else {
- if (m_captureProcess->exitCode() != 0) {
- video_frame->setText(i18n("Capture crashed, please check your parameters\nRecordMyDesktop exit code: %1", QString::number(m_captureProcess->exitCode())));
+ int code = m_captureProcess->exitCode();
+ if (code != 0 && code != 255) {
+ video_frame->setText(i18n("Capture crashed, please check your parameters.\nExit code: %1", QString::number(m_captureProcess->exitCode())));
} else {
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", m_capturePath)));
}
// update free space info
slotUpdateFreeSpace();
} else {
- if (device_selector->currentIndex() != SCREENGRAB) m_stopAction->setEnabled(true);
+ if (device_selector->currentIndex()) m_stopAction->setEnabled(true);
device_selector->setEnabled(false);
}
}