I am trying to get a bare-bones (just running a few commands) script which should read a folder with sub-folders for video files, select the ones which are not HEVC encoded and pass them to ffmpeg
, and after - compare the size of the input and output files and if the output is larger in size - move on to the next one, or if the size is smaller - replace the original file.
My logic goes like so:
Prepare plain txt list:
find /folder -type f \( -iname "*.mkv" -o -iname "*.mp4" -o -iname "*.avi" \) > log.txt
Pass the txt to
ffprobe
ffprobe "log.txt" -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1
This is where ffprobe
should receive line 1,2,3, etc from log.txt
, however I do not know how to do this, because ffprobe
only accepts single input.
ffprobe
should run the list and output the non-HEVC results inlog1.txt
This is where
log1.txt
should be passed toffmpeg
for transcoding, using the system/tmp
folder. I have a workingffmpeg
command, the syntax here is not a problem for a single file.Compare the input and output - if the input is larger than the output - replace it. If the output is larger than the input - discard it and move on to the next one.
The problems I have are mostly linked to passing variables (see 2.) and definetly (5.). I need some pointers as to how to approach the issues stated above, rather than a solution.
Thank you for reading.