Script to play segments to help find the best title
Posted: Sat Jul 27, 2019 4:59 pm
I recently remuxed a UHD Blu-ray, using MakeMKV 1.14.4, that had 9 titles, all the appropriate size and duration. I had never done this before so I needed to know how to choose the best title. I found this forum thread that helped me decide––Determining correct title on BD with MULTIPLE titles. I copied and pasted the 'Segment map:' line for each title to a text file.
I played the corresponding m2ts files from the Blu-ray's BDMV/STREAM directory to see what they contained.
For example, for the first title, which corresponds to 00800.mpls, I played 00687.m2ts, 00688.m2ts, 00674.m2ts, and 00689.m2ts. I saw that segments 688 and 689 were common to all titles. 00688.m2ts contained the whole movie, minus the intro and outro, and 00689.m2ts contained the end credits in English. The other two files contained the different language versions of the intro and outro. Both titles one and two referred to the same segments, which were for the English version. The only way I knew that was by playing 00687.m2ts and 00689.m2ts and seeing the English wording. Corresponding segments from other titles were for different languages. I was surprised that only the English audio and subtitles were chosen by the app for each title. Maybe there was no further information available to determine the language?
I found it very tedious and time-consuming to go back and forth between the various files and the player each time so I wrote a script to automate the process. This is written for OS X and probably works for any OS that is UNIX based, maybe with some modification. It assumes that you have already ripped the disc or decrypted it and can copy the path of the BDMV directory (though it looks like a file, it is actually a directory that contains the STREAM directory)
The script prompts you to copy the BDMV directory path to the clipboard. Then it prompts you to copy the 'Segment map:' line for the title. It then creates a playlist of the corresponding m2ts files and plays them in order so you can more easily decide if they are the correct segments in the correct order.
Here is the script:
I have uploaded it as well as a text file:
You have to change the extension to sh to make it executable. Copy the file to /usr/local/bin/ on OS X and change permissions:
Run the script from any directory but probably not your home directory as it creates a playlist file there.
Note that I use the mpv player which is the best player I have found for OS X. It plays m2ts files flawlessly where VLC can't play them at all. It is small, fast loading, and simple. It is multi-platform as well. I added a commented out line for VLC. Uncomment it and comment out the mpv line if you prefer VLC.
That's it. I hope this helps make it go faster for someone struggling to determine the best title to select, as I did.
Anyone who is adept at Windows batch or WSH scripting is encouraged to convert this for Windows users.
Code: Select all
Segment map: 687,688,674,689
Segment map: 687,688,674,689
Segment map: 692,688,18,689
Segment map: 6,688,21,689
Segment map: 691,688,15,689
Segment map: 4,688,674,689
Segment map: 690,688,17,689
Segment map: 694,688,19,689
Segment map: 693,688,674,689
For example, for the first title, which corresponds to 00800.mpls, I played 00687.m2ts, 00688.m2ts, 00674.m2ts, and 00689.m2ts. I saw that segments 688 and 689 were common to all titles. 00688.m2ts contained the whole movie, minus the intro and outro, and 00689.m2ts contained the end credits in English. The other two files contained the different language versions of the intro and outro. Both titles one and two referred to the same segments, which were for the English version. The only way I knew that was by playing 00687.m2ts and 00689.m2ts and seeing the English wording. Corresponding segments from other titles were for different languages. I was surprised that only the English audio and subtitles were chosen by the app for each title. Maybe there was no further information available to determine the language?
I found it very tedious and time-consuming to go back and forth between the various files and the player each time so I wrote a script to automate the process. This is written for OS X and probably works for any OS that is UNIX based, maybe with some modification. It assumes that you have already ripped the disc or decrypted it and can copy the path of the BDMV directory (though it looks like a file, it is actually a directory that contains the STREAM directory)
The script prompts you to copy the BDMV directory path to the clipboard. Then it prompts you to copy the 'Segment map:' line for the title. It then creates a playlist of the corresponding m2ts files and plays them in order so you can more easily decide if they are the correct segments in the correct order.
Here is the script:
Code: Select all
echo
echo "Copy path of BDMV directory to clipboard:"
echo "e.g., /Volumes/Alita.Battle.Angel.2019.UHD.BluRay/BDMV"
echo
read -rsp $'Press any key when you\'re done...\n' -n 1 -e key </dev/tty
d="`pbpaste`"
echo $d
echo
echo "Copy 'Segment map' line to clipboard:"
echo "e.g., Segment map: 687,688,674,689"
echo
read -rsp $'Press any key when you\'re done...\n' -n 1 -e key </dev/tty
s="`pbpaste`"
echo $s
echo
if [ -f playlist.m3u ]
then rm playlist.m3u
fi
for i in $(echo $s | awk -F ': ' '{print $NF}' | tr ',' '\n')
do
printf "%s/STREAM/%05d%s\n" $d $i .m2ts >> playlist.m3u
done
mpv --really-quiet --playlist=playlist.m3u > /dev/null 2>&1
#vlc playlist.m3u > /dev/null 2>&1
Code: Select all
chmod 755 /usr/local/bin/playsegs.sh
Note that I use the mpv player which is the best player I have found for OS X. It plays m2ts files flawlessly where VLC can't play them at all. It is small, fast loading, and simple. It is multi-platform as well. I added a commented out line for VLC. Uncomment it and comment out the mpv line if you prefer VLC.
That's it. I hope this helps make it go faster for someone struggling to determine the best title to select, as I did.
Anyone who is adept at Windows batch or WSH scripting is encouraged to convert this for Windows users.