tl;dr - watch the video explainer:
https://youtu.be/ZiGeVvNGn9c
I came up with two different ways to batch transcode a folder full of video files using ffmpeg. As far as I know, ffmpeg will copy over all metadata without modification.
Pure Python Way
https://github.com/nuket/Shrinkr#shrinkr-batch-transcode-python-edition
SCons Way
https://github.com/nuket/Shrinkr#shrinkr-batch-transcode-scons-edition
One uses pure Python, the other uses SCons build scripts. Transcoding video can be conceptually similar to compiling software, so, I gave this a shot.
Both ways will let you run the batch repeatedly and will not repeat work, already-transcoded files won't be done again unless the source files change.
Of the two ways, I prefer the SCons method, because it leverages the SCons build system to check for changes to the input / output files. The one downside to SCons is that for some reason it takes a while to start running, but once it figures out what it needs to do, it will execute all of the ffmpeg
calls quickly.
To get started, all you need to do is:
pip3 install scons
git checkout https://github.com/nuket/Shrinkr
- Copy
ShrinkrArchive
to the folder with all the videos. (Rename the file if you want.)
- Edit this line to set the
ffmpeg
parameters you want.
- Edit this line to gather up all the files you want (i.e.
*.mp4
or *.mkv
).
- Open up a command-line prompt in that folder.
- Run
scons -f ShrinkrArchive
.
You'll need a copy of ffmpeg
somewhere in your system PATH
, and of course, a working copy of Python 3.x.
Otherwise, it's pretty easy to use. I've been using it to transcode screencasts to more highly-compressed versions, before kicking them out to cold storage and getting file size savings between 66 - 75%. (Screencasts are usually low-entropy.)
@Takin - to your request:
If it's possible (not neccessary), I would also like to have the
filename as "YYYYMMDD_HHMMSS".
You can do this as well in an the ShrinkrArchive file (which is just an SCons build script), you'd have to add a file stat
call to the file name emitter and change this line, which determines what to call the output file.
This is an exercise left up to the reader, however.
Anyways, hope this helps anyone who needs to transcode a bunch of files and doesn't want to use a GUI to do it.
If anyone has questions, feel free to open up a new topic here or on GitHub.