On Wednesday, 23 November 2022 18:17:53 GMT Dale wrote:
> Frank Steinmetzger wrote:
> > Am Wed, Nov 23, 2022 at 06:16:12AM -0600 schrieb Dale:

> >> P. S.  Now I'm trying to figure out how to change the resolution of all
> >> videos in a directory.  Usually going from 1080p to 720p.  If you have a
> >> script for that, awesome.
> > 
> > I use ffmpeg for all my encoding stuff, and have been using wrapper
> > scripts
> > for years now to make things easier. However, none of them has resized
> > yet.
> > It’s not difficult to configure, but the wrapper needs much more logic. As
> > in: find out the current resolution, see if it is actually larger, then
> > calculate the new resolution while keeping the aspect intact and so on.
> 
> I found commands for it but not a way to process lots of videos.  Right
> now, I use the queue feature of handbrake.  I set up a preset to make it
> the same each time.  I set it to 720p and about 3MB data rate.  Should
> be OK for my 32" TV. 

It depends how close you sit to the 32" screen.  The closer you are the higher 
the resolution needed to avoid seeing individual pixels.  If the size of the 
file is not important, I'd leave it at 1080p.  You never know, you may obtain 
a bigger TV in the future.

With ffmpeg you can use its scale filter to retain the same aspect ratio, but 
reduce the height:

ffmpeg -i blah-1080.mp4 -vf scale=-1:720 -codec:v libx264 -crf 0 -codec:a aac 
blah-720.mp4

NOTES:

1. Run ffprobe to see what the original video codecs are and use an 
appropriate video/audio codec to suit your desired output.  The video will 
have to be transcoded to a lower resolution, but the audio can be just copied 
over.

2. The -crf controls the quality of the quantizer - default is 23.  I've set 
it at 0 to make it lossless, but this takes longer to process.  You could 
instead use some tuning preset provided in the H.264 encoding guide linked to 
below:

https://ffmpeg.org/ffmpeg-filters.html#scale

https://trac.ffmpeg.org/wiki/Scaling

http://trac.ffmpeg.org/wiki/Encode/H.264


Once you find your desired stanza to arrive at some optimal size-quality-
processing time, you can modify Frank's script to resize and rename your 
videos.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to