Between Linux and Anime

Kind of like Schrodinger's Cat

Playing Multiple Subtitles Simultaneously with Mplayer

Well, with any player that plays ass subs really, but the procedure requires Mplayer :)

(I know I haven’t written a real post in a good while and this doesn’t quite count. I’ll post soon! I hope.. at least, I’m positively definitely trying to really write a proper post and push it out as soon as I’m positively capable of doing. No really!)

So I found myself needing to have both english and chinese subtitles on at once today and struggled with it briefly. I eventually found the solution in the form of a script called merge2ass (Source). What it does is it takes two different subtitle files and smushes it into a single ass file that basically shows the first subtitle file at the top of the screen and the second subtitle file at the bottom, something like this:

Yuki is sad all this is harder than she wanted

Usage of the script is simple enough. Make it executable, then supply the video file, the first subtitle file, then the second. You can also just run the script without arguments and it’ll show a nice help message.

chmod +x merge2ass.sh
./merge2ass.sh yourmoviefile.format sub1.srt sub2.srt

This will produce a file called yourmovilefile-bilingual.ass that you could then load with mplayer (or whatever other player you want) to get simultaneous dual subtitles.

Oh right, for this to work with chinese subtitles, you need to change line 125 and/or 128 of the script and supply -subcp enca:zh:BIG5 as an mplayer option, as per this post. Just add it immediately after ‘mplayer’, like so:

mplayer -subcp enca:zh:BIG5 -dumpsrtsub -noautosub -really-quiet -frames 0 -sub "${sub[1]}" "$movie" 2>>"$mplayer_err" && echo "Done"

1287
Rate this post
Thanks!
An error occurred!


  • Facebook
  • Twitter
  • Identi.ca
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • RSS
  • Reddit

Previous

The Clannad Basketball Match: VN vs Anime

Next

Spring 2013 Brainmarks (Simplified)

