Exemplo n.º 1
0
Clip* Scene::duplicateClip(Clip *c)
{
	Clip *nc = createClip( c->getSource(), c->position(), c->start(), c->length() );
	nc->setFrameDuration( profile.getVideoFrameDuration() );
	nc->setSpeed( c->getSpeed() );
	Transition *t = c->getTransition();
	nc->setTransition( t ? new Transition(t) : NULL );
	
	FilterCollection *fc = FilterCollection::getGlobalInstance();
	for ( int i = 0; i < c->videoFilters.count(); ++i ) {
		QSharedPointer<GLFilter> f = c->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();
				f->duplicateFilter( nf );
				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() );
				}
				nc->videoFilters.append( nf.staticCast<GLFilter>() );
				break;
			}
		}
	}
	for ( int i = 0; i < c->audioFilters.count(); ++i ) {
		QSharedPointer<AudioFilter> f = c->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();
				f->duplicateFilter( nf );
				nc->audioFilters.append( nf.staticCast<AudioFilter>() );
				break;
			}
		}
	}
	
	return nc;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
Clip* XMLizer::readClip( QDomElement &element, QList<Source*> *sourcesList, Scene *scene, bool &readError )
{
	QDomNodeList nodes = element.childNodes();
	
	QString name;
	double posInTrack = 0;
	double startTime = 0;
	double length = 0;
	double speed = 1;
	bool okName = false, okPos = false, okStart = false, okLen = false;
	Clip *clip = NULL;
	
	speed = element.attribute( "speed" ).toDouble();
	if ( speed == 0.0 )
		speed = 1.0;
	
	for ( int i = 0; i < nodes.count(); ++i ) {
		QDomElement e = nodes.at( i ).toElement();
		if ( e.isNull() )
			continue;
		
		if ( e.tagName() == "Name" ) {
			name = e.text();
			okName = true;
		}
		else if ( e.tagName() == "PosInTrack" ) {
			posInTrack = e.text().toDouble();
			okPos = true;
		}
		else if ( e.tagName() == "StartTime" ) {
			startTime = e.text().toDouble();
			okStart = true;
		}
		else if ( e.tagName() == "Length" ) {
			length = e.text().toDouble();
			okLen = true;
		}
	}
	
	if ( !( okName && okPos && okStart && okLen ) ) {
		readError = true;
		return clip;
	}
	
	// check if source exists and create clip
	for ( int i = 0; i < sourcesList->count(); ++i ) {
		if ( sourcesList->at(i)->getFileName() == name ) {
			clip = scene->createClip( sourcesList->at(i), posInTrack, startTime, length );
			break;
		}
	}
	
	if ( !clip ) {
		readError = true;
		return clip;
	}
	
	clip->setSpeed( speed );
	
	for ( int i = 0; i < nodes.count(); ++i ) {
		QDomElement e = nodes.at( i ).toElement();
		if ( e.isNull() )
			continue;
		
		if ( e.tagName() == "VideoFilter" ) {
			QSharedPointer<Filter> f = readFilter( e, false, readError );
			if ( !f.isNull() ) {
				if ( f->getIdentifier() == "GLStabilize" ) {
					GLStabilize *stab = (GLStabilize*)f.data();
					stab->setSource( clip->getSource() );
				}
				clip->videoFilters.append( f.staticCast<GLFilter>() );
			}
		}
		else if ( e.tagName() == "AudioFilter" ) {
			QSharedPointer<Filter> f = readFilter( e, true, readError );
			if ( !f.isNull() )
				clip->audioFilters.append( f.staticCast<AudioFilter>() );
		}
		else if ( e.tagName() == "Transition" ) {
			readTransition( e, clip, readError );
		}
	}
	
	return clip;
}