widgets/wizardstandard_ui.ui
widgets/keywordval_ui.ui
widgets/fontval_ui.ui
+ widgets/cutjobdialog_ui.ui
)
if(OPENGL_FOUND)
void ClipManager::slotAddClipList(const KUrl::List urls, const QString &group, const QString &groupId)
{
QUndoCommand *addClips = new QUndoCommand();
-
foreach(const KUrl & file, urls) {
- if (KIO::NetAccess::exists(file, KIO::NetAccess::SourceSide, NULL)) {
+ if (QFile::exists(file.path())) {//KIO::NetAccess::exists(file, KIO::NetAccess::SourceSide, NULL)) {
if (!getClipByResource(file.path()).empty()) {
if (KMessageBox::warningContinueCancel(kapp->activeWindow(), i18n("Clip <b>%1</b><br />already exists in project, what do you want to do?", file.path()), i18n("Clip already exists")) == KMessageBox::Cancel)
continue;
}
new AddClipCommand(m_doc, doc.documentElement(), QString::number(id), true, addClips);
}
+ else kDebug()<<"// CANNOT READ FILE: "<<file;
}
if (addClips->childCount() > 0) {
addClips->setText(i18np("Add clip", "Add clips", addClips->childCount()));
new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Frame rate") << props.value("fps"));
if (!m_view.clip_framerate->isEnabled()) m_view.clip_framerate->setValue(props.value("fps").toDouble());
}
+
+ if (props.contains("progressive")) {
+ int scanning = props.value("progressive").toInt();
+ QString txt = scanning == 1 ? i18n("Progressive") : i18n("Interlaced");
+ new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Scanning") << txt);
+ }
+
if (props.contains("aspect_ratio"))
new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Pixel aspect ratio") << props.value("aspect_ratio"));
if (props.contains("colorspace"))
new QTreeWidgetItem(m_view.clip_vproperties, QStringList() << i18n("Colorspace") << ProfilesDialog::getColorspaceDescription(props.value("colorspace").toInt()));
+
int width = 180.0 * KdenliveSettings::project_display_ratio();
if (width % 2 == 1) width++;
connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
+ connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
m_projectMonitorDock->setObjectName("project_monitor");
kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
}
+
#include "mainwindow.moc"
#ifdef DEBUG_MAINW
if (m_name == "clip") {
m_contextMenu->addMenu(m_markerMenu);
m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
+ QAction *extractZone = m_configMenu->addAction(KIcon("document-new"), i18n("Extract Zone"), this, SLOT(slotExtractCurrentZone()));
+ m_contextMenu->addAction(extractZone);
}
QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
m_contextMenu->addAction(extractFrame);
emit refreshClipThumbnail(m_currentClip->getId(), true);
}
+void Monitor::slotExtractCurrentZone()
+{
+ if (m_currentClip == NULL) return;
+ emit extractZone(m_currentClip->getId(), m_ruler->zone());
+}
+
void Monitor::slotExtractCurrentFrame()
{
QImage frame;
void slotSetVolume(int volume);
void slotShowVolume();
void slotEditMarker();
+ void slotExtractCurrentZone();
public slots:
void slotOpenFile(const QString &);
/** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
* This causes a major slowdown, so we only enable it if required */
void requestFrameForAnalysis(bool);
+ /** @brief Request a zone extraction (ffmpeg transcoding). */
+ void extractZone(const QString &id, QPoint zone);
};
#endif
#include <QFile>
const int DurationRole = Qt::UserRole + 1;
-const int ProxyRole = Qt::UserRole + 5;
+const int JobProgressRole = Qt::UserRole + 5;
+const int JobTypeRole = Qt::UserRole + 6;
+const int JobCrasMessage = Qt::UserRole + 7;
const int itemHeight = 38;
ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
{
QString tip;
if (m_clip->isPlaceHolder()) tip.append(i18n("Missing") + " | ");
- int s = data(0, ProxyRole).toInt();
+ int s = data(0, JobProgressRole).toInt();
if (s == CREATINGJOB || s > 0) {
tip.append(i18n("Building proxy clip") + " | ");
}
}
}
-void ProjectItem::setProxyStatus(CLIPJOBSTATUS status, int progress)
+void ProjectItem::setJobStatus(CLIPJOBSTATUS status, int progress, JOBTYPE jobType)
{
- if (progress > 0) setData(0, ProxyRole, progress);
+ if (status == JOBCRASHED) {
+ if (jobType == PROXYJOB) setData(0, JobCrasMessage, i18n("Proxy crashed"));
+ else if (jobType == CUTJOB) setData(0, JobCrasMessage, i18n("Transcoding crashed"));
+ }
+ setData(0, JobTypeRole, jobType);
+ if (progress > 0) setData(0, JobProgressRole, progress);
else {
- setData(0, ProxyRole, status);
+ setData(0, JobProgressRole, status);
slotSetToolTip();
}
}
bool ProjectItem::hasProxy() const
{
if (m_clip == NULL) return false;
- if (m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-" || data(0, ProxyRole).toInt() == JOBCRASHED) return false;
+ if (m_clip->getProperty("proxy").isEmpty() || m_clip->getProperty("proxy") == "-" || data(0, JobProgressRole).toInt() == JOBCRASHED) return false;
return true;
}
bool ProjectItem::isProxyReady() const
{
- return (data(0, ProxyRole).toInt() == JOBDONE);
+ return (data(0, JobProgressRole).toInt() == JOBDONE);
}
-bool ProjectItem::isProxyRunning() const
+bool ProjectItem::isJobRunning() const
{
- int s = data(0, ProxyRole).toInt();
+ int s = data(0, JobProgressRole).toInt();
if (s == JOBWAITING || s == CREATINGJOB || s > 0) return true;
return false;
}
+bool ProjectItem::isProxyRunning() const
+{
+ int s = data(0, JobProgressRole).toInt();
+ if ((s == CREATINGJOB || s > 0) && data(0, JobTypeRole).toInt() == (int) PROXYJOB) return true;
+ return false;
+}
+
bool ProjectItem::playlistHasProxies(const QString path)
{
kDebug()<<"// CHECKING FOR PROXIES";
#include "gentime.h"
#include "definitions.h"
+#include "projecttree/abstractclipjob.h"
+
class DocClipBase;
QString getClipHash() const;
static int itemDefaultHeight();
void slotSetToolTip();
- /** \brief Set the status of proxy clip creation. 0 = no proxy, 1 = creating proxy, 2 = proxy created. */
- void setProxyStatus(CLIPJOBSTATUS status, int progress = 0);
+ /** \brief Set the status of the clip job. */
+ void setJobStatus(CLIPJOBSTATUS status, int progress = 0, JOBTYPE jobType = NOJOBTYPE);
/** \brief Returns the proxy status for this clip (true means there is a proxy clip). */
bool hasProxy() const;
/** \brief Returns true if the proxy for this clip is ready. */
bool isProxyReady() const;
+ /** \brief Returns true if there is a job currently running for this clip. */
+ bool isJobRunning() const;
/** \brief Returns true if we are currently creating the proxy for this clip. */
bool isProxyRunning() const;
#include "projectitem.h"
#include "commands/addfoldercommand.h"
#include "projecttree/proxyclipjob.h"
+#include "projecttree/cutclipjob.h"
#include "kdenlivesettings.h"
#include "slideshowclip.h"
#include "ui_colorclip_ui.h"
#include "commands/addclipcutcommand.h"
#include "ui_templateclip_ui.h"
+#include "ui_cutjobdialog_ui.h"
#include <KDebug>
#include <KAction>
#include <KApplication>
#include <KStandardDirs>
#include <KColorScheme>
+#include <KUrlRequester>
#ifdef NEPOMUK
#include <nepomuk/global.h>
connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
connect(m_listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
connect(m_listView, SIGNAL(addClip(const QList <QUrl>, const QString &, const QString &)), this, SLOT(slotAddClip(const QList <QUrl>, const QString &, const QString &)));
+ connect(this, SIGNAL(addClip(const QString, const QString &, const QString &)), this, SLOT(slotAddClip(const QString, const QString &, const QString &)));
connect(m_listView, SIGNAL(addClipCut(const QString &, int, int)), this, SLOT(slotAddClipCut(const QString &, int, int)));
connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
continue;
}
item = static_cast <ProjectItem *>(selected.at(i));
- if (item && !item->isProxyRunning()) {
+ if (item && !hasPendingProxy(item)) {
DocClipBase *clip = item->referencedClip();
if (!clip || !clip->isClean() || m_render->isProcessing(item->clipId())) {
kDebug()<<"//// TRYING TO RELOAD: "<<item->clipId()<<", but it is busy";
clip->setProperties(properties);
if (properties.contains("proxy")) {
if (properties.value("proxy") == "-" || properties.value("proxy").isEmpty())
- clip->setProxyStatus(NOJOB);
+ clip->setJobStatus(NOJOB);
}
if (properties.contains("name")) {
monitorItemEditing(false);
kDebug() << "/// Cannot find clip to delete";
return;
}
+ deleteJobsForClip(clipId);
if (item->isProxyRunning()) m_abortProxy.append(item->referencedClip()->getProperty("proxy"));
m_listView->blockSignals(true);
QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true);
}
// WARNING: code below triggers unnecessary reload of all proxy clips on document loading... is it useful in some cases?
- /*else if (item->hasProxy() && !item->isProxyRunning()) {
+ /*else if (item->hasProxy() && !item->isJobRunning()) {
slotCreateProxy(clip->getId());
}*/
bool replace = false;
if (brokenClips.contains(item->clipId())) {
// if this is a proxy clip, disable proxy
- item->setProxyStatus(NOJOB);
+ item->setJobStatus(NOJOB);
clip->setProperty("proxy", "-");
replace = true;
}
- if (clip->isPlaceHolder() == false && !item->isProxyRunning()) {
+ if (clip->isPlaceHolder() == false && !hasPendingProxy(item)) {
QDomElement xml = clip->toXML();
if (fpsChanged) {
xml.removeAttribute("out");
return allExtensions.simplified();
}
+void ProjectList::slotAddClip(const QString url, const QString &groupName, const QString &groupId)
+{
+ kDebug()<<"// Adding clip: "<<url;
+ QList <QUrl> list;
+ list.append(url);
+ slotAddClip(list, groupName, groupId);
+}
+
void ProjectList::slotAddClip(const QList <QUrl> givenList, const QString &groupName, const QString &groupId)
{
if (!m_commandStack)
kDebug() << "Proxy duration is wrong, try changing transcoding parameters.";
emit displayMessage(i18n("Proxy clip unusable (duration is different from original)."), -2);
}
- item->setProxyStatus(JOBCRASHED);
+ item->setJobStatus(JOBCRASHED);
QString path = item->referencedClip()->getProperty("proxy");
KUrl proxyFolder(m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/");
// Proxy stuff
QString size = properties.value("frame_size");
- if (!useProxy() && clip->getProperty("proxy").isEmpty()) setProxyStatus(item, NOJOB);
- if (useProxy() && generateProxy() && clip->getProperty("proxy") == "-") setProxyStatus(item, NOJOB);
- else if (useProxy() && !item->hasProxy() && !item->isProxyRunning()) {
+ if (!useProxy() && clip->getProperty("proxy").isEmpty()) setJobStatus(item, NOJOB);
+ if (useProxy() && generateProxy() && clip->getProperty("proxy") == "-") setJobStatus(item, NOJOB);
+ else if (useProxy() && !item->hasProxy() && !hasPendingProxy(item)) {
// proxy video and image clips
int maxSize;
CLIPTYPE t = item->clipType();
void ProjectList::slotCreateProxy(const QString id)
{
ProjectItem *item = getItemById(id);
- if (!item || item->isProxyRunning() || item->referencedClip()->isPlaceHolder()) return;
+ if (!item || hasPendingProxy(item) || item->referencedClip()->isPlaceHolder()) return;
QString path = item->referencedClip()->getProperty("proxy");
if (path.isEmpty()) {
- setProxyStatus(item, JOBCRASHED);
+ setJobStatus(item, JOBCRASHED);
return;
}
- setProxyStatus(item, JOBWAITING);
+
if (m_abortProxy.contains(path)) m_abortProxy.removeAll(path);
if (m_processingProxy.contains(path)) {
// Proxy is already being generated
}
if (QFileInfo(path).size() > 0) {
// Proxy already created
- setProxyStatus(item, JOBDONE);
+ setJobStatus(item, JOBDONE);
slotGotProxy(path);
return;
}
+ if (!item->isJobRunning()) setJobStatus(item, JOBWAITING);
m_processingProxy.append(path);
- /*PROXYINFO info;
- info.dest = path;
- info.src = item->clipUrl().path();
- info.type = item->clipType();
- info.exif = QString(item->referencedClip()->producerProperty("_exif_orientation")).toInt();*/
- ProxyJob *job = new ProxyJob(PROXYJOB, item->clipType(), item->clipId(), QStringList() << path << item->clipUrl().path() << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight()));
+ ProxyJob *job = new ProxyJob(item->clipType(), id, QStringList() << path << item->clipUrl().path() << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight()));
+ m_jobList.append(job);
+
+ startJobProcess();
+}
+
+void ProjectList::slotCutClipJob(const QString &id, QPoint zone)
+{
+ ProjectItem *item = getItemById(id);
+ if (!item|| item->referencedClip()->isPlaceHolder()) return;
+ QString dest = item->clipUrl().path();
+ QString ext = dest.section('.', -1);
+ dest = dest.section('.', 0, -2) + "_" + QString::number(zone.x()) + "." + ext;
+
+ double clipFps = item->referencedClip()->getProperty("fps").toDouble();
+ if (clipFps == 0) clipFps = m_fps;
+ // if clip and project have different frame rate, adjust in and out
+ int in = zone.x();
+ int out = zone.y();
+ in = GenTime(in, m_timecode.fps()).frames(clipFps);
+ out = GenTime(out, m_timecode.fps()).frames(clipFps);
+ int max = GenTime(item->clipMaxDuration(), m_timecode.fps()).frames(clipFps);
+ int duration = out - in;
+ QString timeIn = Timecode::getStringTimecode(in, clipFps, true);
+ QString timeOut = Timecode::getStringTimecode(duration, clipFps, true);
+
+ QDialog *d = new QDialog(this);
+ Ui::CutJobDialog_UI ui;
+ ui.setupUi(d);
+ ui.file_url->fileDialog()->setOperationMode(KFileDialog::Saving);
+ ui.file_url->setUrl(KUrl(dest));
+ ui.info_label->setText(i18n("Extracting %1 out of %2", timeOut, Timecode::getStringTimecode(max, clipFps, true)));
+ if (d->exec() != QDialog::Accepted) return;
+ dest = ui.file_url->url().path();
+ QString extraParams = ui.extra_params->toPlainText().simplified();
+ delete d;
+
+ if (QFileInfo(dest).size() > 0) {
+ // Clip already created
+ setJobStatus(item, JOBDONE);
+ emit addClip(dest, QString(), QString());
+ return;
+ }
+ if (!item->isJobRunning()) setJobStatus(item, JOBWAITING);
+ m_processingProxy.append(dest);
+ QStringList jobParams;
+ jobParams << dest << item->clipUrl().path() << timeIn << timeOut << QString::number(duration);
+ if (!extraParams.isEmpty()) jobParams << extraParams;
+ CutClipJob *job = new CutClipJob(item->clipType(), id, jobParams);
m_jobList.append(job);
+
+ startJobProcess();
+}
+
+
+void ProjectList::startJobProcess()
+{
int ct = 0;
if (!m_proxyThreads.futures().isEmpty()) {
// Remove inactive threads
}
emit jobCount(ct + m_jobList.count());
- if (m_proxyThreads.futures().isEmpty() || m_proxyThreads.futures().count() < KdenliveSettings::proxythreads()) m_proxyThreads.addFuture(QtConcurrent::run(this, &ProjectList::slotGenerateProxy));
+ if (m_proxyThreads.futures().isEmpty() || m_proxyThreads.futures().count() < KdenliveSettings::proxythreads()) m_proxyThreads.addFuture(QtConcurrent::run(this, &ProjectList::slotProcessJobs));
}
void ProjectList::slotAbortProxy(const QString id, const QString path)
}
}
-void ProjectList::slotGenerateProxy()
+void ProjectList::slotProcessJobs()
{
while (!m_jobList.isEmpty() && !m_abortAllJobs) {
emit projectModified();
QFile file(job->destination());
if (!file.open(QIODevice::WriteOnly)) {
for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), JOBCRASHED);
+ setJobStatus(processingItems.at(i), JOBCRASHED);
m_processingProxy.removeAll(job->destination());
delete job;
continue;
QFile::remove(job->destination());
for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), CREATINGJOB, 0); //, job->description);
+ setJobStatus(processingItems.at(i), CREATINGJOB, 0, job->jobType);
+
bool success;
QProcess *jobProcess = job->startJob(&success);
if (jobProcess == NULL) {
// job is finished
for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), success ? JOBDONE : JOBCRASHED);
+ setJobStatus(processingItems.at(i), success ? JOBDONE : JOBCRASHED);
if (success) {
- slotGotProxy(job->destination());
+ if (job->jobType == PROXYJOB) slotGotProxy(job->destination());
+ //TODO: set folder for transcoded clips
+ else if (job->jobType == CUTJOB) emit addClip(job->destination(), QString(), QString());
}
else {
QFile::remove(job->destination());
if (!m_closing) {
emit cancelRunningJob(job->clipId(), job->cancelProperties());
/*for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), NOJOB);*/
+ setJobStatus(processingItems.at(i), NOJOB);*/
}
else continue;
result = -2;
}
else {
int progress = job->processLogInfo();
- if (progress > -1) processLogInfo(processingItems, progress);
+ if (progress > -1) processLogInfo(processingItems, progress, job->jobType);
}
jobProcess->waitForFinished(500);
}
if (result == QProcess::NormalExit) {
// proxy successfully created
for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), JOBDONE);
- slotGotProxy(job->destination());
+ setJobStatus(processingItems.at(i), JOBDONE);
+ if (job->jobType == PROXYJOB) slotGotProxy(job->destination());
+ //TODO: set folder for transcoded clips
+ else if (job->jobType == CUTJOB) emit addClip(job->destination(), QString(), QString());
}
else if (result == QProcess::CrashExit) {
// Proxy process crashed
QFile::remove(job->destination());
for (int i = 0; i < processingItems.count(); i++)
- setProxyStatus(processingItems.at(i), JOBCRASHED);
+ setJobStatus(processingItems.at(i), JOBCRASHED);
}
delete job;
continue;
}
-void ProjectList::processLogInfo(QList <ProjectItem *>items, int progress)
+void ProjectList::processLogInfo(QList <ProjectItem *>items, int progress, JOBTYPE jobType)
{
for (int i = 0; i < items.count(); i++)
- setProxyStatus(items.at(i), CREATINGJOB, progress);
+ setJobStatus(items.at(i), CREATINGJOB, progress, jobType);
}
void ProjectList::updateProxyConfig()
}
CLIPTYPE t = item->clipType();
if ((t == VIDEO || t == AV || t == UNKNOWN) && item->referencedClip() != NULL) {
- if (generateProxy() && useProxy() && !item->isProxyRunning()) {
+ if (generateProxy() && useProxy() && !hasPendingProxy(item)) {
DocClipBase *clip = item->referencedClip();
if (clip->getProperty("frame_size").section('x', 0, 0).toInt() > m_doc->getDocumentProperty("proxyminsize").toInt()) {
if (clip->getProperty("proxy").isEmpty()) {
QFile::remove(proxyPath);
}
-void ProjectList::setProxyStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress)
+void ProjectList::setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress, JOBTYPE jobType)
{
if (item == NULL || m_abortAllJobs) return;
monitorItemEditing(false);
- item->setProxyStatus(status, progress);
+ item->setJobStatus(status, progress, jobType);
if (status == JOBCRASHED) {
DocClipBase *clip = item->referencedClip();
if (!clip) {
m_commandStack->push(command);
}
+bool ProjectList::hasPendingProxy(ProjectItem *item)
+{
+ if (!item || !item->referencedClip() || m_abortAllJobs) return false;
+ for (int i = 0; i < m_jobList.count(); i++) {
+ if (m_abortAllJobs) break;
+ if (m_jobList.at(i)->clipId() == item->clipId() && m_jobList.at(i)->jobType == PROXYJOB) return true;
+ }
+ if (item->isProxyRunning()) return true;
+ return false;
+}
+
+void ProjectList::deleteJobsForClip(const QString &clipId)
+{
+ QList <AbstractClipJob *> jobsToDelete;
+ for (int i = 0; i < m_jobList.count(); i++) {
+ if (m_abortAllJobs) break;
+ if (m_jobList.at(i)->clipId() == clipId) {
+ AbstractClipJob *job = m_jobList.takeAt(i);
+ delete job;
+ i--;
+ }
+ }
+}
+
+
+
#include "projectlist.moc"
#include "kdenlivesettings.h"
#include "folderprojectitem.h"
#include "subprojectitem.h"
+#include "projecttree/abstractclipjob.h"
#include <kdialog.h>
namespace Mlt
}
}
else if (proxy == JOBCRASHED) {
- proxyText = i18n("Proxy crashed");
+ proxyText = index.data(Qt::UserRole + 7).toString();
QRectF txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + proxyText + " ");
painter->setPen(Qt::NoPen);
painter->setBrush(option.palette.highlight());
/** @brief Prepares removing the selected items. */
void slotRemoveClip();
+ void slotAddClip(const QString url, const QString &groupName, const QString &groupId);
void slotAddClip(const QList <QUrl> givenList = QList <QUrl> (), const QString &groupName = QString(), const QString &groupId = QString());
/** @brief Adds, edits or deletes a folder item.
void slotForceProcessing(const QString &id);
/** @brief Remove all instances of a proxy and delete the file. */
void slotDeleteProxy(const QString proxyPath);
+ /** @brief Start a hard cut clip job. */
+ void slotCutClipJob(const QString &id, QPoint zone);
private:
ProjectListView *m_listView;
/** @brief Set the Proxy status on a clip.
* @param item The clip item to set status
- * @param status The proxy status (see definitions.h) */
- void setProxyStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress = 0);
+ * @param status The job status (see definitions.h) */
+ void setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress = 0, JOBTYPE jobType = NOJOBTYPE);
/** @brief Process ffmpeg output to find out process progress. */
- void processLogInfo(QList <ProjectItem *>items, int progress);
+ void processLogInfo(QList <ProjectItem *>items, int progress, JOBTYPE jobType);
void monitorItemEditing(bool enable);
/** @brief Get cached thumbnail for a project's clip or create it if no cache. */
void getCachedThumbnail(ProjectItem *item);
void getCachedThumbnail(SubProjectItem *item);
/** @brief The clip is about to be reloaded, cancel thumbnail requests. */
void resetThumbsProducer(DocClipBase *clip);
+ /** @brief Check if it is necessary to start a job thread. */
+ void startJobProcess();
+ /** @brief Check if a clip has a running or pending proxy process. */
+ bool hasPendingProxy(ProjectItem *item);
+ /** @brief Delete pending jobs for a clip. */
+ void deleteJobsForClip(const QString &clipId);
private slots:
void slotClipSelected();
void slotCreateProxy(const QString id);
/** @brief Stop creation of this clip's proxy. */
void slotAbortProxy(const QString id, const QString path);
- /** @brief Start creation of proxy clip. */
- void slotGenerateProxy();
+ /** @brief Start creation of clip jobs. */
+ void slotProcessJobs();
/** @brief Discard running and pending clip jobs. */
void slotCancelJobs();
/** @brief Discard a running clip jobs. */
/** @brief Set number of running jobs. */
void jobCount(int);
void cancelRunningJob(const QString, stringMap);
+ void addClip(const QString, const QString &, const QString &);
};
#endif
${kdenlive_SRCS}
projecttree/abstractclipjob.cpp
projecttree/proxyclipjob.cpp
+ projecttree/cutclipjob.cpp
PARENT_SCOPE
)
#include "definitions.h"
-enum JOBTYPE { PROXYJOB = 1, CUTJOB = 2};
+enum JOBTYPE { NOJOBTYPE = 0, PROXYJOB = 1, CUTJOB = 2};
class AbstractClipJob : public QObject
{
--- /dev/null
+/***************************************************************************
+ * *
+ * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "cutclipjob.h"
+#include "kdenlivesettings.h"
+#include "kdenlivedoc.h"
+
+#include <KDebug>
+#include <KLocale>
+
+CutClipJob::CutClipJob(CLIPTYPE cType, const QString &id, QStringList parameters) : AbstractClipJob(CUTJOB, cType, id, parameters)
+{
+ description = i18n("clip cut");
+ m_dest = parameters.at(0);
+ m_src = parameters.at(1);
+ m_start = parameters.at(2);
+ m_end = parameters.at(3);
+ m_jobDuration = parameters.at(4).toInt();
+ if (parameters.count() == 6) m_cutExtraParams = parameters.at(5).simplified();
+}
+
+QProcess *CutClipJob::startJob(bool *ok)
+{
+ // Special case: playlist clips (.mlt or .kdenlive project files)
+ if (clipType == AV || clipType == AUDIO || clipType == VIDEO) {
+ QStringList parameters;
+ parameters << "-i" << m_src;
+ parameters << "-ss" << m_start <<"-t" << m_end;
+ parameters << "-acodec" << "copy" << "-vcodec" << "copy";
+ if (!m_cutExtraParams.isEmpty()) {
+ foreach(const QString &s, m_cutExtraParams.split(' '))
+ parameters << s;
+ }
+
+ // Make sure we don't block when proxy file already exists
+ parameters << "-y";
+ parameters << m_dest;
+ m_jobProcess = new QProcess;
+ m_jobProcess->setProcessChannelMode(QProcess::MergedChannels);
+ kDebug()<<"// STARTING CIUT JOS: "<<parameters;
+ m_jobProcess->start("ffmpeg", parameters);
+ m_jobProcess->waitForStarted();
+ return m_jobProcess;
+ }
+ *ok = false;
+ return NULL;
+}
+
+int CutClipJob::processLogInfo()
+{
+ if (!m_jobProcess || m_jobDuration == 0) return -1;
+ QString log = m_jobProcess->readAll();
+ kDebug()<<log;
+ int progress;
+ // Parse FFmpeg output
+ if (log.contains("frame=")) {
+ int progress = log.section("frame=", 1, 1).simplified().section(' ', 0, 0).toInt();
+ kDebug()<<"// PROgress: "<<progress<<", DUR: "<<m_jobDuration;
+ return (int) (100.0 * progress / m_jobDuration);
+ }
+ else if (log.contains("time=")) {
+ QString time = log.section("time=", 1, 1).simplified().section(' ', 0, 0);
+ if (time.contains(':')) {
+ QStringList numbers = time.split(':');
+ progress = numbers.at(0).toInt() * 3600 + numbers.at(1).toInt() * 60 + numbers.at(2).toDouble();
+ }
+ else progress = (int) time.toDouble();
+ kDebug()<<"// PROgress: "<<progress<<", DUR: "<<m_jobDuration;
+ return (int) (100.0 * progress / m_jobDuration);
+ }
+ return -1;
+}
+
+CutClipJob::~CutClipJob()
+{
+}
+
+const QString CutClipJob::destination() const
+{
+ return m_dest;
+}
+
+stringMap CutClipJob::cancelProperties()
+{
+ QMap <QString, QString> props;
+ return props;
+}
+
+
--- /dev/null
+/***************************************************************************
+ * *
+ * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef CUTCLIPJOB
+#define CUTCLIPJOB
+
+#include <QObject>
+#include <QProcess>
+
+#include "abstractclipjob.h"
+
+
+class CutClipJob : public AbstractClipJob
+{
+ Q_OBJECT
+
+public:
+ CutClipJob(CLIPTYPE cType, const QString &id, QStringList parameters);
+ virtual ~ CutClipJob();
+ const QString destination() const;
+ QProcess *startJob(bool *ok);
+ stringMap cancelProperties();
+ int processLogInfo();
+
+private:
+ QString m_dest;
+ QString m_src;
+ QString m_start;
+ QString m_end;
+ QString m_cutExtraParams;
+ int m_jobDuration;
+};
+
+#endif
#include <KDebug>
#include <KLocale>
-ProxyJob::ProxyJob(JOBTYPE type, CLIPTYPE cType, const QString &id, QStringList parameters) : AbstractClipJob(type, cType, id, parameters),
+ProxyJob::ProxyJob(CLIPTYPE cType, const QString &id, QStringList parameters) : AbstractClipJob(PROXYJOB, cType, id, parameters),
m_jobDuration(0),
m_isFfmpegJob(true)
{
QStringList parameters;
parameters << "-i" << m_src;
QString params = m_proxyParams;
- foreach(QString s, params.split(' '))
- parameters << s;
+ foreach(const QString &s, params.split(' '))
+ parameters << s;
// Make sure we don't block when proxy file already exists
parameters << "-y";
Q_OBJECT
public:
- ProxyJob(JOBTYPE type, CLIPTYPE cType, const QString &id, QStringList parameters);
+ ProxyJob(CLIPTYPE cType, const QString &id, QStringList parameters);
virtual ~ ProxyJob();
const QString destination() const;
QProcess *startJob(bool *ok);
int video_max = 0;
int default_audio = producer->get_int("audio_index");
int audio_max = 0;
+
+ int scan = producer->get_int("meta.media.progressive");
+ filePropertyMap["progressive"] = QString::number(scan);
// Find maximum stream index values
for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) {
//static
-QString Timecode::getStringTimecode(int frames, const double &fps)
+QString Timecode::getStringTimecode(int frames, const double &fps, bool showFrames)
{
// Returns the timecode in an hh:mm:ss format
}
int seconds = (int)(frames / fps);
+ int frms = frames % (int) (fps + 0.5);
int minutes = seconds / 60;
seconds = seconds % 60;
int hours = minutes / 60;
text.append(QString::number(minutes).rightJustified(2, '0', false));
text.append(':');
text.append(QString::number(seconds).rightJustified(2, '0', false));
+ if (showFrames) {
+ text.append('.');
+ text.append(QString::number(frms).rightJustified(2, '0', false));
+ }
return text;
}
int getDisplayFrameCount(const QString &duration, bool frameDisplay) const;
int getFrameCount(const QString &duration) const;
static QString getEasyTimecode(const GenTime & time, const double &fps);
- static QString getStringTimecode(int frames, const double &fps);
+ static QString getStringTimecode(int frames, const double &fps, bool showFrames = false);
const QString getDisplayTimecodeFromFrames(int frames, bool frameDisplay) const;
const QString getTimecodeFromFrames(int frames) const;
double fps() const;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CutJobDialog_UI</class>
+ <widget class="QDialog" name="CutJobDialog_UI">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>359</width>
+ <height>171</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Cut Clip</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="0" colspan="2">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Cut file</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="2" column="0" colspan="2">
+ <widget class="QCheckBox" name="add_clip">
+ <property name="text">
+ <string>Add new clip to project</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <widget class="KUrlRequester" name="file_url">
+ <property name="mode">
+ <set>KFile::File|KFile::LocalOnly</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Save to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="info_label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Advanced</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QTextEdit" name="extra_params"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Extra parameters</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KUrlRequester</class>
+ <extends>QFrame</extends>
+ <header>kurlrequester.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>CutJobDialog_UI</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>CutJobDialog_UI</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>