Files follow the pattern data_1.zip, data_2.zip, … data_500.zip.
All the files are in “https://examples.com/downloads”.
Files have from kilobytes to gigabytes in size.
Solution:
A naive Bash script to download the files using wget.
It is set to use wget with -c (continue). This will skip files already downloaded and continue files that have been interrupted. This only works with FTP/HTTP servers that support the “Range” header.
#!/bin/bash
set -euxo pipefail
PREFIX="https://examples.com/downloads/data_"
for i in $(seq 1 500); do
wget -c "$PREFIX"_"$i".zip
done
[bash]
#!/bin/sh
for image in *.png;
do
convert $image -matte -virtual-pixel transparent \
-distort Perspective \
‘60,90 0,0 50,415 0,720 582,418 1280,720 589,147 1280,0’ \
p_$image
done
[/bash]
Now I have images in the format p_00000001.png to p_00007563.png. Because PNG is a lossless format, the perspective lost less information in this step than it would if step 2 was outputting jpgs.
Step 5) Convert frames to jpgs using ImageMagick and ShellScript.
[bash]
#!/bin/sh
for image in p_*.png;
do
convert $image "${image/.png/}.jpg"
done
[/bash]
Where “${image/.png/}.jpg” removes the .png in the image string.
Ps: this step is not really necessary as you could use png as input to ffmpeg.
‘%08d.jpg’ means a 8 digits filled with zeros in the left followed by .jpg, in this case 00000001.jpg to 00007563.jpg.
With this, I have the output.mp4 video ready to upload.
The whole process took several hours and a total 13GiB, although the final video has only 96 MiB. This could be optimized using pipelines and parallelism if it was needed to repeat the process.