31 Comments

  1. I was tricked. The image made me think this was a Ookami Kodomo no Ame to Yuki post!

  2. Jason "moofang"

    Haha! I want to write on that show. It was great.

  3. It really was great. It hit all the right places. They were so cute as kids.

  4. deyu260

    大中华崛起了?这动画不是日本的?

  5. tidak bisa mendapatkan pengaturan web yang tepat

  6. innn

    hi, what am I doing wrong that I get this:
    merge2ass.sh edukators_1.avi edukators_1.srt edukators_1_de.srt
    Processing..
    mplayer ist /usr/bin/mplayer
    Converting the 1st subtitle file (edukators_1.srt) to a time-based format...
    Done
    mv: der Aufruf von stat für »dumpsub.srt“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
    Converting the 2nd subtitle file (edukators_1_de.srt) to a time-based format...
    Done
    mv: der Aufruf von stat für »dumpsub.srt“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
    sed: kann edukators_1.srt-temp nicht lesen: Datei oder Verzeichnis nicht gefunden
    sed: kann edukators_1_de.srt-temp nicht lesen: Datei oder Verzeichnis nicht gefunden
    rm: das Entfernen von »edukators_1.srt-temp“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
    rm: das Entfernen von »edukators_1_de.srt-temp“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden

    • innn

      I am sorry that was in german. Basically it says “mv:calling for dumpsub.srt not possible: file or folder not found”
      sed: couldn’t read first.srt-temp: not found
      sed: couldn’t read second.srt-temp: not found
      rm:deleting *-temp not possible: not found

      I have to say that I get a *-bilingual.ass file though but it’s not showing anything in smplayer.

      • Jason "moofang"

        Looks like the mplayer commands are not running correctly. You can change the value of mplayer_err to something else: look for the following lines inside the script:

        #mplayer_err=/dev/stderr
        mplayer_err=/dev/null

        Uncomment the first and comment out the second, then run the script again and check for additional error messages.

  7. innn

    @Jason
    thank you for such quick answer. I get the same errors by editing that.
    Basically what happens is this:
    Converts the 1st to a time-based format…
    Done
    But when must it move the dumpsub.srt file (it’s in the code) it says not found.
    Converts the 2nd …Done. Moving not as it doesn’t exist.
    Then twice sed command complains not founding these files:${sub[1]}-temp and ${sub[2]}-temp
    followed by rm complaint that cannot remove them as they don’t exist.

    If it helps somewhat I run it on Ubuntu 13.10 x64

    • Jason "moofang"

      Hmmm, what happens is that the mplayer commands are supposed to produce the dumpsub.srt files that the mv command then renames. The mv command complaining means dumpsub.srt was not produced, meaning something went wrong with the mplayer commands. Maybe /dev/stderr isn’t a visible stderr on ubuntu. Try running the mplayer command directly:

      mplayer -dumpsrtsub -noautosub -really-quiet -frames 0 -sub sub1.srt yourmoviefile.format

      And see if you get any useful info? This command should produce a dumpsub.srt in the current folder.

      • innn

        I’ve tried it:
        mplayer -dumpsrtsub -noautosub -really-quiet -frames 0 -sub edukators_1.srt edukators_1.avi
        and I got only this:
        mplayer: could not connect to socket
        mplayer: No such file or directory
        Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory

        No dumpsub.srt file there.

        • Jason "moofang"

          Hmmm, it looks like it is trying to use VDPAU but VDPAU isn’t installed on your system. Do you normally play videos with mplayer and do they normally work?

          Try telling it to use another backend:

          mplayer -vo xv -dumpsrtsub -noautosub -really-quiet -frames 0 -sub edukators_1.srt edukators_1.avi

          See if that makes a difference? You can also get a list of available backends with

          mplayer -vo help

          In case xv has any issues as well.

          Fixed your comment code blocks btw.

          • innn

            Ok I tried with -xv still no outcome. I only get htis now:

            mplayer: could not connect to socket
            mplayer: No such file or directory

  8. innn

    wait a minute I got it , I disabled LIRC in .mplayer/config
    with this line : nolirc=yes
    run the command and voila there was no error and the dumpsub.srt sitting inside the directory.
    I’ve just run again merge2ass.sh and the *.ass file is there and working.
    Sorry to have bothered all this time and thank you once again . Still in shock because of that lirc support mplayer wouldn’t dump the sub file. Nasty thing.
    Best regards.

  9. deon

    Hello:

    I’m trying FreeBSD on VMware virtual machine, on a HP PC model with Intel architecture 64bist. Install Mplayer and I can not install the codecs, someone help?.

    Note:
    SVN stops and does not work.
    Thank you.

  10. Kerim

    Use KMPlayer instead of combining two subtitle. It can show up to three subtitles simultaneously. My settings can be recognized two subtitles automatically. I only click the video file.

  11. Goncalo

    Please how can I get the same in Windows?

  12. Marc

    Peope who are showing both subtitles at the bottom, do not forget to pass -ass option to mplayer!! :)

  13. Marc

    Thanks a lot.

    Here it is a script to run it with just:

    mplayer2 video sub1 sub2 [margin] [extra-mplayer-params]

    https://gist.github.com/waiting-for-dev/017d31eee21c08641687

  14. I tried this some time ago and it was not useful for some players (ASS format is not widely accepted yet).
    For that reason I created and released a tool to merge and translates SRT subtitles: DualSub (http://dualsub.sourceforge.net/) . This tool works with SRT subtitles for input and output. It has many options for customization. In addition you can use it to translate subtitles to any language.
    Enjoy!

  15. Use KMPlayer instead of combining two subtitle. It can show up to three subtitles simultaneously.

  16. On other website for dual subtitles : http://www.dualsubtitles.com/ The advantage for this website is : compatibility with Kodi (XMBC) and automatic detection/conversion of the files encoding to UTF-8.

  17. Great tip, was initally using greanfish subtitle player but it shows on a separate window. Guess this one does the trick.

  18. Thanks for that tip Jason.
    It worked for me too

  19. Great tip, was initally using greanfish subtitle player but it shows on a separate window. Guess this one does the trick.

  20. lol in image she looks like Ookami Kodomo :D

  21. lol in image she looks like Ookami Kodomo :D

  22. Peope who are showing both subtitles at the bottom, do not forget to pass -ass option to mplayer!! :)

Leave a Reply

Powered by WordPress & Theme by Anders Norén