Changing Sequencer Section End Range in C++

I am trying to create a plugin function that generates a level sequencer and creates a camera cut with a selected actor. I have been able to create the Level Sequencer, add selected actors, create the camera cut and add the actor to the camera cut but the Section Range End automatically is set to 0. Below is my attempt to change it but it doesn’t change the setting. Just to clarify, in the picture below I am trying to change the “Section End Range” in code.

If someone could explain how to do this in blueprints that would also be helpful :slight_smile:

UMovieSceneTrack* MovieTrack = LevelSequence->MovieScene->AddCameraCutTrack(UMovieSceneCameraCutTrack::StaticClass());
	UMovieSceneSection* Section = MovieTrack->CreateNewSection(); 
	UMovieSceneCameraCutSection* CameraCutSection = Cast<UMovieSceneCameraCutSection>(Section); 
	CameraCutSection->SetFlags(RF_Transactional); 
	CameraCutSection->Modify(); 
	CameraCutSection->SetCameraGuid(GuidTripod);
	FFrameNumber number = 90;
	number.Value = FMath::FloorToInt(90);
	//float number = 90; 
	CameraCutSection->SetEndFrame(number);
	CameraCutSection->SetRange(TRange<FFrameNumber>::Inclusive(0, 90));
	MovieTrack->AddSection(*CameraCutSection);

i also have this problem in 4.26. i also tried to use “FindOrExtendSection” of the owning track to hopefully extend the track to the given frame number but still it is [0,0].

any solution to this yet?

ok so i just found out myself. for some obscure reason frame times need to be multiplied by 800. if i create a section in editor with 0-1 and i print the actual range in c++, i get 0-800 and so on.changing the frame rate in sequencer does not seem to affect it.

so what i did is just always multiply the frame time by 800 and suddenly it works. so in your example if you do exactly as you posted and use 90x800 instead of only 90, it should work.

would be interesting to get some information from epic about this tho. why is it that way? will it change? is there a way to get this value of 800 anywhere in code so we are safe if it changes?

Hi, bit late but thought I’d explain as the actual answer is not listed here.

Matt Hoffman (programmer at Epic Games building cinematic tools) answered this for me before.

Tick resolution.

24,000 ticks per second at 30fps display rate = 800 ticks per frame, so frame 1 = tick 800

So essentially you have the frames as they’re displayed to the user (the Display Rate frames).

As well as the frames how they’re actually interpreted under the hood. Where frame 1 = 800. This also ties into how there are what the engine calls Sub Frames.
e.g. Make Qualified Frame Time node can have a Sub Frame (float) input.

There are functions for converting times where you can pass it the framerate for DisplayRate/Tick Resolution (which you can get off the UMovieScene) which does the conversion for you and appropriately handles sub-frames, etc.

Some useful nodes to remember (they ofc have c++ equivalents) are Get Display Rate, Get Tick Resolution and MakeQualifiedFrameTime.
Note that you may need to enable the Sequencer Scripting plugin to get these nodes.

Also remember it is possible to change the Desired Tick Interval as well as the Sequence Display Rate (both inside Sequencer if you click on the 30fps button; Desired Tick Interval in Advanced menu).

So I’d definitely recommend using these values to multiply with rather than always multiplying by 800.

That value might work most of the time. But it’s best to make sure it works all the time.

Also yay first post , finally giving back to the forums that helped me many times before! \o/

1 Like

Here’s some notes as well: Sequencer Time Refactor Technical Notes | Unreal Engine 4.27 Documentation

1 Like

I have same demand as you, I don’t know can you see it,I can’t add camera to the camera cut, here is my code

    UWorld* World = GWorld->GetWorld();
    ACameraActor* CameraActor = World->SpawnActor<ACameraActor>(ACameraActor::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);
    const FGuid CameraGuid = CameraActor->GetActorGuid();

    UMovieSceneTrack* MovieTrack = LevelSequence->MovieScene->AddCameraCutTrack(UMovieSceneCameraCutTrack::StaticClass());
    UMovieSceneSection* Section = MovieTrack->CreateNewSection();
    UMovieSceneCameraCutSection* CameraCutSection = Cast<UMovieSceneCameraCutSection>(Section);
    CameraCutSection->SetFlags(RF_Transactional);
    CameraCutSection->Modify();
    CameraCutSection->SetCameraGuid(CameraGuid);
    FFrameNumber number = 90;
    //float number = 90; 
    CameraCutSection->SetEndFrame(number);
    CameraCutSection->SetRange(TRange<FFrameNumber>::Inclusive(0, 90));
    MovieTrack->AddSection(*CameraCutSection);

It looks like the problem of camera’s guid, I want to know how to get right camera’s guid