How to merge subtitle to video?











up vote
6
down vote

favorite












How can I merge subtitle to a movie to play on my android TV?



I searched for a long time but almost program no longer work on ubuntu or I can't find the repository .
Here is some answer but I think it's no longer supported on 16.04










share|improve this question




















  • 4




    You really tried all the 4 programs on that question? FFMPEG works.
    – Braiam
    Jun 11 '16 at 0:49










  • You can have a reference at this article: debugpoint.com/2015/08/…
    – Sunderlandgreen201503
    May 5 '17 at 9:40















up vote
6
down vote

favorite












How can I merge subtitle to a movie to play on my android TV?



I searched for a long time but almost program no longer work on ubuntu or I can't find the repository .
Here is some answer but I think it's no longer supported on 16.04










share|improve this question




















  • 4




    You really tried all the 4 programs on that question? FFMPEG works.
    – Braiam
    Jun 11 '16 at 0:49










  • You can have a reference at this article: debugpoint.com/2015/08/…
    – Sunderlandgreen201503
    May 5 '17 at 9:40













up vote
6
down vote

favorite









up vote
6
down vote

favorite











How can I merge subtitle to a movie to play on my android TV?



I searched for a long time but almost program no longer work on ubuntu or I can't find the repository .
Here is some answer but I think it's no longer supported on 16.04










share|improve this question















How can I merge subtitle to a movie to play on my android TV?



I searched for a long time but almost program no longer work on ubuntu or I can't find the repository .
Here is some answer but I think it's no longer supported on 16.04







video






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 5 '17 at 5:53









Varun Kamani

31




31










asked Jun 10 '16 at 23:26







user554187















  • 4




    You really tried all the 4 programs on that question? FFMPEG works.
    – Braiam
    Jun 11 '16 at 0:49










  • You can have a reference at this article: debugpoint.com/2015/08/…
    – Sunderlandgreen201503
    May 5 '17 at 9:40














  • 4




    You really tried all the 4 programs on that question? FFMPEG works.
    – Braiam
    Jun 11 '16 at 0:49










  • You can have a reference at this article: debugpoint.com/2015/08/…
    – Sunderlandgreen201503
    May 5 '17 at 9:40








4




4




You really tried all the 4 programs on that question? FFMPEG works.
– Braiam
Jun 11 '16 at 0:49




You really tried all the 4 programs on that question? FFMPEG works.
– Braiam
Jun 11 '16 at 0:49












You can have a reference at this article: debugpoint.com/2015/08/…
– Sunderlandgreen201503
May 5 '17 at 9:40




You can have a reference at this article: debugpoint.com/2015/08/…
– Sunderlandgreen201503
May 5 '17 at 9:40










3 Answers
3






active

oldest

votes

















up vote
13
down vote



accepted










I use Hand Brake on my ubuntu 16.04 great application and very simple to use .
https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases



Installation:



sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get update
sudo apt-get install handbrake


How it work:




  • Click on source and chose movie.

  • From subtitle List tab click on Add.

  • don't forget to tick on Burn into video.
    List item

  • finally click on Start.






share|improve this answer























  • hey mohamed thanks , works like a charm :D
    – user554187
    Jun 10 '16 at 23:42






  • 1




    @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
    – Mohamed Slama
    Jun 11 '16 at 2:18






  • 1




    mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
    – Peter Cordes
    Jun 11 '16 at 2:23






  • 2




    I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
    – Peter Cordes
    Jun 11 '16 at 2:46








  • 1




    @PeterCordes Thanks for valuable information it worth to try :D
    – Mohamed Slama
    Jun 11 '16 at 2:57


















up vote
10
down vote













If your TV can play movies that have subtitles muxed into the same file as the video, there are many advantages to adding the subtitles as a subtitle track, instead of burning them into the video.



mkvmerge -o movie_with_subs.mkv   movie.mp4  subs.srt


That will include all tracks from the mp4 (video, audio, chapters), and subs from the srt as a text subtitle track. It takes about as long as copying the file, since it doesn't have to decode/re-encode the video.



Ubuntu packages mkvmerge in mkvtoolnix. There's an mkvtoolnix-gui package, with a gui frontend. It has a lot of options to let you control things like the subtitle offset.



