I’d like to do a Timelapse and created the initial video using ffmpeg and image2. I used the full resolution frames (8000x4000 or so…) to create a lossless huffyuv video (24fps) because I figured that high quality input means high quality output. I then applied the Rotate and Scale Filters to do some zooming and panning (also tried Size and Position).
However, the resulting video (1920x1080, 24fps) after export is of awful quality (see screenshot below) compared to the input images which are crystal clear.
I’ve set the Interpolation method to “Hyper/Lanczos” in Advanced Mode, but that didn’t help.
Shotcut v19.09.14. I’ve tried several input sources varying in Size and Quality (Huffyuv, FFV1, H264 CRF0).
Only an idea…
Have you tried in a draw program (e.g. Paint.Net, Photoshop)?
To see, if there is also a lost in the quality…
It can be, IMHO, that the downsize is the reason…
Scale the input video (the lossless huffyuv thing) to 1920x and encode it to h264 with FFMPEG
(ffmpeg -i input.mkv -vcodec h264 -vf scale=1920:-1 output.mkv)
Scale & Crop the input video (the lossless huffyuv thing) to 1920x1080 and encode it to h264 using shotcut’s Rotate & Scale Filter. I did not introduce any movement (panning).
Below are screenshots. The first two options show perfect quality, the Shotcut option is significantly degraded. I don’t understand why.
You are comparing things that do not make sense to compare:
input is an image of “8000x4000 or so…” resolution
input is a video of unspecified resolution with no filter effect
input is the same video with filter effects
You said you created a huffyuv video from the images. What is the resolution of this video?
I suspect either the video resolution is low or the interpolation option is not reaching the filter for some reason, and it is default to a lower quality default.
Here I opened a photo that is 5152x3864 in Shotcut, added the Size and Position filter to crop and scale it. Then, I exported it using defaults plus Hyper/Lanczos without hardware encoder.
What is your operating system? (could be a build-related problem)
How are you making your screenshot for the Shotcut result? Best not to use screenshot and instead export a frame of video. I used VLC to do that. If you are really making a screenshot you are subject that program’s preview quality. In Shotcut, that depends on Settings > Interpolation as well as Video Mode.
$ uname -a
Linux monolith 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
However, I think I solved the problem partly:
I used two instances of the Rotate & Scale filter because I didn’t use keyframes properly.
Let me explain. I wanted to zoom in and pan to a starting point at t=00:00:00. For that I used a Rotate & Scale filter with z=175%, x=xxx and y=yyy, but did not define keyframes for that filter.
Then, I instatiated another Rotate & Scale filter because I wanted to zoom out and pan to the “full” picture. For that filter I enabled keyframes. Because of the first filter I had to define values somewhat like z=75%, x=xxx & y=yyy, instead of z=100%, x=0 & y=0. I put the second filter on top of the first, otherwise this would not work.
However, that caused the degradation in quality! Now, I’ve defined only one Rotate & Scale instance but with keyframes. The first keyframe is at t=00:00:00 with z=175%, x=xxx, y=yyy. The second keyframe is at the end of the video with z=100%, x=0, y=0.
From here on I will only talk about Videos which are generated using 1 Rotate & Scale instance
(I’ve also disabled the hardware encoder for now)
This improved the quality drastically. You’ll notice though, that the quality is still not en par with the original image. But I’d attribute that to the video compression.
It also helps to know what build you are using, i.e. how did you get Shotcut?
However, I still have a problem with “jittering”.
This is a common problem when animating images with a lot of detail in any software. You need to apply a small amount of Blur: Low Pass Some tools automatically perform something like this in their canned slow pan/zoom effects but not Shotcut.
suggest a problem with MLT
It is using a MLT-native effect, but I hesitate to call it a bug. The first use of Rotate & Scale utilizes the the full resolution of the source. The second use of it must use the output of the first filter, and that will not be good. Libavfilter and zoompan does not offer keyframed animation.
Via the Ubuntu Snap Store. Please have a look at the screenshot below.
I tried that one out, one with a value of 4.0 and one with the default value of 20.0.
With 4.0 I still can see a lot of jitter, while with 20.0 the blur is really strong and there’s still some jitter in the strongest details.
I understand that using two Rotate & Scale instances is a bad idea when you can do everything with one instance. That was clearly an mistake on my side. However, what I don’t understand is, why ffmpeg produces a jitter free, crisp sharp output while MLT does not?
It is not jitter-free to my eyes and has some detail-crawl/moire effect. I have done an analysis of the zoompan code, but here is the code in MLT if you want to try to improve upon it yourself:
My suggestion was to use Sharpen, Amount < 50% before the Rotate & Scale or Size and Position.
I am having trouble to reproduce as bad a case as yours with my photos. Mine tend to be lower res (~4000x3000) and denoised a little via JPEG. Do you care to make one of your pics available for me and others to experiment?
I looking into libasvfilter zoom pan. It uses libswscale, which is a simple 2D scaler. MLT uses libswscale for inherent scaling, but Rotate & Scale and Size and Position are using an affine transform. Might be related to that
Hi, sorry for the late reply, I’ve been out and offline.
Well, then I prefer that over the jitter. It’s less worse in my eyes (subjective of course).
Even if I had the time to dig into the code I still lack domain specific knowledge.
I tried that out and it improves things a bit, but the problem is still there.
However, after turning off Sharpening in my RAW converter, it improved once more.
Here’s one thing I noticed after playing with Rotate & Scale a bit more: Panning does not cause jitter, but Zooming does. It does not play a role whether I zoom out or in, as soon as I simply zoom (without panning) there’s jitter. If I just pan without zooming there’s no jitter.
frame_0000_no_sharpen.tif - RAW export without Sharpen frame_0000_pre_sharpen.tif - RAW export with Sharpen timelapse_no_sharpen_huffyuv_3s.mkv - 3 seconds of HUFFYUV (lossless) video encoded from frames without Sharpen timelapse_pre_sharpen_huffyuv_3s.mkv - 3 seconds of HUFFYUV (lossless) video encoded from frames with Sharpen
The TIFs are each ~200MB. The video files ~5GB. Please give me a short notice when you’ve downloaded them, because they take up a substantial bit of my Google Drive allowance.
I did notice the better quality of the ffmpeg panzoom animation when I played the video fullscreen. I saw the moire effect while playing smaller size embedded in the page. This downscaled playback is yet another example of how high detail/frequency interacts with scaling during animation.
I have downloaded the files you provided. You can remove them now;.
One thing to note is that a sharpen routine does increase the frequency around edges and existing detail, which will contribute to this.