lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.38k stars 160 forks source link

Question: how to re-encode a folder of videos and put them in a new folder (CLI) #341

Open walksanatora opened 1 year ago

walksanatora commented 1 year ago

So i have this folder of videos on my headless server I want to re-encode them en-masse but when i try the naieve approach it ended up erroring with code 3 ([15:07:50] libhb: work result = 3) so I am asking how to re-encode a entire folder

lisamelton commented 1 year ago

@walksanatora The transcode-video tool doesn't accept a directory of multiple videos as an input. You have to pass each video file as a separate argument on the command line after specifying any options. Or you can write a batch processing script that simply calls transcode-video once for each video within the directory.

I hope that helps.

shuckster commented 1 year ago

You can use the find command to process multiple files for commands that only accept one file as input:

find . -iname '*.mov' -exec echo {} \;

Explained.

The above example will print all *.mov filenames to the console, ignoring case.

Here's a variant that uses the cp copy command to copy files from one folder to another, keeping the folder-structure:

mkdir destination
find ./source -iname '*.mov' -exec cp --parents {} ./destination \;

Explained.

After copying, you can then run other commands using find to separately convert your movies, then delete the old ones.

lisamelton commented 1 year ago

Thanks, @shuckster! 👍

Gattung commented 1 year ago

I was able to do this using the 'for' command.

for /R "\PATH\TO\VIDEOS\FOLDER\" %I in (*.mkv) do @transcode-video "%I"