*Make sure to use cut producer for slowmotion (to prevent setting in/out on master clip)

*Fix project duration not updated on clip copy
*Fix video/audio thumbs with speed effect
parent 6a385ee3
......@@ -475,6 +475,9 @@ std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer(Mlt::Profile *destProf
}
const QByteArray clipXml = c.get("string");
std::shared_ptr<Mlt::Producer> prod(new Mlt::Producer(destProfile ? *destProfile : *m_masterProducer->profile(), "xml-string", clipXml.constData()));
if (strcmp(prod->get("mlt_service"), "avformat") == 0) {
prod->set("mlt_service", "avformat-novalidate");
}
return prod;
}
......
......@@ -268,7 +268,7 @@ bool ClipModel::hasAudio() const
{
READ_LOCK();
QString service = getProperty("mlt_service");
return service.contains(QStringLiteral("avformat")) && (getIntProperty(QStringLiteral("audio_index")) > -1);
return (service.contains(QStringLiteral("avformat")) || service == QLatin1String("timewarp")) && (getIntProperty(QStringLiteral("audio_index")) > -1);
}
bool ClipModel::isAudioOnly() const
......@@ -349,7 +349,7 @@ Fun ClipModel::useTimewarpProducer_lambda(double speed, int extraSpace)
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(m_binClipId);
std::shared_ptr<Mlt::Producer> originalProducer = binClip->originalProducer();
bool limitedDuration = binClip->hasLimitedDuration();
return [originalProducer, speed, in, out, warp_in, warp_out, limitedDuration, this]() {
if (qFuzzyCompare(speed, 1.0)) {
m_producer.reset(originalProducer->cut(in, out));
......@@ -357,7 +357,8 @@ Fun ClipModel::useTimewarpProducer_lambda(double speed, int extraSpace)
QString resource = QString("timewarp:%1:%2").arg(speed).arg(originalProducer->get("resource"));
Mlt::Profile *prof = new Mlt::Profile(pCore->getCurrentProfilePath().toUtf8().constData());
std::shared_ptr<Mlt::Producer> warpProducer(new Mlt::Producer(*prof, resource.toUtf8().constData()));
m_producer = std::move(warpProducer);
// Make sure we use a cut so that the source producer in/out are not modified
m_producer.reset(warpProducer->cut(0, warpProducer->get_length()));
setInOut(in, out);
}
// replant effect stack in updated service
......
......@@ -88,6 +88,6 @@ template <typename Service> void MoveableItem<Service>::setCurrentTrackId(int ti
template <typename Service> void MoveableItem<Service>::setInOut(int in, int out)
{
QWriteLocker locker(&m_lock);
m_position = in;
//m_position = in;
service()->set_in_and_out(in, out);
}
......@@ -33,8 +33,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
bool TimelineFunctions::copyClip(std::shared_ptr<TimelineItemModel> timeline, int clipId, int &newId, PlaylistState::ClipState state, Fun &undo, Fun &redo)
{
// Special case: slowmotion clips
double clipSpeed = timeline->m_allClips[clipId]->getSpeed();
bool res = timeline->requestClipCreation(timeline->getClipBinId(clipId), newId, state, undo, redo);
timeline->m_allClips[newId]->m_endlessResize = timeline->m_allClips[clipId]->m_endlessResize;
// Apply speed effect if necessary
if (!qFuzzyCompare(clipSpeed, 1.0)) {
timeline->m_allClips[newId]->useTimewarpProducer(clipSpeed, -1, undo, redo);
}
// copy useful timeline properties
timeline->m_allClips[clipId]->passTimelineProperties(timeline->m_allClips[newId]);
......@@ -323,7 +329,7 @@ bool TimelineFunctions::requestItemCopy(std::shared_ptr<TimelineItemModel> timel
std::advance(it, target_track_position);
int target_track = (*it)->getId();
if (timeline->isClip(id)) {
res = res && timeline->requestClipMove(newId, target_track, target_position, true, false, undo, redo);
res = res && timeline->requestClipMove(newId, target_track, target_position, true, true, undo, redo);
} else {
const QString &transitionId = timeline->m_allCompositions[id]->getAssetId();
QScopedPointer <Mlt::Properties> transProps(timeline->m_allCompositions[id]->properties());
......
......@@ -196,9 +196,10 @@ Rectangle {
}
property bool variableThumbs: (isAudio || mltService === 'color' || mltService === '')
property bool isImage: (mltService === 'qimage' || mltService === 'pixbuf')
property string baseThumbPath: variableThumbs ? '' : isImage ? 'image://thumbnail/' + binId + '/' + mltService + '/' + clipResource + '#0' : 'image://thumbnail/' + binId + '/' + mltService + '/' + clipResource + '#'
property string inThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + inPoint
property string outThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + outPoint
property string serviceHolder: isImage ? 'image' : (mltService === 'timewarp' ? 'avformat' : mltService)
property string baseThumbPath: variableThumbs ? '' : 'image://thumbnail/' + binId + '/' + (isImage ? '#0' : '#')
property string inThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + Math.floor(inPoint * speed)
property string outThumbPath: (variableThumbs || isImage ) ? baseThumbPath : baseThumbPath + Math.floor(outPoint * speed)
DropArea { //Drop area for clips
anchors.fill: clipRoot
......
......@@ -46,25 +46,16 @@ void ThumbnailProvider::resetProject()
QImage ThumbnailProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
QImage result;
// id is binID/mlt_service/resource#frameNumber
int index = id.lastIndexOf('#');
if (true /*index != -1*/) {
QString binId = id.section('/', 0, 0);
QString service = id.section('/', 1, 1);
QString resource = id.section('/', 2);
int frameNumber = id.mid(index + 1).toInt();
resource = resource.left(resource.lastIndexOf('#'));
// id is binID/#frameNumber
QString binId = id.section('/', 0, 0);
bool ok;
int frameNumber = id.section('#', -1).toInt(&ok);
if (ok) {
if (ThumbnailCache::get()->hasThumbnail(binId, frameNumber, false)) {
result = ThumbnailCache::get()->getThumbnail(binId, frameNumber);
*size = result.size();
return result;
}
const QString key = binId + "#" + QString::number(frameNumber);
if (service == "avformat-novalidate")
service = "avformat";
else if (service.startsWith("xml"))
service = "xml-nogl";
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(binId);
if (binClip) {
std::shared_ptr<Mlt::Producer> prod = binClip->thumbProducer();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment