• The Mac-Forums Community Guidelines (linked at the top of every forum) are very clear, we respect US law and court precedence when it comes to legality of activity.

    Therefore to clarify:
    • You may not discuss breaking DVD or BluRay encryption, copying, or "ripping" commercial, copy-protected DVDs.
    • This includes DVDs or BluRays you own. Even if you own the DVD or BluRay, it is still technically illegal under the DMCA to break the encryption. While some may argue otherwise, until the law is rewritten or the US Supreme Court strikes it down, we will adhere to the current intent of the law.
    • You may discuss ripping or copying unprotected movies or homemade DVDs.
    • You may discuss ripping or copying tools in the context that they are used for legal purposes as outlined in this post.

VideoTS (ISO) batch to MKV (moving to Plex)

Joined
Jan 16, 2016
Messages
5
Reaction score
0
Points
1
I have a fully automated download process and using hazel to move movies to Plex.
Having spent 20+ hours to try and find a solution to the last step I am almost giving up.
What I have is lots of IMG and ISO files that are unrared. Theese I unpack with TheUnarchiver to get VIDEO_TS folders.
BUT – how do I automate the process of making MKV:s of theese? I simply want a batch processor/script for MKV but cant find any that seems to work.

Found the script below, but cant understand how to use it with hazel – and cant find a way to install MKV to make it command-line available (the commands on the page result in an error).

https://github.com/hcr/convertingMkvScript

ANY help most appriciated.

(I want all subtitles, all languages etc and preserve filename from folder so that Plex can identify the movie)

I am aware of that this might not be an applescript, but guess anyone here knows how to get this to work anyway :)

!/bin/sh

INPUT_DIR="/Users/AF/Desktop/hotfolder_videodrive"
OUTPUT_DIR="/Users/AF/Desktop/videodrive_klara"
MIN_LENGTH_IN_SECONDS=120
TEMPORARY FOLDERS

TEMP_FOLDER_PATH=""
LOGS_FOLDER_PATH=""
RESULT FOLDERS

SUCCES_FOLDER_PATH=""
FAILED_FOLDER_PATH=""
SCRIPT VARIABLES

