conv2mp4-py
Python 2.7 script that recursively searches through a defined file path and converts MKV, AVI, FLV, and MPEG files to MP4 using handbrake (with AAC audio). It then refreshes a Plex library, and deletes the source file upon success and moves the new files into the defines directory (Plex Library directories for example). Fails over to ffmpeg encode if conversion failure is detected. The purpose of this script is to reduce the number of transcodes performed by a Plex server, by processing all files into an MP4 format.
Designer Templates
Dependencies
This script requires Python, Filebot, ffmpeg and Handbrake to be installed on your computer. You can download them from here:
Python
FileBot
ffmpeg
Handbrake
Authors and Contributors
Support or Contact
Having trouble with the script? Check out the Readme, F.A.Q. or email me at
F.A.Q.
How do I launch the script
The script takes exactly one launch parameter, the directory where the files are located. For me it's 'F:\Temp'
What does foreign language mean in readme?
In this case I call foreign language every language that is not English. (Even though English is foreign for me)
Options are confusing how can I get my files placed here and there?
Say for example you have a folder with all you media files:
'F:\Temp'
You launch the Script with this parameter.
You want to keep the files where they are, you just want to convert them:
- Set
MOVE_FILES
to False
You want to move files to your Plex Libraries and you have on TV Show and one Movies Library
- Set
MOVE_FILES
to True - Set
FOREIGN
to False
You want to move your TV Shows to your Plex Libraries and also create a separate folder for each TV Show
- Set
MOVE_FILES
to True - Set
FOREIGN
to False - Set
CREATE_TVSHOW_DIRS
to True - Set
TVSHOW_TARGET
to the path where you want to move the = '' #Example F:\Media\TV Shows'
If you have all the Seasons of How I met your mother it will move your files to [Plex TVSHOW Library]\How I Met Your Mother\SeasonXXEpisodeXX.mp4
- You can also enable creating Season folders by setting
CREATE_SEASON_DIRS
to True. The path will be [Plex TVSHOW Library]\How I Met Your Mother\Season XX\EpisodeXX.mp4
You want to move your Movie files to your Plex Libraries and also create a separate folder for each Movie file.
- Set
MOVE_FILES
to True - Set
FOREIGN
to False - Set
CREATE_MOVIE_DIRS
to True - Set
MOVIE_TARGET
to the path where you want to move the movie files #Example: "F:\Media\Movies"
If you have the Pacific Rim movie this will move it to [Plex Movie Library]\Pacific Rim\Pacific Rim.mp4 (Note that the script merely cut's of the file extension of the file to create a directory so if your file is named pacific_rim_2013.mp4 the folder will be called pacific_rim_2013)
You have separate libraries for Tv Shows and Movies in your own and english language and you want the script to put the files where they belong
- Set
MOVE_FILES
to True - Set
FOREIGN
to True - Set up
LANG_MOVIE_TARGET
andLANG_TVSHOW_TARGET
to point to your PLEX libraries in your language.
Same as previous but you want to have files with multiple audio stream in both your english and your own language libraries.
- Set
HARD_LINK
to true. - Set
CREATE_MOVIE_DIRS
to true. - Set
CREATE_TVSHOW_DIRS
to true.