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)

33 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!! :)

  23. Battery Powered Coffee Makers Lets You Enjoy Coffee Made Your way, Anywhere
    When you are far from your house, discovering an excellent cup of coffee can be tough.
    Sure, there are gasoline stations, rest stops and takeaway food areas that offer coffee, however there is nothing to notify you how excellent it’s going to taste.
    The coffee may be an inexpensive brand with bad taste.
    Typically there is a minimal choice of sizes.
    You might not have the ability to consume all the coffee in a big cup prior to it gets cold, or the small size cup does not hold as much coffee as you desire.
    With contemporary innovation coffee machines are now portable.
    To fit todays on the move way of lives, when you are shopping, taking the kids to an activity, or a truck driver that enjoys coffee, you can brew your coffee made your way while driving.
    Anytime you desire a pot of coffee, just plug one of the 12-Volt coffee machines into the cigarette lighter.
    Some 12-Volt coffee makers feature mounting brackets for your automobile.
    The first cup of your coffee made your way begins the day out right.
    It helps perk you up and gets you going.

    Unless you are in a rural area, discovering an eating place with great food is simple.

    When you are in a rural area far from large cites, discovering a fantastic cup of coffee can be tough .
    With a 12-Volt coffee maker installed in your automobile, you can brew your coffee your way, no matter where you are at.
    Having a thermos travel mug will keep the newly brewed coffee hot.
    To keep your coffee hot, try a 12-Volt heated travel mug that plugs into the cigarette lighter.
    There is absolutely nothing that tastes any better than newly brewed coffee made your way.
    Fresh brewed coffee made your way will finish a meal, or you can just take pleasure in the taste of fresh brewed coffee made exactly how you like it.
    Due to the fact that the 12-Volt technology of portable coffee machines, you can make coffee the way you like it.
    You do not have to put up with bad tasting coffee.
    When traveling you can enjoy coffee at the best temperature and made just the way you like it.
    A battery-operated coffee machine can keep you in coffee made how you like it.
    On days I am taking the children to activity’s or simply having a day out with the kids, I like having a battery-powered coffee machine with me.
    I do not need to try and find a location with great coffee and wait with the children for service.
    It’s a lot less expensive too.
    Having coffee exactly how I like it, at my fingertips when driving, is a lifesaver.
    A popular 12 Volt cars and truck pot is made by RoadPro.
    Simply plug it into any 12-volt lighter/power socket, and you have hot water to make hot chocolate, instant soups, noodles and more.
    It has an automated shut-off when the liquid pitcher is empty, or input voltage is to high, making it safe to use anywhere.

    Check out their 12-Volt Car Espresso Coffee machine.
    You can delight in a fresh espresso in the cars and trucks while driving.
    With 12-Volt coffee makers, you can enjoy your coffee made how you like it, no matter where you are at.

Leave a Reply

Powered by WordPress & Theme by Anders Norén