NEW_FILE_PATH_WITH_EXT=""
echoStars() {
echo "***********************************************************"
}
echoStripes() {
echo "-----------------------------------------------------------"
}
move() {
local destination=$(dirname "${2}")
mkdir -pv "${destination}"
mv -n$3 -- "${1}" "${2}"
}
createLoggingFolder() {
local name="logs"
local counter=1
local suffix=""
local keep_going=true
while $keep_going; do
if [ -e "${OUTPUT_DIR}/${name}${suffix}" ]; then
suffix="_${counter}"
counter=$((counter + 1))
else
keep_going=false
fi
done
LOGS_FOLDER_PATH="${OUTPUT_DIR}/${name}${suffix}"
mkdir "${LOGS_FOLDER_PATH}"
}
createSuccessFolder() {
SUCCES_FOLDER_PATH="${LOGS_FOLDER_PATH}/success"
mkdir "${SUCCES_FOLDER_PATH}"
}
createFailedFolder() {
FAILED_FOLDER_PATH="${LOGS_FOLDER_PATH}/failure"
mkdir "${FAILED_FOLDER_PATH}"
}
createTempFolder() {
local name="temp"
local counter=1
local keep_going=true
while $keep_going; do
if [ -e "${OUTPUT_DIR}/${name}${counter}" ]; then
counter=$((counter + 1))
else
keep_going=false
fi
done
TEMP_FOLDER_PATH="${OUTPUT_DIR}/${name}${counter}/"
mkdir "${TEMP_FOLDER_PATH}"
}
deleteTempFolder() {
if [ "$(ls -A $TEMP_FOLDER_PATH)" ]; then
echo "Temporary folder ${TEMP_FOLDER_PATH} is not empty, so not removing it"
else
rmdir "${TEMP_FOLDER_PATH}"
fi
}
echoFoldersToProcess() {
echoStars
echo "Input directory : " $INPUT_DIR
echo "Output directory : " $OUTPUT_DIR
echo "Minimum length in seconds : " $MIN_LENGTH_IN_SECONDS
echo "Directories to be processed :"
find "${INPUT_DIR}" -type d -iname "VIDEO_TS" | while read path_to_be_processed;
do
echo " ${path_to_be_processed}"
done
echoStars
}
tryToMakeMkv() {
eval "makemkvcon -r --minlength=$MIN_LENGTH_IN_SECONDS mkv file:\"${1}\" all \"${TEMP_FOLDER_PATH}\" > \"${LOGS_FOLDER_PATH}/makeMkv.log\""
}
checkIfMkvWasCreated() {
if [ "$(ls -A $TEMP_FOLDER_PATH)" ]; then
echo "Success"
move "${LOGS_FOLDER_PATH}/makeMkv.log" "${SUCCES_FOLDER_PATH}${1}.log"
else
echo "Failure"
move "${LOGS_FOLDER_PATH}/makeMkv.log" "${FAILED_FOLDER_PATH}${1}.log"
fi
}
determineNewFileName() {
local new_file_path="${OUTPUT_DIR}${1}"
local counter=1
local suffix=""
local extension=".mkv"

local keep_going=true
while $keep_going; do
if [ -e "${new_file_path}${suffix}${extension}" ]; then
suffix="_${counter}"
counter=$((counter + 1))
else
keep_going=false
fi
done

NEW_FILE_PATH_WITH_EXT="${new_file_path}${suffix}${extension}"
}
renameMkvs() {
if [ "$(ls -A $TEMP_FOLDER_PATH)" ]; then
for file in "${TEMP_FOLDER_PATH}"*
do
determineNewFileName "${1}"
move "${file}" "${NEW_FILE_PATH_WITH_EXT}" v
done
fi
}
echoFinished() {
echoStars
local resultfile="${LOGS_FOLDER_PATH}/result.log"
echoStars >> "${resultfile}"

if [ "$(ls -A $SUCCES_FOLDER_PATH)" ]; then
echo "Successfully converted:" >> "${resultfile}"
find "${SUCCES_FOLDER_PATH}" -type f -iname "*.log" | while read log;
do
local logfile="${log%.log}"
echo "${logfile#${SUCCES_FOLDER_PATH}/}" >> "${resultfile}"
done
echoStars >> "${resultfile}"
fi

if [ "$(ls -A $FAILED_FOLDER_PATH)" ]; then
echo "Failure to convert:" >> "${resultfile}"
find "${FAILED_FOLDER_PATH}" -type f -iname "*.log" | while read log;
do
local logfile="${log%.log}"
echo "${logfile#${FAILED_FOLDER_PATH}/}" >> "${resultfile}"
done
echoStars >> "${resultfile}"
fi

echo "Finished script"
echo "Check ${LOGS_FOLDER_PATH}/result.log for the result"
}
process() {
echoFoldersToProcess
createLoggingFolder
createSuccessFolder
createFailedFolder

echoStars

find "${INPUT_DIR}" -type d -iname "VIDEO_TS" | while read path_to_be_processed;
do
echo "Processing directory: ${path_to_be_processed}"

local without_input_folder=${path_to_be_processed#${INPUT_DIR}}
local media_name=${without_input_folder%/[V,v][I,i][D,d][E,e][O,o]_[T,t][S,s]}

createTempFolder

tryToMakeMkv "${path_to_be_processed}"

checkIfMkvWasCreated "${media_name}"

renameMkvs "${media_name}"

deleteTempFolder

echoStripes
done

echoFinished
}
if [ $# -eq 0 ]; then
echo "Please supply on of these arguments: info, process"
elif [ "$1" = "info" ]; then
echoFoldersToProcess
elif [ "$1" = "process" ]; then
process
else
echo "Invalid argument [${1}]. Please supply on of these arguments: info, process"
fi
 
Joined
Nov 29, 2010
Messages
2,513
Reaction score
134
Points
63
Location
Warrington, UK
Your Mac's Specs
PPC Mini, 10.4.11. Intel Mini, 10.6.8. MacBook Pro, 10.14.6. M1 MBA 11.6.3 iPhone 5 iOS 12.5,
Use Handbrake, certainly for the .img files, although I'm not sure if it can cope with .iso files. It has a batch function and will give MKV files at the end.
https://handbrake.fr/downloads.php
 
OP
F
Joined
Jan 16, 2016
Messages
5
Reaction score
0
Points
1
I have handbrake of course, but the batch is not automatic. I am setting up a hands-off batch that moves files from folder to folder and resulting in a final file. Handbrakes batch is not that automatic. I have to manually open Handbrake, add files to batch one-at-a-time and start.

At least thats what I have found out. A hotfolder (auto loads to batch from new items in folder) would be best, but cant see that Handbrake supports this.

That is why I am looking in to scripts, and I am not really that good at this part. Sorry!
 
OP
F
Joined
Jan 16, 2016
Messages
5
Reaction score
0
Points
1
Any clues why following command gives me this error (after successful password prompt):

install: /usr/bin//makemkvcon: Operation not permitted

I am an Admin-user on my account

cd /opt/homebrew-cask/Caskroom/makemkv/1.9.8/MakeMKV.app/contents/macos && sudo /usr/bin/install makemkvcon /usr/bin/ && sudo /usr/bin/install libmakemkv.dylib /usr/bin/ && sudo /usr/bin/install libdriveio.dylib /usr/bin/ && sudo /usr/bin/install libffm.dylib /usr/bin/ && sudo /usr/bin/install libfdk.dylib /usr/bin/
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You're trying to run an .app as a terminal command? Don't think that's going to work.
Also you have two slashes in the path. Is there something supposed to be there? Or typo?
Where are you getting these commands?
 
C

chas_m

Guest
I don't know enough about Plex to comment (but that's never stopped me before! :)) but I have to ask ... surely it plays lots of media types (kind of the whole point I would have thought)? Why not convert this stuff to something standard rather than the oddball MKV format? Like, hey here's an idea, the MPEG-standard MPEG4/H.264 that will be much more transportable on your next setup ... or when you get an Apple TV ... or a Roku ... or anything ...
 
OP
F
Joined
Jan 16, 2016
Messages
5
Reaction score
0
Points
1
Thanks!

Yes I will convert to Mp4 in next step. I have found an app that takes mkv files and converts them to mp4 by dropping in one folder. (But not any app that takes video_ts folders and batchconverts through hotfolders to mp4). Theese are not pirated discimages, though!

The above script calls an command-line appversion of makemkv. Takes Video_TS folder and creates a MKV.

The script will be triggered by hazel when dropping files in a certain folder.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top