Ejemplo n.º 1
0
bool Scene::setProfile( Profile &p )
{
	bool ok = true;
	double duration = profile.getVideoFrameDuration();
	profile = p;
	double margin = profile.getVideoFrameDuration() / 4.0;
	
	if ( duration != profile.getVideoFrameDuration() ) {
		duration = profile.getVideoFrameDuration();
		for ( int i = 0; i < tracks.count(); ++i ) {
			Track *t = tracks[i];
			for ( int j = 0; j < t->clipCount(); ++j ) {
				Clip *c = t->clipAt( j );
				c->setFrameDuration( duration );
				double newPos = nearestPTS( c->position(), duration );
				if ( !c->getTransition() && j > 0 ) {
					Clip *prev = t->clipAt( j - 1 );
					if ( newPos < prev->position() + prev->length() - margin )
						newPos = prev->position() + prev->length();
					c->setPosition( newPos );
				}
				else if ( canMove( c, c->length(), newPos, i ) )
					move( c, i, newPos, i );
				else
					ok = false;
			}
		}
	}
	
	return ok;
}
Ejemplo n.º 2
0
void Scene::moveMulti( Clip *clip, int clipTrack, double newPos )
{
	QMutexLocker ml( &mutex );
	
	if ( clip->position() == newPos )
		return;
	
	double delta = newPos - clip->position();
	double margin = profile.getVideoFrameDuration() / 4.0;
	Track *t = tracks[clipTrack];
	int count = t->clipCount();
	int clipIndex = 0;
	int k = 0;
	while ( k < count ) {
		Clip *c = t->clipAt( k );
		// find clip
		if ( c == clip ) {
			clipIndex = k;
			break;
		}
		++k;
	}

	removeTransitions( clip, clipTrack, clipTrack, clipIndex, newPos, clip->length(), margin, true );
	clip->setPosition( clip->position() + delta );
	while ( ++k < count ) {
		Clip *c = t->clipAt( k );
		c->setPosition( c->position() + delta );
	}
	updateTransitions( clip, clipTrack, margin );
	clip->setInput( NULL );
	
	update = true;
}
Ejemplo n.º 3
0
Clip* Scene::sceneSplitClip( Clip *clip, int track, double pts )
{
	pts = nearestPTS( pts, profile.getVideoFrameDuration() );
	
	double start = clip->position();
	if (clip->getTransition()) {
		start += clip->getTransition()->length();
	}
	double end = clip->position() + clip->length();
	Track *t = tracks[track];
	int cc = t->clipCount();
	int index = t->indexOf(clip);
	Transition *tail = NULL;
	Clip *next = NULL;
	if (index > -1 && index < cc - 1) {
		next = t->clipAt(index + 1);
		if (next->getTransition()) {
			end -= next->getTransition()->length() + profile.getVideoFrameDuration();
			tail = new Transition(next->getTransition());
		}
	}

	double oldLength = clip->length();
	double newLength = pts - clip->position();
	
	resize( clip, newLength, track );
	Clip *nc = createClip( clip->getSource(), pts, clip->start() + newLength, oldLength - newLength );
	double newPos = nc->position();
	nc->setPosition( newPos );
	FilterCollection *fc = FilterCollection::getGlobalInstance();
	for ( int i = 0; i < clip->videoFilters.count(); ++i ) {
		QSharedPointer<GLFilter> f = clip->videoFilters.at( i );
		for ( int j = 0; j < fc->videoFilters.count(); ++j ) {
			if ( fc->videoFilters[ j ].identifier == f->getIdentifier() ) {
				QSharedPointer<Filter> nf = fc->videoFilters[ j ].create();
				GLFilter *gf = (GLFilter*)nf.data();
				if ( nf->getIdentifier() == "GLCustom" ) {
					GLCustom *gc = (GLCustom*)gf;
					gc->setCustomParams( f->getParameters().last()->value.toString() );
				}
				else if ( nf->getIdentifier() == "GLStabilize"  ) {
					GLStabilize *gs = (GLStabilize*)gf;
					gs->setSource( nc->getSource() );
				}
				f->splitParameters( gf, newLength );
				nf->setPosition( nc->position() );
				nf->setLength( nc->length() );
				nc->videoFilters.append( nf.staticCast<GLFilter>() );
				break;
			}
		}
	}
	for ( int i = 0; i < clip->audioFilters.count(); ++i ) {
		QSharedPointer<AudioFilter> f = clip->audioFilters.at( i );
		for ( int j = 0; j < fc->audioFilters.count(); ++j ) {
			if ( fc->audioFilters[ j ].identifier == f->getIdentifier() ) {
				QSharedPointer<Filter> nf = fc->audioFilters[ j ].create();
				AudioFilter *af = (AudioFilter*)nf.data();
				f->splitParameters( af, newLength );
				nf->setPosition( nc->position() );
				nf->setLength( nc->length() );
				nc->audioFilters.append( nf.staticCast<AudioFilter>() );
				break;
			}
		}
	}
	addClip( nc, track );
	if (tail) {
		next->setTransition(tail);
	}

	return nc;
}