Mplayer With Arabic Subtitles FIX

Well, this is my first contribution to “HackRoot” The CAT Distro - Based on Fedora.
There is a very common problem regarding arabic subtitles in Linux video players, I’ve googled and found some old patches with ugly ideas (it was best at their time, because fribidi didn’t support arabic shaping), but now after fribidi2 (beta) which has a almost-finished arabic shaping support I thought I could hack Mplayer and fribidi2 and get things to work together for the complete Linux beginner.Mplayer With Arabic Subtitles

I’ve compiled fribidi2 and hacked it’s configuration alittle and prepared a RPM as there is no RPMS for fribidi2 (because it’s still beta).

I Also hacked the Mplayer to work with my new fribidi2 RPM and to use the arabic shaping capabilities, and here is how you can get arabic subtitles working in Linux:Mplayer With Arabic Subtitles

- You’ll have to remove mplayer if you already have it installed

rpm -e mplayer mplayer-gui

- Download Mplayer RPMs and Fribidi rpms into a new empty directory, aka. /opt/mplayer
- Install all the packages, use force if neccessary (libfribidi may have some conflicts, don’t worry about using force with it)
- Make sure that you have fonts-arabic already installed, if not, Install them via yum.
- Now you need to convert the subtitles for your movie into UTF-8 encoding before playing, let’s see how can you do this

#assume the .sub or srt file is named movie.sub

$ mv movie.sub movie.sub.old

$ iconv -f windows-1256 -t utf8 movie.sub.old > movie.sub

# rm movie.sub.old

OR:

you can download convert_sub script and chmod +x convert_sub.sh and just pass the subtitles file to it and it’ll do the conversion.

then you are ready to play :)

Basically you’ll need to install mplayer, mplayer-gui and fribidi0 RPMS and you’ll have everything setuped. you can download the tree rpms in an empty directory and install them as follows *Please make sure that you have Livna Repo. setuped*

# cd /opt/empty_directory
# yum localinstall *

while /opt/empty_directory is an example for an empty directory you copied the RPMS into.

please don’t hesitate to tell me any comments or problems..

Download RPMS:

mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mplayer-gui-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mplayer-doc-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
mencoder-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm

fribidi0-0.19-1.AhmedSoliman.com.i386.rpm

libfribidi0-0.19-1.AhmedSoliman.com.i386.rpm
libfribidi0-devel-0.19-1.AhmedSoliman.com.i386.rpm

Source RPMS:

fribidi-0.19-1.AhmedSoliman.com.src.rpm
mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.src.rpm

NOTE1: Those packages are based on rpm.livna.org packages and are completely compliant with Fedora Core 6

NOTE2: If you chose to install fribidi0-0.19-1.AhmedSoliman.com.i386.rpm then you shouldn’t install libfribidi0 and libfribidi0-devel as they are self-contained in fribidi0, this package was made to make the installation thing easier.

NOTE3: You may face conflicts with original fribidi package while installation, you can rpm -ivh –force fribidi0* before installing mplayer, then do the normal installation and remove fribidi0 from directory.

NOTE4: You may face a problem that my packages aren’t signed during installation using yum localinstall, edit /etc/yum.conf and change gpgcheck=0

