How to add and remove subtitles in an MKV file?












25















I have a good quality MKV file that has several subtitle options. I want to add an additional subtitle file to the list. I'm using OSX.



Some search online led me to use video converters, and basically re-encode the movie into a new file. That seems really overkill to me. Plus I may loose the previous subtitles, and some image quality along the way.










share|improve this question





























    25















    I have a good quality MKV file that has several subtitle options. I want to add an additional subtitle file to the list. I'm using OSX.



    Some search online led me to use video converters, and basically re-encode the movie into a new file. That seems really overkill to me. Plus I may loose the previous subtitles, and some image quality along the way.










    share|improve this question



























      25












      25








      25


      13






      I have a good quality MKV file that has several subtitle options. I want to add an additional subtitle file to the list. I'm using OSX.



      Some search online led me to use video converters, and basically re-encode the movie into a new file. That seems really overkill to me. Plus I may loose the previous subtitles, and some image quality along the way.










      share|improve this question
















      I have a good quality MKV file that has several subtitle options. I want to add an additional subtitle file to the list. I'm using OSX.



      Some search online led me to use video converters, and basically re-encode the movie into a new file. That seems really overkill to me. Plus I may loose the previous subtitles, and some image quality along the way.







      macos video subtitles matroska






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 13 '18 at 1:35









      JakeGould

      32k1098140




      32k1098140










      asked Jun 18 '13 at 15:30









      nutenute

      78471833




      78471833






















          3 Answers
          3






          active

          oldest

          votes


















          35














          Removing subtitles:



          mkvmerge -o output.mkv input.mkv -S # remove all subtitle tracks
          mkvmerge -o output.mkv input.mkv -s 3,4 # remove tracks 3 and 4
          mkvmerge -o output.mkv input.mkv -s '!3' # remove all subtitle tracks except 3
          mkvmerge -i input.mkv # show track numbers


          Adding subtitles:



          mkvmerge -o output.mkv input.mkv subs.srt
          mkvmerge -o output.mkv input.mkv --language 0:ger --track-name 0:German subs.srt


          Extracting subtitles:



          mkvextract tracks input.mkv 3:subs.srt




          for f in *.mkv; do
          sub=$(mkvmerge -i "$f" | awk '$4=="subtitles"{print;exit}')
          [[ $sub ]] || continue
          [[ $sub =~ S_TEXT/ASS ]] && ext=ass || ext=srt
          track=$(awk -F '[ :]' '{print $3}' <<< "$sub")
          mkvextract tracks "$f" "$track:${f%mkv}$ext"
          done


          mkvmerge and mkvextract can be installed with brew install mkvtoolnix.






          share|improve this answer



















          • 2





            MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

            – Bora
            Jun 18 '13 at 23:35











          • Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

            – Mathias Bynens
            May 5 '16 at 20:45



















          4














          There are two basic ways of showing subtitles. You can encode the pixels into the video itself. This is called "hardsubbing". The advantage here is the simplicity for the video player, it's just a video stream. The disadvantages are that you had to reencode the video, which takes time, and has some fidelity loss. If you get a better translation, well, it's pixels in the video. And you can only have one language.



          What is somewhat better is "softsubbing", which is to have a text file someplace, separate from the video stream. There are many different formats of subtitle files, but at their base they all have "text, start what time, remove what time" at their core. Some have additional features like colors and orientation on the screen. The advantage to this is you can have multiple languages (think of a DVD, you have multiple languages available) and you can fix typos and such in the file. And if you don't need subtitles, well you just turn them off.



          Softsubs can either be separate files - most players will automagically look for subtitles with the same name (different extension) as the main video. Or certain container file formats (like MKV) can have them embedded inside. Check out MKVtoolnix (there is a mac port) for MKV file tools. This should let you embed softsubs without reencoding.



          Note that not all players can support all formats. My experience is that XBMC has issues with SSA files, but the much simpler SRT files are fine. VLC will play anything, if it's supported on your platform.






          share|improve this answer





















          • 1





            Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

            – evilsoup
            Jun 18 '13 at 16:17











          • @evilsoup thanks, didn't know that.

            – Rich Homolka
            Jun 18 '13 at 17:04






          • 1





            Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

            – Karan
            Jun 18 '13 at 19:20











          • changed link to the direct download page.

            – Bora
            Jun 18 '13 at 23:38



















          0














          I realize this is an old question and user495470’s answer has been accepted as of 2013, but since part of the question is about adding subtitles to files, I wanted to add this new addition.



          Basically, I needed to merge dozens of .ass subtitles into similarly named MKV files, so doing this one command at a time was not cutting it. So I whipped up this simple Bash script that will search the current directory it’s run from for .ass files and then merge them as expected.



          find -E . -maxdepth 1 -type f -iregex '.*.(ASS|SRT)$' |
          while read FILEPATH
          do
          DIRNAME=$(dirname "${FILEPATH}");
          BASENAME=$(basename "${FILEPATH}");
          FILENAME="${BASENAME%.*}";
          EXTENSION="${BASENAME##*.}"
          mkvmerge -o "/Users/jake/${FILENAME}"-NEW.mkv "${FILENAME}".mp4 --language 0:eng --track-name 0:English "${FILENAME}"."${EXTENSION}"
          done


          Of course, this simple script assumes that the subtitles are English and merges them as such, but that can be manually adjusted per usage need; the big issue of automatically merging the subtitles with the MKV is solved by a simple script like this.






          share|improve this answer
























            protected by slhck Jan 17 '14 at 14:15



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?














            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            35














            Removing subtitles:



            mkvmerge -o output.mkv input.mkv -S # remove all subtitle tracks
            mkvmerge -o output.mkv input.mkv -s 3,4 # remove tracks 3 and 4
            mkvmerge -o output.mkv input.mkv -s '!3' # remove all subtitle tracks except 3
            mkvmerge -i input.mkv # show track numbers


            Adding subtitles:



            mkvmerge -o output.mkv input.mkv subs.srt
            mkvmerge -o output.mkv input.mkv --language 0:ger --track-name 0:German subs.srt


            Extracting subtitles:



            mkvextract tracks input.mkv 3:subs.srt




            for f in *.mkv; do
            sub=$(mkvmerge -i "$f" | awk '$4=="subtitles"{print;exit}')
            [[ $sub ]] || continue
            [[ $sub =~ S_TEXT/ASS ]] && ext=ass || ext=srt
            track=$(awk -F '[ :]' '{print $3}' <<< "$sub")
            mkvextract tracks "$f" "$track:${f%mkv}$ext"
            done


            mkvmerge and mkvextract can be installed with brew install mkvtoolnix.






            share|improve this answer



















            • 2





              MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

              – Bora
              Jun 18 '13 at 23:35











            • Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

              – Mathias Bynens
              May 5 '16 at 20:45
















            35














            Removing subtitles:



            mkvmerge -o output.mkv input.mkv -S # remove all subtitle tracks
            mkvmerge -o output.mkv input.mkv -s 3,4 # remove tracks 3 and 4
            mkvmerge -o output.mkv input.mkv -s '!3' # remove all subtitle tracks except 3
            mkvmerge -i input.mkv # show track numbers


            Adding subtitles:



            mkvmerge -o output.mkv input.mkv subs.srt
            mkvmerge -o output.mkv input.mkv --language 0:ger --track-name 0:German subs.srt


            Extracting subtitles:



            mkvextract tracks input.mkv 3:subs.srt




            for f in *.mkv; do
            sub=$(mkvmerge -i "$f" | awk '$4=="subtitles"{print;exit}')
            [[ $sub ]] || continue
            [[ $sub =~ S_TEXT/ASS ]] && ext=ass || ext=srt
            track=$(awk -F '[ :]' '{print $3}' <<< "$sub")
            mkvextract tracks "$f" "$track:${f%mkv}$ext"
            done


            mkvmerge and mkvextract can be installed with brew install mkvtoolnix.






            share|improve this answer



















            • 2





              MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

              – Bora
              Jun 18 '13 at 23:35











            • Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

              – Mathias Bynens
              May 5 '16 at 20:45














            35












            35








            35







            Removing subtitles:



            mkvmerge -o output.mkv input.mkv -S # remove all subtitle tracks
            mkvmerge -o output.mkv input.mkv -s 3,4 # remove tracks 3 and 4
            mkvmerge -o output.mkv input.mkv -s '!3' # remove all subtitle tracks except 3
            mkvmerge -i input.mkv # show track numbers


            Adding subtitles:



            mkvmerge -o output.mkv input.mkv subs.srt
            mkvmerge -o output.mkv input.mkv --language 0:ger --track-name 0:German subs.srt


            Extracting subtitles:



            mkvextract tracks input.mkv 3:subs.srt




            for f in *.mkv; do
            sub=$(mkvmerge -i "$f" | awk '$4=="subtitles"{print;exit}')
            [[ $sub ]] || continue
            [[ $sub =~ S_TEXT/ASS ]] && ext=ass || ext=srt
            track=$(awk -F '[ :]' '{print $3}' <<< "$sub")
            mkvextract tracks "$f" "$track:${f%mkv}$ext"
            done


            mkvmerge and mkvextract can be installed with brew install mkvtoolnix.






            share|improve this answer













            Removing subtitles:



            mkvmerge -o output.mkv input.mkv -S # remove all subtitle tracks
            mkvmerge -o output.mkv input.mkv -s 3,4 # remove tracks 3 and 4
            mkvmerge -o output.mkv input.mkv -s '!3' # remove all subtitle tracks except 3
            mkvmerge -i input.mkv # show track numbers


            Adding subtitles:



            mkvmerge -o output.mkv input.mkv subs.srt
            mkvmerge -o output.mkv input.mkv --language 0:ger --track-name 0:German subs.srt


            Extracting subtitles:



            mkvextract tracks input.mkv 3:subs.srt




            for f in *.mkv; do
            sub=$(mkvmerge -i "$f" | awk '$4=="subtitles"{print;exit}')
            [[ $sub ]] || continue
            [[ $sub =~ S_TEXT/ASS ]] && ext=ass || ext=srt
            track=$(awk -F '[ :]' '{print $3}' <<< "$sub")
            mkvextract tracks "$f" "$track:${f%mkv}$ext"
            done


            mkvmerge and mkvextract can be installed with brew install mkvtoolnix.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 18 '13 at 22:24









            LriLri

            31.4k590131




            31.4k590131








            • 2





              MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

              – Bora
              Jun 18 '13 at 23:35











            • Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

              – Mathias Bynens
              May 5 '16 at 20:45














            • 2





              MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

              – Bora
              Jun 18 '13 at 23:35











            • Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

              – Mathias Bynens
              May 5 '16 at 20:45








            2




            2





            MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

            – Bora
            Jun 18 '13 at 23:35





            MKVMerge GUI is already available on Mac OS X, but nevertheless, it's a good how to for console fans.

            – Bora
            Jun 18 '13 at 23:35













            Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

            – Mathias Bynens
            May 5 '16 at 20:45





            Note that the above commands for adding subtitles also set the subtitles as “enabled by default” when playing the file. (This flag can be confirmed using the MKVMerge GUI.) To avoid this, use --default-track '0:0'.

            – Mathias Bynens
            May 5 '16 at 20:45













            4














            There are two basic ways of showing subtitles. You can encode the pixels into the video itself. This is called "hardsubbing". The advantage here is the simplicity for the video player, it's just a video stream. The disadvantages are that you had to reencode the video, which takes time, and has some fidelity loss. If you get a better translation, well, it's pixels in the video. And you can only have one language.



            What is somewhat better is "softsubbing", which is to have a text file someplace, separate from the video stream. There are many different formats of subtitle files, but at their base they all have "text, start what time, remove what time" at their core. Some have additional features like colors and orientation on the screen. The advantage to this is you can have multiple languages (think of a DVD, you have multiple languages available) and you can fix typos and such in the file. And if you don't need subtitles, well you just turn them off.



            Softsubs can either be separate files - most players will automagically look for subtitles with the same name (different extension) as the main video. Or certain container file formats (like MKV) can have them embedded inside. Check out MKVtoolnix (there is a mac port) for MKV file tools. This should let you embed softsubs without reencoding.



            Note that not all players can support all formats. My experience is that XBMC has issues with SSA files, but the much simpler SRT files are fine. VLC will play anything, if it's supported on your platform.






            share|improve this answer





















            • 1





              Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

              – evilsoup
              Jun 18 '13 at 16:17











            • @evilsoup thanks, didn't know that.

              – Rich Homolka
              Jun 18 '13 at 17:04






            • 1





              Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

              – Karan
              Jun 18 '13 at 19:20











            • changed link to the direct download page.

              – Bora
              Jun 18 '13 at 23:38
















            4














            There are two basic ways of showing subtitles. You can encode the pixels into the video itself. This is called "hardsubbing". The advantage here is the simplicity for the video player, it's just a video stream. The disadvantages are that you had to reencode the video, which takes time, and has some fidelity loss. If you get a better translation, well, it's pixels in the video. And you can only have one language.



            What is somewhat better is "softsubbing", which is to have a text file someplace, separate from the video stream. There are many different formats of subtitle files, but at their base they all have "text, start what time, remove what time" at their core. Some have additional features like colors and orientation on the screen. The advantage to this is you can have multiple languages (think of a DVD, you have multiple languages available) and you can fix typos and such in the file. And if you don't need subtitles, well you just turn them off.



            Softsubs can either be separate files - most players will automagically look for subtitles with the same name (different extension) as the main video. Or certain container file formats (like MKV) can have them embedded inside. Check out MKVtoolnix (there is a mac port) for MKV file tools. This should let you embed softsubs without reencoding.



            Note that not all players can support all formats. My experience is that XBMC has issues with SSA files, but the much simpler SRT files are fine. VLC will play anything, if it's supported on your platform.






            share|improve this answer





















            • 1





              Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

              – evilsoup
              Jun 18 '13 at 16:17











            • @evilsoup thanks, didn't know that.

              – Rich Homolka
              Jun 18 '13 at 17:04






            • 1





              Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

              – Karan
              Jun 18 '13 at 19:20











            • changed link to the direct download page.

              – Bora
              Jun 18 '13 at 23:38














            4












            4








            4







            There are two basic ways of showing subtitles. You can encode the pixels into the video itself. This is called "hardsubbing". The advantage here is the simplicity for the video player, it's just a video stream. The disadvantages are that you had to reencode the video, which takes time, and has some fidelity loss. If you get a better translation, well, it's pixels in the video. And you can only have one language.



            What is somewhat better is "softsubbing", which is to have a text file someplace, separate from the video stream. There are many different formats of subtitle files, but at their base they all have "text, start what time, remove what time" at their core. Some have additional features like colors and orientation on the screen. The advantage to this is you can have multiple languages (think of a DVD, you have multiple languages available) and you can fix typos and such in the file. And if you don't need subtitles, well you just turn them off.



            Softsubs can either be separate files - most players will automagically look for subtitles with the same name (different extension) as the main video. Or certain container file formats (like MKV) can have them embedded inside. Check out MKVtoolnix (there is a mac port) for MKV file tools. This should let you embed softsubs without reencoding.



            Note that not all players can support all formats. My experience is that XBMC has issues with SSA files, but the much simpler SRT files are fine. VLC will play anything, if it's supported on your platform.






            share|improve this answer















            There are two basic ways of showing subtitles. You can encode the pixels into the video itself. This is called "hardsubbing". The advantage here is the simplicity for the video player, it's just a video stream. The disadvantages are that you had to reencode the video, which takes time, and has some fidelity loss. If you get a better translation, well, it's pixels in the video. And you can only have one language.



            What is somewhat better is "softsubbing", which is to have a text file someplace, separate from the video stream. There are many different formats of subtitle files, but at their base they all have "text, start what time, remove what time" at their core. Some have additional features like colors and orientation on the screen. The advantage to this is you can have multiple languages (think of a DVD, you have multiple languages available) and you can fix typos and such in the file. And if you don't need subtitles, well you just turn them off.



            Softsubs can either be separate files - most players will automagically look for subtitles with the same name (different extension) as the main video. Or certain container file formats (like MKV) can have them embedded inside. Check out MKVtoolnix (there is a mac port) for MKV file tools. This should let you embed softsubs without reencoding.



            Note that not all players can support all formats. My experience is that XBMC has issues with SSA files, but the much simpler SRT files are fine. VLC will play anything, if it's supported on your platform.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 18 '13 at 16:04

























            answered Jun 18 '13 at 15:57









            Rich HomolkaRich Homolka

            25.5k64367




            25.5k64367








            • 1





              Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

              – evilsoup
              Jun 18 '13 at 16:17











            • @evilsoup thanks, didn't know that.

              – Rich Homolka
              Jun 18 '13 at 17:04






            • 1





              Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

              – Karan
              Jun 18 '13 at 19:20











            • changed link to the direct download page.

              – Bora
              Jun 18 '13 at 23:38














            • 1





              Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

              – evilsoup
              Jun 18 '13 at 16:17











            • @evilsoup thanks, didn't know that.

              – Rich Homolka
              Jun 18 '13 at 17:04






            • 1





              Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

              – Karan
              Jun 18 '13 at 19:20











            • changed link to the direct download page.

              – Bora
              Jun 18 '13 at 23:38








            1




            1





            Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

            – evilsoup
            Jun 18 '13 at 16:17





            Good answer, though it should be noted that some soft-subtitles -- especially DVD subtitles -- are bitmap-based, rather than text-based. The main effect of which is to make them almost impossible to edit -_-

            – evilsoup
            Jun 18 '13 at 16:17













            @evilsoup thanks, didn't know that.

            – Rich Homolka
            Jun 18 '13 at 17:04





            @evilsoup thanks, didn't know that.

            – Rich Homolka
            Jun 18 '13 at 17:04




            1




            1





            Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

            – Karan
            Jun 18 '13 at 19:20





            Yep, IDX+SUB VOBsub, where IDX is a text file but SUB contains bitmaps.

            – Karan
            Jun 18 '13 at 19:20













            changed link to the direct download page.

            – Bora
            Jun 18 '13 at 23:38





            changed link to the direct download page.

            – Bora
            Jun 18 '13 at 23:38











            0














            I realize this is an old question and user495470’s answer has been accepted as of 2013, but since part of the question is about adding subtitles to files, I wanted to add this new addition.



            Basically, I needed to merge dozens of .ass subtitles into similarly named MKV files, so doing this one command at a time was not cutting it. So I whipped up this simple Bash script that will search the current directory it’s run from for .ass files and then merge them as expected.



            find -E . -maxdepth 1 -type f -iregex '.*.(ASS|SRT)$' |
            while read FILEPATH
            do
            DIRNAME=$(dirname "${FILEPATH}");
            BASENAME=$(basename "${FILEPATH}");
            FILENAME="${BASENAME%.*}";
            EXTENSION="${BASENAME##*.}"
            mkvmerge -o "/Users/jake/${FILENAME}"-NEW.mkv "${FILENAME}".mp4 --language 0:eng --track-name 0:English "${FILENAME}"."${EXTENSION}"
            done


            Of course, this simple script assumes that the subtitles are English and merges them as such, but that can be manually adjusted per usage need; the big issue of automatically merging the subtitles with the MKV is solved by a simple script like this.






            share|improve this answer






























              0














              I realize this is an old question and user495470’s answer has been accepted as of 2013, but since part of the question is about adding subtitles to files, I wanted to add this new addition.



              Basically, I needed to merge dozens of .ass subtitles into similarly named MKV files, so doing this one command at a time was not cutting it. So I whipped up this simple Bash script that will search the current directory it’s run from for .ass files and then merge them as expected.



              find -E . -maxdepth 1 -type f -iregex '.*.(ASS|SRT)$' |
              while read FILEPATH
              do
              DIRNAME=$(dirname "${FILEPATH}");
              BASENAME=$(basename "${FILEPATH}");
              FILENAME="${BASENAME%.*}";
              EXTENSION="${BASENAME##*.}"
              mkvmerge -o "/Users/jake/${FILENAME}"-NEW.mkv "${FILENAME}".mp4 --language 0:eng --track-name 0:English "${FILENAME}"."${EXTENSION}"
              done


              Of course, this simple script assumes that the subtitles are English and merges them as such, but that can be manually adjusted per usage need; the big issue of automatically merging the subtitles with the MKV is solved by a simple script like this.






              share|improve this answer




























                0












                0








                0







                I realize this is an old question and user495470’s answer has been accepted as of 2013, but since part of the question is about adding subtitles to files, I wanted to add this new addition.



                Basically, I needed to merge dozens of .ass subtitles into similarly named MKV files, so doing this one command at a time was not cutting it. So I whipped up this simple Bash script that will search the current directory it’s run from for .ass files and then merge them as expected.



                find -E . -maxdepth 1 -type f -iregex '.*.(ASS|SRT)$' |
                while read FILEPATH
                do
                DIRNAME=$(dirname "${FILEPATH}");
                BASENAME=$(basename "${FILEPATH}");
                FILENAME="${BASENAME%.*}";
                EXTENSION="${BASENAME##*.}"
                mkvmerge -o "/Users/jake/${FILENAME}"-NEW.mkv "${FILENAME}".mp4 --language 0:eng --track-name 0:English "${FILENAME}"."${EXTENSION}"
                done


                Of course, this simple script assumes that the subtitles are English and merges them as such, but that can be manually adjusted per usage need; the big issue of automatically merging the subtitles with the MKV is solved by a simple script like this.






                share|improve this answer















                I realize this is an old question and user495470’s answer has been accepted as of 2013, but since part of the question is about adding subtitles to files, I wanted to add this new addition.



                Basically, I needed to merge dozens of .ass subtitles into similarly named MKV files, so doing this one command at a time was not cutting it. So I whipped up this simple Bash script that will search the current directory it’s run from for .ass files and then merge them as expected.



                find -E . -maxdepth 1 -type f -iregex '.*.(ASS|SRT)$' |
                while read FILEPATH
                do
                DIRNAME=$(dirname "${FILEPATH}");
                BASENAME=$(basename "${FILEPATH}");
                FILENAME="${BASENAME%.*}";
                EXTENSION="${BASENAME##*.}"
                mkvmerge -o "/Users/jake/${FILENAME}"-NEW.mkv "${FILENAME}".mp4 --language 0:eng --track-name 0:English "${FILENAME}"."${EXTENSION}"
                done


                Of course, this simple script assumes that the subtitles are English and merges them as such, but that can be manually adjusted per usage need; the big issue of automatically merging the subtitles with the MKV is solved by a simple script like this.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 20 at 3:21

























                answered Jan 8 '18 at 2:39









                JakeGouldJakeGould

                32k1098140




                32k1098140

















                    protected by slhck Jan 17 '14 at 14:15



                    Thank you for your interest in this question.
                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                    Would you like to answer one of these unanswered questions instead?



                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy