[BASH] simple script to convert bluray BDMV M2TS file to MKV

Come up with a useful post-processing script? Share it here!
Post Reply
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

[BASH] simple script to convert bluray BDMV M2TS file to MKV

Post by Eelisland »

Hi,

i'have addapted a script found on this forum to convert the biggest M2TS file found in /BDMV/STREAM/ folder of Blu-Ray in MKV, no compression, everything inclued:

Code: Select all

#!/bin/bash
BDMV_FOLD=`find "$1" -name "BDMV" -print0`

if [[ $BDMV_FOLD == *BDMV* ]]; then
   # cd to the ./BDMV/STREAM sub folder
   cd "$BDMV_FOLD/STREAM/"
   # Find the biggest .M2TS file, usually the movie
   BIGST_M2TS=`find . -type f | xargs ls -1S | head -n 1 | rev | cut -c 6- | rev`
   # MkvMerge the file
   mkvmerge -o "$BIGST_M2TS".mkv --compression -1:none "$BIGST_M2TS".m2ts
   # Change MKV permission to -rw-r--r-- and move file out of STREAM folder
   chmod 644 "$BIGST_M2TS".mkv
   mv "$BIGST_M2TS".mkv "$1"
   echo "MKV created! ("$1")"
else
   echo "BDMV2Mkv: no processing"
fi
edit: bug correction.

Hope that it will be usefull to someone.
Regards.
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

Re: [BASH] simple script to convert bluray BDMV M2TS file to

Post by Eelisland »

removed a bug
goblix
Newbie
Newbie
Posts: 2
Joined: July 2nd, 2016, 5:04 pm

Re: [BASH] simple script to convert bluray BDMV M2TS file to

Post by goblix »

Thanks for the script works well for me, I added on to it to support iso files since some rips are iso dumps and also to use the name of the $3 (job name of the nzb) as the filename.

Couch potato does good work for most media filetypes but BDMV is a mess so this definitely helps.

**editing the code now to fix some bugs

not a script pro so probably worth while to verify and keep an eye out on a couple run throughs
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

Re: [BASH] simple script to convert bluray BDMV M2TS file to

Post by Eelisland »

goblix wrote:Thanks for the script works well for me, I added on to it to support iso files since some rips are iso dumps and also to use the name of the $3 (job name of the nzb) as the filename.

Couch potato does good work for most media filetypes but BDMV is a mess so this definitely helps.

**editing the code now to fix some bugs

not a script pro so probably worth while to verify and keep an eye out on a couple run throughs
Hello Goblix,

glad to see you find it usefull, post your modified version for others if you have time ;)

regards,
Post Reply