This script was made out of a simple need: To process whole seasons of files obtained elsewhere (ripped, downloaded, etc.) and, for each file, do the following:
- Convert into an iPhone-Compatible format.
- Insert one or more “soft”1 subtitles from SRT (.srt) or TXTSUB (.sub, no .idx/.sub) sources.
- Tag the video resulting MP4 according to the name
- Insert the converted, subtitled and tagged video file into iTunes
Current Version is 1.8 – 2012-04-04
Please consider donating with the button above. This will help us cover expenses for hosting and optimize new versions in the future.
mkmp4s.bash comes in two flavors: A zip file containing a bash script and some helper files and a zip file containing an application that allows dropped files and stores encoding parameters (NOTE: Only accepts files, not folders).
The bash script is designed to be run from the terminal. There are several options:
usage: ./mkmp4s.bash [-c] [-h] [-V] [-f Normal|iPad|iPhone4] [-m T|M file1 file2] -c Convert files MP4/M4V to custom MP4. Disabled by default. -h Display this Help -G Graphical Mode. Will pop-up timed options for the conversion. -V Show version -m Manual file mode. Either 'T' for TV-Shows or 'M' for Movies. Followed by one or more video files to process. Disabled by default. -f Format for conversion, if executed. Default is 'iPad' See all at: http://trac.handbrake.fr/wiki/BuiltInPresets -n Don't add to iTunes automatically. Default is to add to iTunes. Implies '-k' -k Keep final files. Default is to delete final .m4v files. Enabled if '-n'
The script can either run on full automatic mode or, conversely, all options can be tweaked.
- Fully Automatic: Files to process will be reader from text files called episodes.txt and/or movies.txt. Files will be considered TV Episodes or Plain Movies depending on which file they appear in. Encoding will be made to the iPad preset. MP4s will NOT be reconverted.
- User-defined: Any setting defined will override defaults. Option m can be used to override the text file lists, but must include a file type (M for movies, T for TV Episodes) and the files to process must be listed at the end.
Fully automatic Will convert all video files in episodes.txt and movies.txt with default values:
Command-line file processing Will process the two video files as TV Episodes with default values:
./mkmp4s.bash -m T "TV Episode 1x02.avi" TV\ Episode 1x03.mp4
The full enchilada Convert both video files changing the default preset to iphone4 and reconverting MP4s even if already compatible, resulting MP4 files will not be added to iTunes:
./mkmp4s.bash -f iPhone4 -c -n -m T "TV Episode 1x02.avi" TV\ Episode 1x03.mp4
Subtitles in SRT format will be embedded in MP4 files. If subtitle is in TXTSUB2 the script will attempt to convert it to SRT and embed it as well.
Subtitles are expected to have the same name as the video file and, optionally, a language prefix between the name and extension (if no language is provided “English” will be assumed).
If a video file is named “My Big Movie.avi” then a spanish subtitle could be “My Big Movie.es.srt” and an english one could be “My Big Movie.en.srt” or even “My Big Movie.srt”.
If not explicitly disabled (-n), the last action of the script will be to add the files to iTunes. iTunes will then show the video files properly tagged:
For the script to work its magic, TV Episodes must be named in a way the program can understand. Some of the possible names are:
ShowName S01E02.avi ShowName S01E02 - Episode Title.avi ShowName S01E02E03.avi ShowName S01E02E03 - Episode Title.avi ShowName 102.avi ShowName 1x02.avi ShowName 1x02 - Episode Title.avi ShowName 1x02-03.avi ShowName 1x02-03 - Episode Title.avi ShowName 2012-03-17.avi ShowName Part1.avi ShowName Part1 of 3.avi
It is recommended that files are named properly, so episode titles are parsed correctly:
The main advantage of properly naming and tagging becomes apparent when synchronizing iTunes with iOS devices, where iTunes and the devices themselves can manage the seasons intelligently and only include files that haven’t been watched in order:
Starting with version 1.56 you can easily integrate mkmp4s into your workflows for automations. Creating a Contextual menu or a Folder Action becomes trivial with Automator.
A couple of sample workflows have been included. Both are almost identical. The “Folder Action” can be attached to a folder and will pick up all “video” files and process them with mkmp4s.bash. The “Service” is probably more useful, in that it can take a group of selected files and appear as a contextual menu, which will pick up all selected and process them.
Fancier automations can be made that show some sort of progress. Suggestions will be included in this section.