Hey everyone!!
I was recently guided toward ffmpeg for batch re-sizing video files and I've almost perfected it, but am running into a stumbling block with some files..
I have a folder containing many .flv and .mp4 files with varying resolutions.
All files need to be re-sized to 320 pixels in width, while maintaining the original aspect ratio, so frame heights will vary from file to file.
Included in the folder is the following batch file:
Code:set ffmpeg="C:\Program Files\ffmpeg\bin\ffmpeg.exe" for %%f in (*.flv) do %ffmpeg% -i "%%f" -vf scale=w=320:h=-1 -crf:v 20 -acodec copy -vcodec libx264 -threads 0 -f flv -y ".\RESIZED\%%f_resized.flv" for %%f in (*.mp4) do %ffmpeg% -i "%%f" -vf scale=w=320:h=-1 -crf:v 20 -acodec copy -vcodec libx264 -threads 0 -f mp4 -y ".\RESIZED\%%f_resized.mp4"
This works almost perfectly except for two issues..
1. A number of files in the destination folder are 0kb, and upon investigating I noticed ffmpeg returned the following error for each:
(sorry about the image.. i was having difficulty pasting the text)
... is there anyway to modify the command line so it doesn't error out when processing these files?
2. I've also noticed a slight affect to the framerates on the re-sized files.. its most noticeable when there is a long pan or steady movement across the screen.. Is this an unavoidable degradation due to the lossy nature of what im doing? .. or can the command line be tweaked to make the results as fluid as the original files?
Any help is greatly appreciated!!
Thanks!!
+ Reply to Thread
Results 1 to 3 of 3
-
-
Hi
height not divisible by 2
Where you have used scale=320:h=-1
I use:-
-vf "scale=320:trunc(ow/a/2)*2"
Code:ffmpeg -i foo.mp4 -vf "scale=320:trunc(ow/a/2)*2" -c:v libx264 -crf 23 -preset ultrafast -c:a copy foo_resized.mp4
Code:for %%f in (*.mp4) do %ffmpeg% -i "%%f" -vf "scale=320:trunc(ow/a/2)*2" -crf:v 20 -acodec copy -vcodec libx264 -threads 0 -f mp4 -y ".\RESIZED\%%f_resized.mp4"
-
^ genius
Worked like a charm! My endless thanks!!
Regarding the playback not being as smooth as the original files.. it looks like a dropped frame every now and then.. almost like a subtle hiccup that becomes more apparent during tracking shots or smooth camera panning.. is there anyway around that or is it just a side effect of re-sizing videos to a smaller resolution?
Similar Threads
-
[C++] How to read progress from CMD prompts like FFMPEG's
By squadjot in forum ProgrammingReplies: 5Last Post: 12th Feb 2021, 06:49 -
Line space/height in aegisub?
By supercain in forum EditingReplies: 2Last Post: 1st Jul 2012, 11:47 -
Using ffmped cmd line to create WinFF preset
By Yaro in forum Video ConversionReplies: 0Last Post: 18th Jul 2011, 15:33 -
cmd line tool to join two mpeg-2 files
By nighthawk2018 in forum Newbie / General discussionsReplies: 1Last Post: 1st Mar 2010, 22:13 -
Video info tool (cmd-line-way) wich one?
By squadjot in forum Video ConversionReplies: 2Last Post: 19th Sep 2008, 14:01