I am taking an very high quality 8k video and I want to try to get as good a 4k video out of it as possible. But at the same time I want to remove the sides of the video as well as the bottom, but not the top, making almost a 'T' shaped video, like so:
As I understand it it should be possible for me to do all of this in one command but I am running into some trouble. Here is the command(s) I have tried:
First one is based on this post:
ffmpeg -i "8k.test.mp4" -preset slow -vcodec libx265 -crf 18 -movflags faststart -filter_complex "[1]scale=3840:2160 [2]drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill,drawbox=w=3840:h=300:x=0:y=2160-300:t=fill" -an -c:a copy output.mp4
Error
[AVFilterGraph @ 0000029c747cf540] Unable to parse graph description substring: "drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill,drawbox=w=3840:h=300:x=0:y=2160-300:t=fill" Error initializing complex filters. Invalid argument
Second one is based on this post:
ffmpeg -i "8k.test.mp4" -preset slow -vcodec libx265 -crf 18 -movflags faststart -vf scale=3840:2160, drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill,drawbox=w=3840:h=300:x=0:y=2160-300:t=fill -an -c:a copy output.mp4
Error:
[NULL @ 000001f5ee5d1500] Unable to find a suitable output format for 'drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill,drawbox=w=3840:h=300:x=0:y=2160-300:t=fill' drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill,drawbox=w=3840:h=300:x=0:y=2160-300:t=fill: Invalid argument
I seem to be misunderstanding something, according to the documentation commands in same catgegory should be seperated by 'comma' and different category by 'semicolon'. But I have tried both to no avail.
Filters in the same linear chain are separated by commas, and distinct linear chains of filters are separated by semicolons.
from here.
Would anyone know how to get about this?
Seems I found the solution, I was putting spaces after the comma, this way causing issues.
The correct command was as follows:
ffmpeg -i <INPUT>.mp4 -preset slow -vcodec libx265 -crf 18 -movflags faststart -vf scale=3840:2160,drawbox=w=450:h=1280:x=0:y=640:t=fill,drawbox=w=450:h=1280:x=3840-450:y=640:t=fill,drawbox=w=3840:h=400:x=0:y=2160-400:t=fill -an -c:a copy <OUTPUT>.mp4
However, a side note in my use case that perhaps someone can try and explain.
If I run the above command I will get a video file that has really good quality and the boxes the way I want them but with a file size of 350MB for 20 seconds.
However if I run the following command:
ffmpeg -i <INPUT-FILE> -vf scale=3840:2160 -preset slow -vcodec libx265 -crf 0 -movflags faststart -an -c:a copy <OUTPUT-NAME>.mp4
And then follow it with this command:
ffmpeg -i <INPUT-FILE> -vf drawbox=w=450:h=1280:x=0:y=640:t=fill,drawbox=w=450:h=1280:x=3840-450:y=640:t=fill,drawbox=w=3840:h=400:x=0:y=2160-400:t=fill -c:a copy <OUTPUT-NAME>.mp4
Then I get a file that is only 106MB yet the quality difference is negligable. I am happy that I have run all these tests because in my case I would much rather want a file that is under a third of the size with quality that is hard to distinguish.
I use https://www.diffchecker.com/image-diff/ to check the difference.