The major advantage to this is that you avoid degrading the quality with another decode/encode cycle of generation loss. It's impossible to avoid losing quality when transcoding, and it takes a lot of CPU time to even come close to the quality-per-filesize of a well-encoded source. (e.g. x264 with -preset slower, or if your player supports it, x265 if you're willing to spend a huge amount of CPU time to make smaller files that still look good). If you don't care about file size because you're just streaming it to your TV, transcoding with x264 with -preset veryfast -crf15 can run quickly and lose minimal quality.



Another advantage to muxing subs is that you can then toggle the subs on/off, or have your player show them in a different position on screen.



You can also extract them later and search them if you're trying to remember a line from the movie.



You can even extract them, fix typos, and mux them back in.






share|improve this answer






























    up vote
    1
    down vote













    I think that MKVToolNix is the simplest and easiest-to-use free tool available for you to merge a video file with a subtitles file. Just install it by e.g. running a terminal/shell command such as:



    sudo apt-get install mkvtoolnix mkvtoolnix-gui -y


    ...and then run it, right-click the Source files area in order to add your video file and your subtitles file (step 1, at the picture below), specify the location of the destination MKV video file (step 2) and then click on Start multiplexing (step 3). Done.



    MVKToolNix's main window



    MKVToolNix muxes/multiplexes the subtitles track/stream along with the video track/stream. This means that the output MKV file (e.g. /tmp/output.mkv) will be a video file that contains subtitles embedded in it and you will be able to turn the subtitles on and off, while such MKV video is playing.



    PS: if your Android TV doesn't play MKV video files, use MX Player, Kodi Player or VLC Media Player to add MKV playback support.





    What if you want subtitles "fused" (hardcoded) in the video, instead of just muxed/multiplexed?



    In such case, a laborious-yet-rewarding approach consists of (1) converting your subtitles file to the SSA format, (2) editing the SSA's Style line and then (3) using avconv/ffmpeg to merge/hardcode such stylized subtitles into the video track/stream (the subtitles' characters will then be converted to pictograms or graphical symbols, i.e. pixels not only "laid over" the video's pictures/frames but replacing some of such pixels).



    Here's how to do it:




    1. Use a subtitles editor such as GNOME Subtitles (to install it from the shell, run sudo apt-get install gnome-subtitles -y) to convert your subtitles file (e.g. input.srt) to the SSA format (e.g. input.ssa) and then save the SSA file in /tmp (you'll thus have /tmp/input.ssa).

    2. Use a simple text editor such as Gedit (install it with the shell command sudo apt-get install gedit -y) to open your SSA file and then replace the entire Style line by this one:


    Style: Default,Arial,16,&H00FFFF,&H00FFFF,&H00FFFF,&H77000000,2,0,3,2,1,2,10,10,10,0,0



    After replacing the Style line, save the SSA file and then close the text editor. The configuration line above will globally preset the subtitles with a 16pt yellow Arial font and will add a semi-transparent black background behind the subtitles (to make reading them easier).





    1. Now it's time to use avconv:



      3.1. Install the avconv and ffmpeg packages by running this shell command:



      sudo apt-get install ffmpeg libav-tools -y


      3.2. Move your video file (e.g. input.avi) to the /tmp folder, in order to end up having e.g. /tmp/input.avi and /tmp/input.ssa



      3.3. Run the shell command cd /tmp in order to cause the Linux shell to access the /tmp directory



      3.4. Hardcode the SSA subtitles into the video file by running this shell command:



      avconv -i input.avi -map 0:0 -map 0:1 -c:v libx264 -aspect 16:9 -q:v 1 -b:v 512k -strict -2 -c:a aac -ac 2 -filter:v subtitles=input.ssa output.mp4



    The output of the command above will be /tmp/output.mp4 and you'll notice that such MP4 video file will have hardcoded bitmap subtitles.



    If you want to decrease the quality of the merged/output video in order to make its file smaller and possibly wait less time for the merging process to end, decrease 512k to a smaller value (e.g. 256k). If you decide to increase the quality of the merged/output video at the cost of getting a bigger file size and possibly waiting more for the merging process to end, increase 512k to a bigger value (e.g. 768k).






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f785508%2fhow-to-merge-subtitle-to-video%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown
























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      13
      down vote



      accepted










      I use Hand Brake on my ubuntu 16.04 great application and very simple to use .
      https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases



      Installation:



      sudo add-apt-repository ppa:stebbins/handbrake-releases
      sudo apt-get update
      sudo apt-get install handbrake


      How it work:




      • Click on source and chose movie.

      • From subtitle List tab click on Add.

      • don't forget to tick on Burn into video.
        List item

      • finally click on Start.






      share|improve this answer























      • hey mohamed thanks , works like a charm :D
        – user554187
        Jun 10 '16 at 23:42






      • 1




        @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
        – Mohamed Slama
        Jun 11 '16 at 2:18






      • 1




        mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
        – Peter Cordes
        Jun 11 '16 at 2:23






      • 2




        I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
        – Peter Cordes
        Jun 11 '16 at 2:46








      • 1




        @PeterCordes Thanks for valuable information it worth to try :D
        – Mohamed Slama
        Jun 11 '16 at 2:57















      up vote
      13
      down vote



      accepted










      I use Hand Brake on my ubuntu 16.04 great application and very simple to use .
      https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases



      Installation:



      sudo add-apt-repository ppa:stebbins/handbrake-releases
      sudo apt-get update
      sudo apt-get install handbrake


      How it work:




      • Click on source and chose movie.

      • From subtitle List tab click on Add.

      • don't forget to tick on Burn into video.
        List item

      • finally click on Start.






      share|improve this answer























      • hey mohamed thanks , works like a charm :D
        – user554187
        Jun 10 '16 at 23:42






      • 1




        @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
        – Mohamed Slama
        Jun 11 '16 at 2:18






      • 1




        mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
        – Peter Cordes
        Jun 11 '16 at 2:23






      • 2




        I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
        – Peter Cordes
        Jun 11 '16 at 2:46








      • 1




        @PeterCordes Thanks for valuable information it worth to try :D
        – Mohamed Slama
        Jun 11 '16 at 2:57













      up vote
      13
      down vote



      accepted







      up vote
      13
      down vote



      accepted






      I use Hand Brake on my ubuntu 16.04 great application and very simple to use .
      https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases



      Installation:



      sudo add-apt-repository ppa:stebbins/handbrake-releases
      sudo apt-get update
      sudo apt-get install handbrake


      How it work:




      • Click on source and chose movie.

      • From subtitle List tab click on Add.

      • don't forget to tick on Burn into video.
        List item

      • finally click on Start.






      share|improve this answer














      I use Hand Brake on my ubuntu 16.04 great application and very simple to use .
      https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases



      Installation:



      sudo add-apt-repository ppa:stebbins/handbrake-releases
      sudo apt-get update
      sudo apt-get install handbrake


      How it work:




      • Click on source and chose movie.

      • From subtitle List tab click on Add.

      • don't forget to tick on Burn into video.
        List item

      • finally click on Start.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jun 10 '16 at 23:40

























      answered Jun 10 '16 at 23:28









      Mohamed Slama

      1,329833




      1,329833












      • hey mohamed thanks , works like a charm :D
        – user554187
        Jun 10 '16 at 23:42






      • 1




        @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
        – Mohamed Slama
        Jun 11 '16 at 2:18






      • 1




        mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
        – Peter Cordes
        Jun 11 '16 at 2:23






      • 2




        I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
        – Peter Cordes
        Jun 11 '16 at 2:46








      • 1




        @PeterCordes Thanks for valuable information it worth to try :D
        – Mohamed Slama
        Jun 11 '16 at 2:57


















      • hey mohamed thanks , works like a charm :D
        – user554187
        Jun 10 '16 at 23:42






      • 1




        @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
        – Mohamed Slama
        Jun 11 '16 at 2:18






      • 1




        mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
        – Peter Cordes
        Jun 11 '16 at 2:23






      • 2




        I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
        – Peter Cordes
        Jun 11 '16 at 2:46








      • 1




        @PeterCordes Thanks for valuable information it worth to try :D
        – Mohamed Slama
        Jun 11 '16 at 2:57
















      hey mohamed thanks , works like a charm :D
      – user554187
      Jun 10 '16 at 23:42




      hey mohamed thanks , works like a charm :D
      – user554187
      Jun 10 '16 at 23:42




      1




      1




      @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
      – Mohamed Slama
      Jun 11 '16 at 2:18




      @PeterCordes i don't know if mkvmerge still supported on 16.04 but when i tried on 14.04 was buggy (not appering arabic subtitle) for me hand brake quality of the original file is the same and is fast may because i have SSD anyway it's great to post new answer for another technology :D
      – Mohamed Slama
      Jun 11 '16 at 2:18




      1




      1




      mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
      – Peter Cordes
      Jun 11 '16 at 2:23




      mkvmerge does a 1GB file in a couple seconds with fast hard drives. Transcoding will take at least a few minutes (on a fast multi-core CPU), and that's only if you don't care at all about the file size of the output. If you use a high enough bitrate, you won't be able to notice the quality loss, but it's there. (And your new file will be significantly bigger than your original.)
      – Peter Cordes
      Jun 11 '16 at 2:23




      2




      2




      I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
      – Peter Cordes
      Jun 11 '16 at 2:46






      I know you want to play it on your TV. My point was that it's not actually mkvmerge that buggy, just that your TV's lack of support means muxing an srt probably can't work. If you're interested in trying out the bitmap-subtitle idea, google for "convert srt to vobsub", pick a program and try muxing that into an mkv. First check that it plays on your Ubuntu desktop, then see what happens on your TV. Your definition of "fine" is a lot different from mine; I wouldn't consider it acceptable to lose even a tiny bit of quality by transcoding, especially not to a larger file.
      – Peter Cordes
      Jun 11 '16 at 2:46






      1




      1




      @PeterCordes Thanks for valuable information it worth to try :D
      – Mohamed Slama
      Jun 11 '16 at 2:57




      @PeterCordes Thanks for valuable information it worth to try :D
      – Mohamed Slama
      Jun 11 '16 at 2:57












      up vote
      10
      down vote













      If your TV can play movies that have subtitles muxed into the same file as the video, there are many advantages to adding the subtitles as a subtitle track, instead of burning them into the video.



      mkvmerge -o movie_with_subs.mkv   movie.mp4  subs.srt


      That will include all tracks from the mp4 (video, audio, chapters), and subs from the srt as a text subtitle track. It takes about as long as copying the file, since it doesn't have to decode/re-encode the video.



      Ubuntu packages mkvmerge in mkvtoolnix. There's an mkvtoolnix-gui package, with a gui frontend. It has a lot of options to let you control things like the subtitle offset.



      The major advantage to this is that you avoid degrading the quality with another decode/encode cycle of generation loss. It's impossible to avoid losing quality when transcoding, and it takes a lot of CPU time to even come close to the quality-per-filesize of a well-encoded source. (e.g. x264 with -preset slower, or if your player supports it, x265 if you're willing to spend a huge amount of CPU time to make smaller files that still look good). If you don't care about file size because you're just streaming it to your TV, transcoding with x264 with -preset veryfast -crf15 can run quickly and lose minimal quality.



      Another advantage to muxing subs is that you can then toggle the subs on/off, or have your player show them in a different position on screen.



      You can also extract them later and search them if you're trying to remember a line from the movie.



      You can even extract them, fix typos, and mux them back in.






      share|improve this answer



























        up vote
        10
        down vote













        If your TV can play movies that have subtitles muxed into the same file as the video, there are many advantages to adding the subtitles as a subtitle track, instead of burning them into the video.



        mkvmerge -o movie_with_subs.mkv   movie.mp4  subs.srt


        That will include all tracks from the mp4 (video, audio, chapters), and subs from the srt as a text subtitle track. It takes about as long as copying the file, since it doesn't have to decode/re-encode the video.



        Ubuntu packages mkvmerge in mkvtoolnix. There's an mkvtoolnix-gui package, with a gui frontend. It has a lot of options to let you control things like the subtitle offset.



        The major advantage to this is that you avoid degrading the quality with another decode/encode cycle of generation loss. It's impossible to avoid losing quality when transcoding, and it takes a lot of CPU time to even come close to the quality-per-filesize of a well-encoded source. (e.g. x264 with -preset slower, or if your player supports it, x265 if you're willing to spend a huge amount of CPU time to make smaller files that still look good). If you don't care about file size because you're just streaming it to your TV, transcoding with x264 with -preset veryfast -crf15 can run quickly and lose minimal quality.



        Another advantage to muxing subs is that you can then toggle the subs on/off, or have your player show them in a different position on screen.



        You can also extract them later and search them if you're trying to remember a line from the movie.



        You can even extract them, fix typos, and mux them back in.






        share|improve this answer

























          up vote
          10
          down vote










          up vote
          10
          down vote









          If your TV can play movies that have subtitles muxed into the same file as the video, there are many advantages to adding the subtitles as a subtitle track, instead of burning them into the video.



          mkvmerge -o movie_with_subs.mkv   movie.mp4  subs.srt


          That will include all tracks from the mp4 (video, audio, chapters), and subs from the srt as a text subtitle track. It takes about as long as copying the file, since it doesn't have to decode/re-encode the video.



          Ubuntu packages mkvmerge in mkvtoolnix. There's an mkvtoolnix-gui package, with a gui frontend. It has a lot of options to let you control things like the subtitle offset.



          The major advantage to this is that you avoid degrading the quality with another decode/encode cycle of generation loss. It's impossible to avoid losing quality when transcoding, and it takes a lot of CPU time to even come close to the quality-per-filesize of a well-encoded source. (e.g. x264 with -preset slower, or if your player supports it, x265 if you're willing to spend a huge amount of CPU time to make smaller files that still look good). If you don't care about file size because you're just streaming it to your TV, transcoding with x264 with -preset veryfast -crf15 can run quickly and lose minimal quality.



          Another advantage to muxing subs is that you can then toggle the subs on/off, or have your player show them in a different position on screen.



          You can also extract them later and search them if you're trying to remember a line from the movie.



          You can even extract them, fix typos, and mux them back in.






          share|improve this answer














          If your TV can play movies that have subtitles muxed into the same file as the video, there are many advantages to adding the subtitles as a subtitle track, instead of burning them into the video.



          mkvmerge -o movie_with_subs.mkv   movie.mp4  subs.srt


          That will include all tracks from the mp4 (video, audio, chapters), and subs from the srt as a text subtitle track. It takes about as long as copying the file, since it doesn't have to decode/re-encode the video.



          Ubuntu packages mkvmerge in mkvtoolnix. There's an mkvtoolnix-gui package, with a gui frontend. It has a lot of options to let you control things like the subtitle offset.



          The major advantage to this is that you avoid degrading the quality with another decode/encode cycle of generation loss. It's impossible to avoid losing quality when transcoding, and it takes a lot of CPU time to even come close to the quality-per-filesize of a well-encoded source. (e.g. x264 with -preset slower, or if your player supports it, x265 if you're willing to spend a huge amount of CPU time to make smaller files that still look good). If you don't care about file size because you're just streaming it to your TV, transcoding with x264 with -preset veryfast -crf15 can run quickly and lose minimal quality.



          Another advantage to muxing subs is that you can then toggle the subs on/off, or have your player show them in a different position on screen.



          You can also extract them later and search them if you're trying to remember a line from the movie.



          You can even extract them, fix typos, and mux them back in.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 12 '16 at 9:38

























          answered Jun 11 '16 at 2:11









          Peter Cordes

          841714




          841714






















              up vote
              1
              down vote













              I think that MKVToolNix is the simplest and easiest-to-use free tool available for you to merge a video file with a subtitles file. Just install it by e.g. running a terminal/shell command such as:



              sudo apt-get install mkvtoolnix mkvtoolnix-gui -y


              ...and then run it, right-click the Source files area in order to add your video file and your subtitles file (step 1, at the picture below), specify the location of the destination MKV video file (step 2) and then click on Start multiplexing (step 3). Done.



              MVKToolNix's main window



              MKVToolNix muxes/multiplexes the subtitles track/stream along with the video track/stream. This means that the output MKV file (e.g. /tmp/output.mkv) will be a video file that contains subtitles embedded in it and you will be able to turn the subtitles on and off, while such MKV video is playing.



              PS: if your Android TV doesn't play MKV video files, use MX Player, Kodi Player or VLC Media Player to add MKV playback support.





              What if you want subtitles "fused" (hardcoded) in the video, instead of just muxed/multiplexed?



              In such case, a laborious-yet-rewarding approach consists of (1) converting your subtitles file to the SSA format, (2) editing the SSA's Style line and then (3) using avconv/ffmpeg to merge/hardcode such stylized subtitles into the video track/stream (the subtitles' characters will then be converted to pictograms or graphical symbols, i.e. pixels not only "laid over" the video's pictures/frames but replacing some of such pixels).



              Here's how to do it:




              1. Use a subtitles editor such as GNOME Subtitles (to install it from the shell, run sudo apt-get install gnome-subtitles -y) to convert your subtitles file (e.g. input.srt) to the SSA format (e.g. input.ssa) and then save the SSA file in /tmp (you'll thus have /tmp/input.ssa).

              2. Use a simple text editor such as Gedit (install it with the shell command sudo apt-get install gedit -y) to open your SSA file and then replace the entire Style line by this one:


              Style: Default,Arial,16,&H00FFFF,&H00FFFF,&H00FFFF,&H77000000,2,0,3,2,1,2,10,10,10,0,0



              After replacing the Style line, save the SSA file and then close the text editor. The configuration line above will globally preset the subtitles with a 16pt yellow Arial font and will add a semi-transparent black background behind the subtitles (to make reading them easier).





              1. Now it's time to use avconv:



                3.1. Install the avconv and ffmpeg packages by running this shell command:



                sudo apt-get install ffmpeg libav-tools -y


                3.2. Move your video file (e.g. input.avi) to the /tmp folder, in order to end up having e.g. /tmp/input.avi and /tmp/input.ssa



                3.3. Run the shell command cd /tmp in order to cause the Linux shell to access the /tmp directory



                3.4. Hardcode the SSA subtitles into the video file by running this shell command:



                avconv -i input.avi -map 0:0 -map 0:1 -c:v libx264 -aspect 16:9 -q:v 1 -b:v 512k -strict -2 -c:a aac -ac 2 -filter:v subtitles=input.ssa output.mp4



              The output of the command above will be /tmp/output.mp4 and you'll notice that such MP4 video file will have hardcoded bitmap subtitles.



              If you want to decrease the quality of the merged/output video in order to make its file smaller and possibly wait less time for the merging process to end, decrease 512k to a smaller value (e.g. 256k). If you decide to increase the quality of the merged/output video at the cost of getting a bigger file size and possibly waiting more for the merging process to end, increase 512k to a bigger value (e.g. 768k).






              share|improve this answer



























                up vote
                1
                down vote













                I think that MKVToolNix is the simplest and easiest-to-use free tool available for you to merge a video file with a subtitles file. Just install it by e.g. running a terminal/shell command such as:



                sudo apt-get install mkvtoolnix mkvtoolnix-gui -y


                ...and then run it, right-click the Source files area in order to add your video file and your subtitles file (step 1, at the picture below), specify the location of the destination MKV video file (step 2) and then click on Start multiplexing (step 3). Done.



                MVKToolNix's main window



                MKVToolNix muxes/multiplexes the subtitles track/stream along with the video track/stream. This means that the output MKV file (e.g. /tmp/output.mkv) will be a video file that contains subtitles embedded in it and you will be able to turn the subtitles on and off, while such MKV video is playing.



                PS: if your Android TV doesn't play MKV video files, use MX Player, Kodi Player or VLC Media Player to add MKV playback support.





                What if you want subtitles "fused" (hardcoded) in the video, instead of just muxed/multiplexed?



                In such case, a laborious-yet-rewarding approach consists of (1) converting your subtitles file to the SSA format, (2) editing the SSA's Style line and then (3) using avconv/ffmpeg to merge/hardcode such stylized subtitles into the video track/stream (the subtitles' characters will then be converted to pictograms or graphical symbols, i.e. pixels not only "laid over" the video's pictures/frames but replacing some of such pixels).



                Here's how to do it:




                1. Use a subtitles editor such as GNOME Subtitles (to install it from the shell, run sudo apt-get install gnome-subtitles -y) to convert your subtitles file (e.g. input.srt) to the SSA format (e.g. input.ssa) and then save the SSA file in /tmp (you'll thus have /tmp/input.ssa).

                2. Use a simple text editor such as Gedit (install it with the shell command sudo apt-get install gedit -y) to open your SSA file and then replace the entire Style line by this one:


                Style: Default,Arial,16,&H00FFFF,&H00FFFF,&H00FFFF,&H77000000,2,0,3,2,1,2,10,10,10,0,0



                After replacing the Style line, save the SSA file and then close the text editor. The configuration line above will globally preset the subtitles with a 16pt yellow Arial font and will add a semi-transparent black background behind the subtitles (to make reading them easier).





                1. Now it's time to use avconv:



                  3.1. Install the avconv and ffmpeg packages by running this shell command:



                  sudo apt-get install ffmpeg libav-tools -y


                  3.2. Move your video file (e.g. input.avi) to the /tmp folder, in order to end up having e.g. /tmp/input.avi and /tmp/input.ssa



                  3.3. Run the shell command cd /tmp in order to cause the Linux shell to access the /tmp directory



                  3.4. Hardcode the SSA subtitles into the video file by running this shell command:



                  avconv -i input.avi -map 0:0 -map 0:1 -c:v libx264 -aspect 16:9 -q:v 1 -b:v 512k -strict -2 -c:a aac -ac 2 -filter:v subtitles=input.ssa output.mp4



                The output of the command above will be /tmp/output.mp4 and you'll notice that such MP4 video file will have hardcoded bitmap subtitles.



                If you want to decrease the quality of the merged/output video in order to make its file smaller and possibly wait less time for the merging process to end, decrease 512k to a smaller value (e.g. 256k). If you decide to increase the quality of the merged/output video at the cost of getting a bigger file size and possibly waiting more for the merging process to end, increase 512k to a bigger value (e.g. 768k).






                share|improve this answer

























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  I think that MKVToolNix is the simplest and easiest-to-use free tool available for you to merge a video file with a subtitles file. Just install it by e.g. running a terminal/shell command such as:



                  sudo apt-get install mkvtoolnix mkvtoolnix-gui -y


                  ...and then run it, right-click the Source files area in order to add your video file and your subtitles file (step 1, at the picture below), specify the location of the destination MKV video file (step 2) and then click on Start multiplexing (step 3). Done.



                  MVKToolNix's main window



                  MKVToolNix muxes/multiplexes the subtitles track/stream along with the video track/stream. This means that the output MKV file (e.g. /tmp/output.mkv) will be a video file that contains subtitles embedded in it and you will be able to turn the subtitles on and off, while such MKV video is playing.



                  PS: if your Android TV doesn't play MKV video files, use MX Player, Kodi Player or VLC Media Player to add MKV playback support.





                  What if you want subtitles "fused" (hardcoded) in the video, instead of just muxed/multiplexed?



                  In such case, a laborious-yet-rewarding approach consists of (1) converting your subtitles file to the SSA format, (2) editing the SSA's Style line and then (3) using avconv/ffmpeg to merge/hardcode such stylized subtitles into the video track/stream (the subtitles' characters will then be converted to pictograms or graphical symbols, i.e. pixels not only "laid over" the video's pictures/frames but replacing some of such pixels).



                  Here's how to do it:




                  1. Use a subtitles editor such as GNOME Subtitles (to install it from the shell, run sudo apt-get install gnome-subtitles -y) to convert your subtitles file (e.g. input.srt) to the SSA format (e.g. input.ssa) and then save the SSA file in /tmp (you'll thus have /tmp/input.ssa).

                  2. Use a simple text editor such as Gedit (install it with the shell command sudo apt-get install gedit -y) to open your SSA file and then replace the entire Style line by this one:


                  Style: Default,Arial,16,&H00FFFF,&H00FFFF,&H00FFFF,&H77000000,2,0,3,2,1,2,10,10,10,0,0



                  After replacing the Style line, save the SSA file and then close the text editor. The configuration line above will globally preset the subtitles with a 16pt yellow Arial font and will add a semi-transparent black background behind the subtitles (to make reading them easier).





                  1. Now it's time to use avconv:



                    3.1. Install the avconv and ffmpeg packages by running this shell command:



                    sudo apt-get install ffmpeg libav-tools -y


                    3.2. Move your video file (e.g. input.avi) to the /tmp folder, in order to end up having e.g. /tmp/input.avi and /tmp/input.ssa



                    3.3. Run the shell command cd /tmp in order to cause the Linux shell to access the /tmp directory



                    3.4. Hardcode the SSA subtitles into the video file by running this shell command:



                    avconv -i input.avi -map 0:0 -map 0:1 -c:v libx264 -aspect 16:9 -q:v 1 -b:v 512k -strict -2 -c:a aac -ac 2 -filter:v subtitles=input.ssa output.mp4



                  The output of the command above will be /tmp/output.mp4 and you'll notice that such MP4 video file will have hardcoded bitmap subtitles.



                  If you want to decrease the quality of the merged/output video in order to make its file smaller and possibly wait less time for the merging process to end, decrease 512k to a smaller value (e.g. 256k). If you decide to increase the quality of the merged/output video at the cost of getting a bigger file size and possibly waiting more for the merging process to end, increase 512k to a bigger value (e.g. 768k).






                  share|improve this answer














                  I think that MKVToolNix is the simplest and easiest-to-use free tool available for you to merge a video file with a subtitles file. Just install it by e.g. running a terminal/shell command such as:



                  sudo apt-get install mkvtoolnix mkvtoolnix-gui -y


                  ...and then run it, right-click the Source files area in order to add your video file and your subtitles file (step 1, at the picture below), specify the location of the destination MKV video file (step 2) and then click on Start multiplexing (step 3). Done.



                  MVKToolNix's main window



                  MKVToolNix muxes/multiplexes the subtitles track/stream along with the video track/stream. This means that the output MKV file (e.g. /tmp/output.mkv) will be a video file that contains subtitles embedded in it and you will be able to turn the subtitles on and off, while such MKV video is playing.



                  PS: if your Android TV doesn't play MKV video files, use MX Player, Kodi Player or VLC Media Player to add MKV playback support.





                  What if you want subtitles "fused" (hardcoded) in the video, instead of just muxed/multiplexed?



                  In such case, a laborious-yet-rewarding approach consists of (1) converting your subtitles file to the SSA format, (2) editing the SSA's Style line and then (3) using avconv/ffmpeg to merge/hardcode such stylized subtitles into the video track/stream (the subtitles' characters will then be converted to pictograms or graphical symbols, i.e. pixels not only "laid over" the video's pictures/frames but replacing some of such pixels).



                  Here's how to do it:




                  1. Use a subtitles editor such as GNOME Subtitles (to install it from the shell, run sudo apt-get install gnome-subtitles -y) to convert your subtitles file (e.g. input.srt) to the SSA format (e.g. input.ssa) and then save the SSA file in /tmp (you'll thus have /tmp/input.ssa).

                  2. Use a simple text editor such as Gedit (install it with the shell command sudo apt-get install gedit -y) to open your SSA file and then replace the entire Style line by this one:


                  Style: Default,Arial,16,&H00FFFF,&H00FFFF,&H00FFFF,&H77000000,2,0,3,2,1,2,10,10,10,0,0



                  After replacing the Style line, save the SSA file and then close the text editor. The configuration line above will globally preset the subtitles with a 16pt yellow Arial font and will add a semi-transparent black background behind the subtitles (to make reading them easier).





                  1. Now it's time to use avconv:



                    3.1. Install the avconv and ffmpeg packages by running this shell command:



                    sudo apt-get install ffmpeg libav-tools -y


                    3.2. Move your video file (e.g. input.avi) to the /tmp folder, in order to end up having e.g. /tmp/input.avi and /tmp/input.ssa



                    3.3. Run the shell command cd /tmp in order to cause the Linux shell to access the /tmp directory



                    3.4. Hardcode the SSA subtitles into the video file by running this shell command:



                    avconv -i input.avi -map 0:0 -map 0:1 -c:v libx264 -aspect 16:9 -q:v 1 -b:v 512k -strict -2 -c:a aac -ac 2 -filter:v subtitles=input.ssa output.mp4



                  The output of the command above will be /tmp/output.mp4 and you'll notice that such MP4 video file will have hardcoded bitmap subtitles.



                  If you want to decrease the quality of the merged/output video in order to make its file smaller and possibly wait less time for the merging process to end, decrease 512k to a smaller value (e.g. 256k). If you decide to increase the quality of the merged/output video at the cost of getting a bigger file size and possibly waiting more for the merging process to end, increase 512k to a bigger value (e.g. 768k).







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered Nov 22 at 6:36









                  Yuri Sucupira

                  612616




                  612616






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f785508%2fhow-to-merge-subtitle-to-video%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to send String Array data to Server using php in android

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                      Is anime1.com a legal site for watching anime?