I have a large number of lecture files directly from the camcorder. Hence, these are huge .MTS files. They are taking up almost 800 GB right now with each hour-long lecture being around/over a GB or even 2. I am very new to the encoding area and only know a few things from different quality anime I download and why their file sizes vary so much because of bitrate.
As for my goal, since they are simply lectures, I don't care much about video quality. I only look at it for facial/hand expressions and in case any powerpoint slides (latter very rarely). The most important thing is just not toooo blurry on a computer screen (32" monitor max) and having OK audio since the primary thing is to listen.
While digging the internet, I found this option to convert MTS to MP4 for individual files while controlling the quality through this CRF parameter
This does a very good job of getting a 1.97 GB file down to just 122 MB. However, it also takes it from 1080p to 480p without my control. The audio is bearable though I'd prefer a bit above. Funny when I used it yesterday on another file (can't find it right now), it gave me around 240 MB, 480p, but almost identical audio. This is OK but if I could somehow control the audio to be a bit better and make it batch, I'd probably be good.Code:ffmpeg -i input.mts -crf 23 -s vga output.mp4 -preset veryfast
While looking for a batch method, I found this code
This is in batch form so it's good. But it gives me 700 MB, 1080p, with good audio. Too big files. I want some batch form that gives 240 MBish like the previous code (good audio, 480p or 720p) but in batch form.Code:for %%a in ("*.*") do ffmpeg -i "%%a" -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k "D:\Converted\%%~na.mp4"
As a bonus, since these are in well-structured folders, is it possible to write them in a similar folder structure in another drive? The above code is being run on an external drive but writing new files to the "Converted" folder in D drive. This is because I don't have the space in the external right now to make new copies of 800 GB of files. It's best if FFMPEG can make the files with the same names in folders with the same names in a folder/drive of my choice. Is that possible?
+ Reply to Thread
Results 1 to 14 of 14
for %%a in ("*.mts") do ( md "D:%%~pa" ffmpeg -i "%%a" -vf scale=w=1280:h=-4 -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k "D:%%~pna.mp4" ) pause
FFMPEG run on it twice at the same CRF value, will give 2 different file sizes?
The bad news, unfortunately, is it's only converting the file(s), if any, in the main folder, nothing in the subfolders. Do you know what could be the problem?
ffmpeg calculates the correct size for you using the absolute value of the number as the modulus. You can always specify the exact size yourself for example "-vf scale=w=960:h=720" for a 4:3 source. Keep in mind that any small text may become unreadable if you reduce the frame size too much.
will downscale to 1280 by the nearest mod 4 height that's necessary to keep the aspect ratio. It will place the new files in the same folder tree on drive D:. You can decrease the file size by using a higher crf value (and hence lower picture quality), or by using a smaller frame size (trading off resolution to get smaller files). Note that crf encoding doesn't guarantee the final file size because some videos will compress more than others. So two source videos that are exactly the same size may result in very different sizes after compression.
No, the same file encoded twice will be the same size. But two different videos of the same frame size, frame rate, and running time may turn out with very different sizes because of the picture content. Foe example, an action movie will turn out much larger than a lecture full of static pie charts, text, etc.
This is OK but if I could somehow control the audio to be a bit better and make it batch, I'd probably be good.
for /R %%a in ("*.mts") do ( md "D:%%~pa" ffmpeg -i "%%a" -vf scale=w=960:h=-4 -c:v libx264 -preset medium -crf 25 -c:a copy "D:%%~pna.mp4" ) pauseThis is in batch form so it's good. But it gives me 700 MB, 1080p, with good audio.
A good reason to recompress the audio would be to make it "more audible" if it's too weak in the original recordings, with a normalization or dynamic range compression processing. In this case, for optimal quality, it would be better to use QAAC rather than ffmpeg's internal AAC encoder, or at least use a higher bitrate than 128k to preserve the audio signal as much as possible. There's a --normalize option in QAAC which may be enough for that purpose, but if there are already peaks near the limit (due for instance to someone coughing or clapping hands next to the recording device) then it won't do much, in this case a more advanced dynamic range compression processing would be needed, I don't know if there's a way to automate it efficiently.
Last edited by abolibibelot; 9th Jul 2020 at 10:51.
I was trying to post after everything was done to give feedback but it's looking good so far on the files I have tried, so I am commenting now since it's going on for >a day now.
I now have a simple code that does the job better than I ever imagined! Big thanks to both of you! Will let you know if I have anymore problems/questions.
Last edited by jagabo; 11th Jul 2020 at 20:40.
Since I am looking for a reasonably fast process
If bloodtalon's profile is correct, using QS on a i7-4790K probably won't be much faster than x264 at veryfast. And it will be lower quality (per bitrate). It is less CPU intensive so he may want to try it anyway.
I just finished and the 800 GB library came down to 100! I am so glad. I did find out it terminated early because around 1/3rd of the files were actually .mov so I had to rerun the batch file with .mts changed to .mov in the first line. A quick google search seems to show there is no easy "or" operator in cmd though.
Yeah it's an i7-4790K. You mean QS helps in weaker CPUs because it is less CPU intensive? Mine is pretty old, 4th gen...
for /R %%a in (*.mts *.mov) do ...
I dunno why but the original files had a lot of noise/grain so I am actually glad it reduced it.
You could significantly reduce the size for a similar subjective quality by using Avisynth and a denoising filter.
(Or perhaps ffmpeg has an embedded denoising filter ? If it does, how does it compare with Avisynth's filters ? When I asked about good denoising filters some years ago the main suggestions were SMDegrain and MCTemporalDenoise – have better filters been developped since then ?)
But it would be more complex, and it would significantly increase the encoding time, so if you're satisfied with the current outcome, don't bother.
Last edited by abolibibelot; 15th Jul 2020 at 18:50.