I realize the script is coded in a very inelegant way, since I am just learning Bash, but I hope that provides an easy way to see what it is attempting to do...
Anyway, more information is below, and I hope it will be useful. I am happy to respond to questions and appreciate any comments.
Regards, Mitch
Repository: https://github.com/encode2m4v/encode2m4v
Script name: encode2m4v.sh
Description: Transcodes files and recurses folders in current directory "." (or
"root directory/".) Finds all .mp4 (or "--inext") files and transcodes
them into an .m4v (or "--ext") file using the "HQ 1080p30 Surround"
(or --preset) HandBrakeCLI preset. Originally meant to be copied to the
directory to start the recursive search (root) and run from there, it
also has command line switches (arguments) which can be passed in to set
the "root" folder and other switches to set processing options.
Features:
If run without switches:
- searches in current directory and subdirectories for all video files with a .mp4 extension
- will prompt for a subtitle extension to add or no subtitle.
- will prompt whether or not to upconvert to 1080
- will start transcoding all found video files to .m4v files using the HandBrakeCLI "HQ 1080p Surround" preset
- Will place these transcoded files in the same directory as the source (input) video file.
- Will not move or remove any files.
- Will not display the HandBrakeCLI encoding details.
- specify a "transcode directory/" to start search for video files and subtitle files.
- specify input video file extension to search for (.mp4, .mov, .mkv, ...) or all video files (".*")- (-i / --inext)
- specify output transcoded video file extension (.mp4 , .m4v, .mkv ...) - (-e / --ext)
- specify subtitle file extension (?.srt / "none") - (-s / --subtitle=)
- specify whether to stop encoding (-b / --break) if a subtitle file is not found or continue (-c / --continue)
- specify a HandBrake preset (-p / --preset=)
- specify specific HandBrake transcoding options (-t / --transopt)
- use a HandBrake .json settings file (-j / --json=)
- upconvert the video to 1080 (-u / --upconvert) or not (-n / --noupconvert)
- specify an upconvert level (720, 1080, 2160, 4320) (-x / --xlevel)
- output the transcoded file(s) to a specified directory (-o / --output=)
- re-create the input directory structure when output to a different directory (-r / --recreatedirs)
- move input video and subtitle files once they have been transcoded (-m / --move=)
- delete input file(s) after they have been transcoded (-k / -kill)
- show details of HandBrakeCLI encoding or not (-d / --details)
- display a "manpage" like information (-g / --guide)