1 |
On Wednesday, 23 November 2022 18:17:53 GMT Dale wrote: |
2 |
> Frank Steinmetzger wrote: |
3 |
> > Am Wed, Nov 23, 2022 at 06:16:12AM -0600 schrieb Dale: |
4 |
|
5 |
> >> P. S. Now I'm trying to figure out how to change the resolution of all |
6 |
> >> videos in a directory. Usually going from 1080p to 720p. If you have a |
7 |
> >> script for that, awesome. |
8 |
> > |
9 |
> > I use ffmpeg for all my encoding stuff, and have been using wrapper |
10 |
> > scripts |
11 |
> > for years now to make things easier. However, none of them has resized |
12 |
> > yet. |
13 |
> > It’s not difficult to configure, but the wrapper needs much more logic. As |
14 |
> > in: find out the current resolution, see if it is actually larger, then |
15 |
> > calculate the new resolution while keeping the aspect intact and so on. |
16 |
> |
17 |
> I found commands for it but not a way to process lots of videos. Right |
18 |
> now, I use the queue feature of handbrake. I set up a preset to make it |
19 |
> the same each time. I set it to 720p and about 3MB data rate. Should |
20 |
> be OK for my 32" TV. |
21 |
|
22 |
It depends how close you sit to the 32" screen. The closer you are the higher |
23 |
the resolution needed to avoid seeing individual pixels. If the size of the |
24 |
file is not important, I'd leave it at 1080p. You never know, you may obtain |
25 |
a bigger TV in the future. |
26 |
|
27 |
With ffmpeg you can use its scale filter to retain the same aspect ratio, but |
28 |
reduce the height: |
29 |
|
30 |
ffmpeg -i blah-1080.mp4 -vf scale=-1:720 -codec:v libx264 -crf 0 -codec:a aac |
31 |
blah-720.mp4 |
32 |
|
33 |
NOTES: |
34 |
|
35 |
1. Run ffprobe to see what the original video codecs are and use an |
36 |
appropriate video/audio codec to suit your desired output. The video will |
37 |
have to be transcoded to a lower resolution, but the audio can be just copied |
38 |
over. |
39 |
|
40 |
2. The -crf controls the quality of the quantizer - default is 23. I've set |
41 |
it at 0 to make it lossless, but this takes longer to process. You could |
42 |
instead use some tuning preset provided in the H.264 encoding guide linked to |
43 |
below: |
44 |
|
45 |
https://ffmpeg.org/ffmpeg-filters.html#scale |
46 |
|
47 |
https://trac.ffmpeg.org/wiki/Scaling |
48 |
|
49 |
http://trac.ffmpeg.org/wiki/Encode/H.264 |
50 |
|
51 |
|
52 |
Once you find your desired stanza to arrive at some optimal size-quality- |
53 |
processing time, you can modify Frank's script to resize and rename your |
54 |
videos. |