39 Comments »

  1. Abd El-Rahman Hegazy said,

    May 24, 2007 @ 8:32 am

    very very very good ya abo7emeeeeed wallahi
    ana mosh 7a3raf 2a3ala2 delwa2ty le2ni lessa magarbitich da
    isa 7ab2a a2ol ra2yi lamma agarabo elnaharda isa
    bas begad enta fe3lan u are the best

  2. Mohammed Azmy said,

    May 24, 2007 @ 1:46 pm

    Again , a very fine work from a computer wizard :) . This fribidi library gave me a very hard time when I was trying to apply the old patches .

    NOTE: You can use Totem with gstreamer to play arabic subtitles files with no need to change subtitle file encoding .

    Keep up the good work ya basha ,

    Salam

  3. Mohammed Azmy said,

    May 24, 2007 @ 1:49 pm

    Another commend if you don’t mind , Where is the source code :P , a good supporter to the open source community as you shouldn’t forget something like that , or you don’t want us to learn ?? :D

    Salam

  4. Ahmed S. Farghal said,

    May 24, 2007 @ 1:51 pm

    Yeah, I really forgot that… I’ll post them now

  5. Leo said,

    May 24, 2007 @ 2:08 pm

    Great job ya basha ,
    Bas feeh so2al….howa mesh el mafrood el new versions beta3et el MPLAYER yekono 7alo feeha el moshkela deh walla eh ?

    ThanQ

  6. Ahmed S. Farghal said,

    May 24, 2007 @ 2:31 pm

    well, feeh many reasons
    1- there is almost no arabic developer in the mplayer development team
    2- they are depending on fribidi2 which is still beta and is maintained by an Iranian Called Behdad Esfahbod, he is a professional in unicode and he is implementing the GNU unicode standards. I’m trying to give some help there to get this beta version to live.

  7. Leo said,

    May 24, 2007 @ 2:35 pm

    Mmm….howa lazem yekoon fe arabic developer 3ashan yezabat el 3araby feeh walla eh ??,,,walla homma mesh 3ayezeen yedefo arabic to it’s features aslan ?

  8. Ahmed S. Farghal said,

    May 24, 2007 @ 2:45 pm

    The Open Source community has a simple rule, if you need it? write it!
    And the arabic contributions are very a few, so If we really need arabic? we should push for its support.

  9. Neo said,

    May 24, 2007 @ 3:37 pm

    Great work really, you never stop impressing me :) masha2alla…begad I’m so happy you’re working in such stuff now. I’ll try it and let you know isA. Waiting for more my friend

  10. AbuShokry said,

    May 24, 2007 @ 8:27 pm

    Al slam 3lykom,

    first, I wanna thank you for your great effort , and i ask Allah to help you keep up the good work.

    second, you said that there will be some conflicts with the libfribidi and there is no harm in using force (you mean using –force option, right ?). well, I tried it and it didn’t work.
    here is what I exactly did ..

    [root@localhost Subtitles Fix]# rpm -iv –force libfribidi0-0.19-1.AhmedSoliman.com.i386.rpm
    error: Failed dependencies:
    fribidi0 conflicts with libfribidi0-0.19-1.AhmedSoliman.com.i386

    So ??!!

    Am using FC6.

    Thanks again.

  11. ayman said,

    May 24, 2007 @ 9:34 pm

    ya man ana men s3adte mesh 3aref 22ol eah we ana s3ead le 3det 2sbab
    1-2n el arabic subtitle kam mdaw7′ne men zman we 7awelt fe 100 7agah bas ma nfe3sh but now i think 2n 2na hnam mrta7
    2-2n el 3malha howa my friend ahmed soliman
    3- 2n dah hyb2a support gamed le el hackroot l2n i think 2n 27na keda hn7el ktear men el problems 2le 3nad el users

    we ana 2oltha 2bl keda . we all must be “Ahmed Soliman Like”

  12. Mo3taz said,

    May 24, 2007 @ 10:35 pm

    Well done ahmed , but i have a Q WHY mv & rm after :

    $ mv movie.sub movie.sub.old

    $ iconv -f windows-1256 -t utf8 > movie.sub

    # rm movie.sub

    is movie.sub is input file or the output file , another Q will that need more dependancies that normal mplayer ??

  13. ayman said,

    May 24, 2007 @ 10:59 pm

    i have Q ya ahmed . 2nta 2olt 2nha based 3la livna.org fa dah m3nah eah ?

  14. kamasheto said,

    May 24, 2007 @ 11:17 pm

    mo3taz I was thinking just the same;

    why did you remove the subtitle? but then i figured that that is just a comment in bash, no?

    anyway, I was wondering something else

    why did you rename the movie.sub to movie.sub.old then fix the encoding of movie.sub? why the renaming procedure the first place? should this be a cp instead? meaning that movie.sub.old was created just for backup sake?

    one other thing

    what is mplayer coded with? C? and how exactly does someone go around hacking into a programs specific code to fix something like that? I’m not by all means trying to be a hero (and take your route, though I’d love to =P) but at least that will give us a wider vision of where to start if we would like to take your lead and start contributing to the linux community.

    congratulations on your achievement =)

  15. Ahmed S. Farghal said,

    May 25, 2007 @ 3:18 am

    Well, it was a type mistake,
    you should rename the sub file into sub.old file then convert .old file from windows-1256 encoding (intellectual property encoding used by M$) into Unicode (standard encoding used by GNU and Almost Every OS Around).
    Then we remove the .sub.old one cuz we don’t need it anymore.

    Thanks you Shabab for your support.

    Abu Shukri : You’ll only need to install fribidi0-0.19-1.AhmedSoliman.com.i386.rpm it contains the other packages as well (Sorry not to mention this but if you noticed, this post was posted on 4:36AM! just before praying fajr! - I was very tired though.

    So, No Need to install libfribidi or its devel package as it’s contained in fribidi0 package, it was made to make the installation process easy.

    Kamasheto: Mplayer is written in GNU C, and playing with code is not easy, it required great experience and lots of problem solving techniques.

    If you really want to start hacking linux, you’ll have to start learning C and I can guide you all if you want to contribute to the Linux community.

    Ayman: Mplayer is based on SVN snapshot by Livna, so it’s based on the source packaged by Livna, I just played with it. but fribidi packaging was completely mine.

  16. AbuShokry said,

    May 25, 2007 @ 7:42 am

    It works , Thank you very much.

    By the way, after i installed the mplayer package you provided, I wasn’t able to play RMVB files. So I downloaded this archive:

    http://www2.mplayerhq.hu/MPlayer/releases/codecs/rp9codecs-win32-20050115.tar.bz2

    Extracted it to the /usr/lib/codecs directory and it worked just fine.

    Am just mentioning that for any one who faced the same problem.

    Once again, thank you very much

  17. kamasheto said,

    May 25, 2007 @ 11:25 am

    Ahmeeeeed you’re losing me again! lol

    you should rename the sub file into sub.old file then convert .old file from windows-1256 encoding into Unicode. Then we remove the .sub.old one cuz we don’t need it anymore.

    I have movie.sub
    I rename to movie.sub.old (NOT copy)
    We convert .sub.old to unicode
    Delete .sub.old

    Now, we don’t have a subtitle file?? Plus, why rename it to .sub.old first? Why don’t we convert the encoding of the .sub file 3ala tool?

    We’ll talk about GNU C later on, its time will come, I’m sure =P

  18. Ahmed S. Farghal said,

    May 25, 2007 @ 1:09 pm

    kamasheto, the iconv utility cannot do the conversion on input file that’s the same output!, so look at the command:

    iconv -f windows-1256 -t utf8 movie.sub.old > movie.sub

    we are converting file .sub.old and redirecting the standard output into movie.sub (which is the new unicode output). Thus we don’t need the .sub.old anymore.

  19. Ahmed S. Farghal said,

    May 25, 2007 @ 1:10 pm

    Abo Shokry:
    Yeah, Codecs aren’t included by default, you can get codecs from Mplayer website directly and extract it as you did.

    Thanks for the note. I’m happy it worked for you :)

  20. kamasheto said,

    May 25, 2007 @ 1:33 pm

    AAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHH

    I didn’t notice you changed the iconv command in your main post, now I get it.

    Thanks for the explanation =)

  21. Ahmed S. Farghal said,

    May 25, 2007 @ 4:51 pm

    I’ve created a script called convert_sub you can download it and copy it into /usr/local/bin to use it directly against your subtitles files anywhere

  22. neo said,

    May 25, 2007 @ 11:19 pm

    IT WORKEDDDDDDDDDDD :D AT LAAAAAAST I CAN PLAY My ARABIC SUBTITLES ;) really Ahmed you’re a genius masha2alla. And you inspire me always :)..keep up the exceptional work :D

  23. mahmoud El-Gazzaz said,

    May 26, 2007 @ 4:25 am

    ya solimaaaaaaaaaaaaaaaaaaaaaaaan ya gamed ( spider man 3 - by sub arabic in linux gameeeeeeeeeed)

  24. Dj.r4iDeN said,

    May 27, 2007 @ 12:02 am

    al slam 3lykom ana 3amlt add fe al forum bet3ak bas mestny al mowfa2a

    bas al forum fe 3eben ano phpbb al nas mesh met3awda 3leeh we al 3eeb al tany

    ano be al English we kol al user aly feh masryeen

    m3 3lena

    al we rad bet3ay mloosh ay lazma bas aho :D

    slam 3lykom

  25. AbuShokry said,

    June 1, 2007 @ 7:41 pm

    Al slam 3lykom.

    I’m facing a problem, I don’t know if it’s your hacked mplayer or something else.

    The problem is that when i try to play a real video file, The video and audio plays just fine, but i get an ugly error message at the beginning saying

    ERROR: Could not open required DirectShow codec drv4.so.6.0.

    The effect of this error appears when i try to seek through the movie. The Audio and Video goes totally out of sync.

    The output from the terminal showed that there is a problem loading some files.
    I checked to see if these files are in the right place (/usr/lib/codecs), and i found that they are.

    Here is the output


    MPlayer SVN-r22817 rpm.livna.org (C) 2000-2007 MPlayer Team
    CPU: Intel(R) Pentium(R) 4 CPU 1.80GHz (Family: 15, Model: 2, Stepping: 4)
    CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
    Compiled with runtime CPU detection.
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.

    Playing /mnt/hd2/pb/Prison Break Season 1/001/Prison Break - 101 - Pilot.rmvb.
    REAL file format detected.
    Stream description: Audio Stream
    Stream mimetype: audio/x-pn-realaudio
    Stream description: Video Stream
    Stream mimetype: video/x-pn-realvideo
    Stream mimetype: logical-fileinfo
    VIDEO: [RV40] 624×352 24bpp 30.000 fps 0.0 kbps ( 0.0 kbyte/s)
    Clip info:
    comment:
    ==========================================================================
    Opening video decoder: [realvid] RealVideo decoder
    Error: /usr/lib/codecs/drvc.so: cannot restore segment prot after reloc: Permiss
    ion denied
    Win32 LoadLibrary failed to load: drvc.so, /usr/lib/codecs/drvc.so, /usr/lib/win
    32/drvc.so, /usr/local/lib/win32/drvc.so
    Error loading dll
    ERROR: Could not open required DirectShow codec drvc.so.
    Read the RealVideo section of the DOCS!
    VDecoder init failed :(
    Opening video decoder: [realvid] RealVideo decoder
    Error: /usr/lib/codecs/drv4.so.6.0: cannot restore segment prot after reloc: Per
    mission denied
    Win32 LoadLibrary failed to load: drv4.so.6.0, /usr/lib/codecs/drv4.so.6.0, /usr /lib/win32/drv4.so.6.0, /usr/local/lib/win32/drv4.so.6.0
    Error loading dll
    ERROR: Could not open required DirectShow codec drv4.so.6.0.
    Read the RealVideo section of the DOCS!
    VDecoder init failed :(
    Opening video decoder: [realvid] RealVideo decoder
    Called unk__beginthreadex
    Selected video codec: [rv40win] vfm: realvid (Win32 RealPlayer 9 RV40 decoder)

  26. Ahmed S. Farghal said,

    June 2, 2007 @ 5:08 am

    well, First of all it’s not my hack as it’s not related at all.
    I feel that it’s a permissions problem, did you try loading this file as root? did you notice a change?

    but I really don’t know much about that, All I can say is that Real Media support in mplayer is still poor and quite buggy as you see now ;)

    Try playing with root and tell me if there is a difference…

  27. AbuShokry said,

    June 2, 2007 @ 9:39 am

    Yes, I’ve already tried that after I noticed the line

    cannot restore segment prot after reloc: Permission denied

    But it didn’t fix the problem.

    Anyway, thank you so much (^:

  28. Ahmed El Deraa said,

    June 5, 2007 @ 10:33 pm

    I need a favour from you
    I am very new to the Linux world i’ve installed Kubuntu and as i know it doesn’t support rpm packages unless using command aline and i’ve done that and installed that patch
    but the application did not open when trying to open it..
    could you provide a .deb package to install on kubuntu , please?

    another question is : as i understand i need to install fribidi2 (i got fribidi installed) but all what i can find for it on google is this page
    http://webcvs.freedesktop.org/fribidi/fribidi2/
    which is the CVS view of the source , i cannot find any installable packages anywhere , can you help me with that ?

    last and i am sorry for asking too much , everywhere in the linux world i see people talking about compiling their application by themselves, is there are commands to do this or what ?

    Thaaaaaaaaaaaaaanks

  29. Ahmed S. Farghal said,

    June 6, 2007 @ 3:03 pm

    well, those packages were designed for Fedora, about Kubuntu I may work on a package soon isA.

    Yeah, fribidi2 doesn’t have any RPMS available or DEP packages because it’s still beta, the only package available is my RPM here.

    you can ask those type of questions on our support forum http://www.cat-hackers.com

    Thanks ;)

  30. mo3az said,

    June 11, 2007 @ 5:11 pm

    really ya ahmed … walahy enta great man .. begad enta 7′orafa besm allah mash2 allah .. i just try it now .. bas fi problem so3′yera .. en ana 3amlt kol 7aga bas el mplayer not setuped on linux mish 3aref ezay … 3ashan fi rpms kitte 3aweza dependences ! zay
    [root@localhost mplayer]# rpm -ivh mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.i386.rpm
    error: Failed dependencies:
    libcaca.so.0 is needed by mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.i386
    libcucul.so.0 is needed by mplayer-1.0-0.72.20070325svn.AhmedSoliman.com.i386

    so plz help me

  31. mo3az said,

    June 11, 2007 @ 5:20 pm

    sorry de kaman kanet 7aslt lama 3malt #yum localinstall *
    –> Finished Dependency Resolution
    Error: libfribidi0 conflicts with fribidi0
    Error: libfribidi0-devel conflicts with fribidi0
    ??

  32. Ahmed S. Farghal said,

    June 12, 2007 @ 6:21 am

    Thanks mo3az,

    Please remove libfribidi0 and libfribidi0-devel from the directory before localinstall, then try again and all your problems should just go away :)

    Please see NOTE 2

  33. mo3az said,

    June 12, 2007 @ 12:20 pm

    ok .. ana download rpms again without libfribidi0 and libfribidi0-devel then save them in /opt/mplayer then 3amlt yum -y localinstall * when i was in the directory
    /opt/mplayer ….. then ro7t 3amlt

    #mv movie.sub movie.sub.old
    #iconv -f windows-1256 -t utf8 movie.sub.old > movie.sub
    # rm movie.sub.old

    ok .. there is arabic characters on the movie but not connected and havenot mean ?

    then fi another Question plz : i dont get use of :
    iconv -f windows-1256 -t utf8 movie.sub.old > movie.sub
    ?

    thax

    ?

  34. Ahmed S. Farghal said,

    June 12, 2007 @ 4:38 pm

    please remove ~/.mplayer directory and things will work just ok

    this command converts the subtitles encoding from windows-1256 arabic encoding to the standard unicode encoding.

    btw, you can use the script I made directly, just pass the subtitles filename and it’ll do the nasty work for you ;)

  35. ahmed said,

    June 25, 2007 @ 8:02 pm

    Ahmed Soilamn , Good work coz u r doing great
    but i wanna ask and i hope to find the help here
    did ur package work with Opensuse 10.2 ?
    i think no , but can help me out to got arabic subtitle working with Mplayer in SUSE 10.2

  36. Ahmed-Linux said,

    July 26, 2007 @ 11:18 pm

    What about Debian users …

    we want somthing in *.deb packages

    thanks alot :)

  37. Ahmed S. Farghal said,

    July 28, 2007 @ 11:12 pm

    sorry shabab,
    currently I’m not interested in SuSE or Debian!

  38. Mohamad elkhatib said,

    December 28, 2007 @ 2:42 am

    salam ya akhi ahmed

    i am not so talented in computer programing
    so i wish that you can simplify this procedure
    that everybody can understand it and applied it simply.

    i have another question, is this method work in windows XP or not ?
    i appreciate that u e-mail me, i really need this arabic subtitles.

    thank u in advance.

  39. Ahmed S. Farghal said,

    December 29, 2007 @ 1:49 pm

    It’s very easy though ;)

    No, mplayer is complied on Linux and not windows, you can download and compile it yourself for windows, I don’t support windows anyway :)

    you don’t have to be programmer to install this! just follow the installation steps and everything should run OK.

    I’m now preparing an upgrade for fedora 8 with pulseaudio patch.

RSS feed for comments on this post

Leave a Comment