X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmltdevicecapture.cpp;h=c94f896dd2707840e243a43acfd3037407b0d7d7;hb=56aee6aedeeed3efd10ada8fe3c229eddc01ef05;hp=e93e54190a5796e3287dbb41efbcf922155e7bb2;hpb=a1f0a54b93ab364a37fd8242c1881c61d066ada7;p=kdenlive diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index e93e5419..c94f896d 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -19,13 +19,14 @@ #include "mltdevicecapture.h" #include "kdenlivesettings.h" #include "definitions.h" +#include "widgets/videosurface.h" #include #include #include #include -#include +#include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -77,7 +79,7 @@ static void rec_consumer_frame_preview(mlt_consumer, MltDeviceCapture * self, ml MltDeviceCapture::MltDeviceCapture(QString profile, VideoSurface *surface, QWidget *parent) : - AbstractRender(Kdenlive::recordMonitor, parent), + AbstractRender(Kdenlive::RecordMonitor, parent), doCapture(0), sendFrameForAnalysis(false), processingImage(false), @@ -91,7 +93,8 @@ MltDeviceCapture::MltDeviceCapture(QString profile, VideoSurface *surface, QWidg { m_captureDisplayWidget = surface; analyseAudio = KdenliveSettings::monitor_audio(); - if (profile.isEmpty()) profile = KdenliveSettings::current_profile(); + if (profile.isEmpty()) + profile = KdenliveSettings::current_profile(); buildConsumer(profile); connect(this, SIGNAL(unblockPreview()), this, SLOT(slotPreparePreview())); m_droppedFramesTimer.setSingleShot(false); @@ -184,7 +187,8 @@ void MltDeviceCapture::stop() if (m_mltConsumer) { m_mltConsumer->set("refresh", 0); - m_mltConsumer->stop(); + m_mltConsumer->purge(); + m_mltConsumer->stop(); //if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop(); } if (m_mltProducer) { @@ -251,13 +255,14 @@ void MltDeviceCapture::emitFrameUpdated(Mlt::Frame& frame) } */ - mlt_image_format format = mlt_image_rgb24a; + mlt_image_format format = mlt_image_rgb24; int width = 0; int height = 0; const uchar* image = frame.get_image(format, width, height); - QImage qimage(width, height, QImage::Format_ARGB32_Premultiplied); - memcpy(qimage.bits(), image, width * height * 4); - emit frameUpdated(qimage.rgbSwapped()); + QImage qimage(width, height, QImage::Format_RGB888); + //QImage qimage(width, height, QImage::Format_ARGB32_Premultiplied); + memcpy(qimage.bits(), image, width * height * 3); + emit frameUpdated(qimage); } void MltDeviceCapture::showFrame(Mlt::Frame& frame) @@ -449,15 +454,15 @@ bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &pa renderProps->set("mlt_service", "avformat"); renderProps->set("target", path.toUtf8().constData()); renderProps->set("real_time", -KdenliveSettings::mltthreads()); - renderProps->set("terminate_on_pause", 0); + //renderProps->set("terminate_on_pause", 0); renderProps->set("mlt_profile", m_activeProfile.toUtf8().constData()); - QStringList paramList = params.split(" ", QString::SkipEmptyParts); + QStringList paramList = params.split(' ', QString::SkipEmptyParts); char *tmp2; - for (int i = 0; i < paramList.count(); i++) { - tmp = qstrdup(paramList.at(i).section("=", 0, 0).toUtf8().constData()); - QString value = paramList.at(i).section("=", 1, 1); + for (int i = 0; i < paramList.count(); ++i) { + tmp = qstrdup(paramList.at(i).section('=', 0, 0).toUtf8().constData()); + QString value = paramList.at(i).section('=', 1, 1); if (value == "%threads") value = QString::number(QThread::idealThreadCount()); tmp2 = qstrdup(value.toUtf8().constData()); renderProps->set(tmp, tmp2); @@ -518,19 +523,25 @@ bool MltDeviceCapture::slotStartCapture(const QString ¶ms, const QString &pa } - tmp = qstrdup(playlist.toUtf8().constData()); if (xmlPlaylist) { // create an xml producer - m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", tmp); + m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData()); } else { // create a producer based on mltproducer parameter - m_mltProducer = new Mlt::Producer(*m_mltProfile, tmp); + m_mltProducer = new Mlt::Producer(*m_mltProfile, playlist.toUtf8().constData()); } - delete[] tmp; if (m_mltProducer == NULL || !m_mltProducer->is_valid()) { kDebug()<<"//// ERROR CREATRING PROD"; + if (m_mltConsumer) { + delete m_mltConsumer; + m_mltConsumer = NULL; + } + if (m_mltProducer) { + delete m_mltProducer; + m_mltProducer = NULL; + } return false; } @@ -604,7 +615,7 @@ void MltDeviceCapture::setOverlay(const QString &path) //delete clip; } -void MltDeviceCapture::setOverlayEffect(const QString &tag, QStringList parameters) +void MltDeviceCapture::setOverlayEffect(const QString &tag, const QStringList ¶meters) { if (m_mltProducer == NULL || !m_mltProducer->is_valid()) return; Mlt::Service service(m_mltProducer->parent().get_service()); @@ -642,7 +653,7 @@ void MltDeviceCapture::setOverlayEffect(const QString &tag, QStringList paramete delete[] tmp; if (filter && filter->is_valid()) { for (int j = 0; j < parameters.count(); j++) { - filter->set(parameters.at(j).section("=", 0, 0).toUtf8().constData(), parameters.at(j).section("=", 1, 1).toUtf8().constData()); + filter->set(parameters.at(j).section('=', 0, 0).toUtf8().constData(), parameters.at(j).section('=', 1, 1).toUtf8().constData()); } trackService.attach(*filter); } @@ -763,3 +774,5 @@ void MltDeviceCapture::slotAllowPreview() } + +#include "mltdevicecapture.moc"