Polishing Pitivi's viewer

In the Pitivi video editor, the viewer is quite important, as it shows the video. Our viewer also shows a discreet frame around a clip selected in the timeline, making it easy to resize and position the video of the clip by dragging. Below is the story of the viewer updates in the past year.

Easy resizing

It was a bit cumbersome to have to drag both the left and bottom margins of the viewer container to resize it. We thought it would be easier to resize the viewer by simply dragging the bottom-left corner of its container. Harish Fulara made time at the end of his GSoC 2018 internship for this, after he finished his main task, and it works great! — 25609f3a

Are we 100% yet?

In Pitivi, the project resolution is conveniently set for new projects to match the first imported video file, and can be changed at any time. This project resolution applies to the video content, which at the end is resized when displayed by the viewer, depending on the size of the viewer. Of course resizing introduces artifacts, so we need a way to have the viewer display the video content at 100%, pixel for pixel.

Without introducing any new confusing UI, the simplest thing we could do was to show the resize status while the viewer is resized. Now the video dims when you resize the viewer, to see clearly the resize percent, and then is restored after a timeout with no change in size.

By connecting to the widget’s width/height property-change signals, any size change is detected, irrespective of what caused it: the corner being dragged, or the window being maximized, etc. Thanks again to Harish and his GSoC for implementing this! —d91c1283

Sometimes it can be fiddly to set the viewer to 100%, since one pixel more and it’s not 1:1 anymore. We thought about improving it by introducing snapping.

Snapping

Unfortunately, with snapping you won’t be able to set your viewer size to 101%, but in return it’s much easier to target 100%. Now the 100..105% range is down-snapped to 100%, to make it easy to display the video content without any resize artifacts. Harish researched how we can do this, but as school took him over, yours truly recently made time to finish the implementation. —371581a0

[![](Peek 2019-02-15 00-34.gif)](Peek 2019-02-15 00-34.gif)

Once merged, looking back at my commit, like everybody does from time to time, ..closely, some code cleanup commits popped up, like mushrooms after rain. It’s pretty cloudy in Zurich.

Better trimming preview

Normally the viewer is used to display the project video at the playhead position, but we also use it to display the start or end margins of a clip when it is being trimmed.

A long time ago it used to be the case that we had to limit the seek rate when trimming, for performance reasons, but now the seek is done async and our pipeline is smart enough to skip scheduled seeks if new ones come in. With the limit removed, now the trim preview is more precise and (up to 200ms) snappier. —42a7dc01

The code responsible for the switch between the project video widget and the clip video widget, when starting/finishing a trim operation, was very complex. It was checking in quite a few places, which one are we dealing with: the pipeline of the project or the pipeline of the trimmed clip. By keeping separate references to both, the logic is now much easier to read. As a bonus, now when the trim is finished, we directly display the project video, without having to wait for the pipeline state to go from NULL to PAUSED. —03e15b44

When a trim operation was being started, the trim preview was flickering. This was more noticeable when the end of the clip was trimmed. The first frame of the clip was being displayed for a split second before the first seek is done. Now we simply wait for the first seek to be performed before switching the viewer to show the trimming preview. —6d49ee54

It takes a very short time until the pipeline for a clip trim preview is ready, but why not have it instantly? At least when the user is focused on a handful of clips adjusting and trimming them, a cheap cache now does the job. —ec9ca33b

Contributing to Pitivi

Pitivi benefits from the GStreamer multimedia framework used on most Linux desktops and we contribute back in multiple ways. We could use some more hands on Pitivi. Contributions of any type would be greatly appreciated. Come chat with us. If you’re a student, you can join us doing a GSoC internship this summer!