gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

About external .srt subtitles in omxplayer

Sun Oct 14, 2012 2:48 pm

Hello everybody. Has anyone tried to compile the omxplayer branch from https://github.com/torarin/omxplayer ? This fork from torarin is supposed to support external .srt subtitles. Has anyone installed it and tried it out?

I know there is XBMC if subtitles are absolutely necessary, but it is a little overkill and to be honest, I have had problems with my keyboard+mouse (both of them vanishing after a few seconds) in all the major xbmc versions available. I know it's a problem quite a few people have mentioned, but I don't have a powered hub to try out right now, plus I'm a little skeptical because other than xbmc, both mouse and keyboard work perfectly fine in raspbian but vanish when I start xbmc. Is it possible it could be a permissions issue?

Thank you very much in advance!

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 14, 2012 5:52 pm

xbmc subtitles could not sync last I checked

usb stuff:
http://elinux.org/Rpi_USB_check-list
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 14, 2012 7:52 pm

Hi gilgames, I just slapped together a deb package of my external subtitles branch. It seemed to work OK when I tried it, but let me know if you have any problems.

https://github.com/torarin/omxplayer/downloads

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 14, 2012 10:53 pm

Thank you very much for posting and acting so quickly! I'm really impressed by the live Raspberry Pi community :)
elatllat wrote:xbmc subtitles could not sync last I checked

usb stuff:
http://elinux.org/Rpi_USB_check-list
I didn't have a problem with .srt subtitles in xbmc (well I never watched more than ~10 minutes while testing tbh, but still that would probably be enough to notice any problems). My problem with XBMC is that keyboard+mouse stop working after it has started. Granted, I haven't tried a different keyboard+mouse combo (which I intend to asap), but still, this combo works great in raspbian so it's a shame.
henle wrote:Hi gilgames, I just slapped together a deb package of my external subtitles branch. It seemed to work OK when I tried it, but let me know if you have any problems.

https://github.com/torarin/omxplayer/downloads
Thank you for uploading the deb so fast! I installed it in my current test raspbian installation, and while I was excited to try it out, I haven't been able to make it work. It installed fine, I saw the --subtitles flag available, but .srt subtitles don't show. I invoke the player somewhat like this: omxplayer -o hdmi --subtitles /media/usb/clip.srt /media/usb/clip.mkv . It loads up, plays back the file just fine but without any subtitles. Do I miss something? :-/

P.S.: Are you the actual maker of this patched omxplayer fork? Just curious :) In any case, thank you very much for your help, looking forward!

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 14, 2012 11:30 pm

gilgames wrote: Thank you for uploading the deb so fast! I installed it in my current test raspbian installation, and while I was excited to try it out, I haven't been able to make it work. It installed fine, I saw the --subtitles flag available, but .srt subtitles don't show. I invoke the player somewhat like this: omxplayer -o hdmi --subtitles /media/usb/clip.srt /media/usb/clip.mkv . It loads up, plays back the file just fine but without any subtitles. Do I miss something? :-/

P.S.: Are you the actual maker of this patched omxplayer fork? Just curious :) In any case, thank you very much for your help, looking forward!
I did indeed make this, I'm glad someone else may have use for it. :)

It seems like you are invoking omxplayer correctly. Could you send me omxplayer.log and the srt file so I can have a look?

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 10:09 am

I'm also glad that someone was willing to try and add this functionality! :)

Here is the logfile and one of the .srt files used.
omxplayer_log_sub.tar.gz
(23.82 KiB) Downloaded 271 times
I also tried the subtitles in their native encoding (iso-8859-7 = Greek) as well as UTF-8 which is necessary. Tell me about any way I can help :)

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 1:11 pm

gilgames wrote: Here is the logfile and one of the .srt files used.
omxplayer_log_sub.tar.gz
From the log it looks like GPU memory shortage, can you try the 128/128 split? I should probably add an error message for when this happens.

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 2:01 pm

henle wrote:
gilgames wrote: Here is the logfile and one of the .srt files used.
omxplayer_log_sub.tar.gz
From the log it looks like GPU memory shortage, can you try the 128/128 split? I should probably add an error message for when this happens.
Perfect! Trying the 50/50 split did it, it works perfectly! The only drawback is that the system really crawls to a halt with 128 MB RAM :-/ It's really astonishing what difference can 64 MB make! Raspi is nicely usable (always considering the specs) with 192 MB of Ram, but is suffering quite badly as a small system with 128, at least in my installation. Is it normal that CPU usage is mostly pinned at 100% with 128 MB of RAM, even when only a simple LXterminal is open?

It's still excellent news that omxplayer finally supports external subtitles! XBMC is too much for occasional video playback. I wonder if there is anything that can be done to avoid using 50/50 split. Have you tried it on a clean installation of Raspbian with 192/64 split? Does it need 50/50 in that case too? I wonder if some services/background processes can be safely stopped before playback, freeing RAM, and restarted afterwards.

EDIT: Or maybe even something like this: http://www.raspberrypi.org/phpBB3/viewt ... 29&t=18263
Custom memory split! I will try that and let you know if you'd like :)

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 3:13 pm

I just tried 192/64, and it fails. What I could do, eventually, is to allocate a smaller buffer at the bottom of the screen, since subtitles usually have less than 3 lines. I don't run a desktop environment, so I haven't had any problems with 128/128.

It would be interesting to see if you can find a custom split that performs better. Subtitles require about 3.5 MB of GPU memory for 720p and 8 MB for 1080p.

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 3:44 pm

henle wrote:I just tried 192/64, and it fails. What I could do, eventually, is to allocate a smaller buffer at the bottom of the screen, since subtitles usually have less than 3 lines. I don't run a desktop environment, so I haven't had any problems with 128/128.

It would be interesting to see if you can find a custom split that performs better. Subtitles require about 3.5 MB of GPU memory for 720p and 8 MB for 1080p.
It definetely works! I just tried it with a very modest increase in RAM, at 160/96 split and subtitles work perfectly. Plus the system responds much better than before. I will try a different split in about an hour and will let you know, normally a 180/76 should be possible, but then we might run into issues with 1080p playback. Worst case scenario, 160/96 works fine in any resolution, so we have gained at least 32 MB of RAM! Will notify you very soon!

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 5:46 pm

I'm back with some feedback.

So, best problem-free setting is with 168/88 split. That way, the system is far more responsive than 128/128 even with LXde running, and subtitles show even for 1080p movies. As far as I'm concerned, that is the best split we can achieve at the moment. I've also tried 176/80 but subtitles didn't show up for 1080p (they showed up fine for 720p though). All in all, we can gain a whooping 40 MB of RAM that way, which is very good I think!

A couple of questions: Would it be difficult to implement other encodings apart from UTF-8? That would make many .srt files compatible (for example, iso-8859-7 and windows-1253 showed up as garbage) without re-saving the file in a different encoding. Just a suggestion :)

Also, after I quit omxplayer, the screen is covered with a black artifact-like surface. I can clear the screen up if I move the cursor around, probably a framebuffer issue, right? Is there anyway it can automatically clear up after omxplayer has quit?

Finally could you change --subtitles flag that way so, if called in a certain way (eg --subtitles same) it will assume that .srt filename will be the same as the video file? That way, this .desktop shortcut

Code: Select all

[Desktop Entry]
Type=Application
Name=OMXPlayer
Categories=AudioVideo;Player;
Exec=lxterminal --command "omxplayer -o hdmi --subtitles same %f"
Terminal=false
Icon=/usr/share/icons/nuoveXT2/96x96/categories/applications-multimedia.png
would work fine for double-click playing a video file AND its correspondant subtitle file.

Let me know what you think in any case! Thank you very-very much for giving us subtitles in omxplayer!

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5331
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 6:11 pm

henle wrote:I just tried 192/64, and it fails. What I could do, eventually, is to allocate a smaller buffer at the bottom of the screen, since subtitles usually have less than 3 lines. I don't run a desktop environment, so I haven't had any problems with 128/128.

It would be interesting to see if you can find a custom split that performs better. Subtitles require about 3.5 MB of GPU memory for 720p and 8 MB for 1080p.
I have a feeling EGL surfaces are triple buffered, so those numbers are 10.5MB and 24MB...

Code: Select all

V3D_DOUBLE_BUFFER=1 omxplayer
Will only double buffer.

I think creating a surface just high enough for a couple of lines of text would be a good idea.

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 6:23 pm

dom wrote:
henle wrote:I just tried 192/64, and it fails. What I could do, eventually, is to allocate a smaller buffer at the bottom of the screen, since subtitles usually have less than 3 lines. I don't run a desktop environment, so I haven't had any problems with 128/128.

It would be interesting to see if you can find a custom split that performs better. Subtitles require about 3.5 MB of GPU memory for 720p and 8 MB for 1080p.
I have a feeling EGL surfaces are triple buffered, so those numbers are 10.5MB and 24MB...

Code: Select all

V3D_DOUBLE_BUFFER=1 omxplayer
Will only double buffer.

I think creating a surface just high enough for a couple of lines of text would be a good idea.
Hmm, that would explain why in eg. 192/64 split subtitles don't show up at all, in 176/80 they work for 720p but NOT for 1080p, while 168/88 works for both. Still, until a better solution is implemented, this "exotic" split is better than 50/50. :)

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 6:57 pm

gilgames wrote: A couple of questions: Would it be difficult to implement other encodings apart from UTF-8? That would make many .srt files compatible (for example, iso-8859-7 and windows-1253 showed up as garbage) without re-saving the file in a different encoding. Just a suggestion :)
I'll keep it in mind, but to be honest, I don't think I would find that very inspiring work. I feel like it's easier to just convert stuff to UTF-8.
gilgames wrote: Also, after I quit omxplayer, the screen is covered with a black artifact-like surface. I can clear the screen up if I move the cursor around, probably a framebuffer issue, right? Is there anyway it can automatically clear up after omxplayer has quit?
I'm not sure about this, sorry. I know there were some changes to the startup script recently to get the terminal back on screen, you could look into that: https://github.com/huceke/omxplayer/iss ... nt-9408888
gilgames wrote: Finally could you change --subtitles flag that way so, if called in a certain way (eg --subtitles same) it will assume that .srt filename will be the same as the video file?
Yes, good idea, or it could just do this by default. Thank you for the feedback!

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Mon Oct 15, 2012 7:05 pm

dom wrote: I have a feeling EGL surfaces are triple buffered, so those numbers are 10.5MB and 24MB...

Code: Select all

V3D_DOUBLE_BUFFER=1 omxplayer
Will only double buffer.
Thanks, I didn't know about the triple buffering. I should have taken double buffering into account, though.

jose1711_
Posts: 58
Joined: Sat Jul 21, 2012 10:03 am

Re: About external .srt subtitles in omxplayer

Tue Oct 16, 2012 5:49 pm

hope it's not too offtopic but i noticed that openelec's xbmc is able to play videos more smoothly than omxplayer. anyone's got an explanation for that? what optimization level was used when making the packaged omxplayer? thanks, jose

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5331
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: About external .srt subtitles in omxplayer

Tue Oct 16, 2012 6:16 pm

jose1711_ wrote:hope it's not too offtopic but i noticed that openelec's xbmc is able to play videos more smoothly than omxplayer. anyone's got an explanation for that? what optimization level was used when making the packaged omxplayer? thanks, jose
No, omxplayer can play harder videos than xbmc.
Are you using "-r" command line flag for omxplayer?

jose1711_
Posts: 58
Joined: Sat Jul 21, 2012 10:03 am

Re: About external .srt subtitles in omxplayer

Wed Oct 17, 2012 11:16 am

sorry, did test with invalid file. anyway.. i experienced garbled sound (analog) with omxplayer and high cpu load - never happened when using xbmc.

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Fri Oct 26, 2012 11:04 pm

Here is a new version that uses a smaller surface (and consequently works fine with 64 MB of GPU memory) and automatically loads subtitle files with the same name as the video:

https://github.com/downloads/torarin/om ... _armhf.deb

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 3:43 pm

Thank you very much for implementing this addition! I had resorted to quick-coding a little launcher for the player in C to do this automatically (while also encoding non-UTF-8 subs to UTF-8 on the fly), but having it implemented natively (plus with lower memory needed) is much better! :)

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 5:46 pm

gilgames wrote:Thank you very much for implementing this addition! I had resorted to quick-coding a little launcher for the player in C to do this automatically (while also encoding non-UTF-8 subs to UTF-8 on the fly), but having it implemented natively (plus with lower memory needed) is much better! :)
Perhaps your encoding conversion code could be integrated?

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 8:33 pm

I would be glad to but since it was created mostly for personal use, the code currently just assumes a greek encoding (either windows1253 or iso88597) as the subtitles encoding, if it is not already utf8, and treats it accordingly. It was meant to be a quick and dirty method, so it doesn't try hard to identify what kind of an ascii encoding the file is, since I'm only using Greek subtitles it just takes greek encoding for granted. I could try and modify it if you would be interested. It currently relies on a combination of "file" and "iconv" system calls though, (quick and dirty :P), so changing this to a more smart approach would require mostly heuristics and try-to-guess approaches, without a guaranteed result. Let me know what you think though :)

jose1711_
Posts: 58
Joined: Sat Jul 21, 2012 10:03 am

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 8:39 pm

please also check out enca. it should help with that guesswork

henle
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 8:53 pm

gilgames wrote:I would be glad to but since it was created mostly for personal use, the code currently just assumes a greek encoding (either windows1253 or iso88597) as the subtitles encoding, if it is not already utf8, and treats it accordingly. It was meant to be a quick and dirty method, so it doesn't try hard to identify what kind of an ascii encoding the file is, since I'm only using Greek subtitles it just takes greek encoding for granted. I could try and modify it if you would be interested. It currently relies on a combination of "file" and "iconv" system calls though, (quick and dirty :P), so changing this to a more smart approach would require mostly heuristics and try-to-guess approaches, without a guaranteed result. Let me know what you think though :)
Would be great if you could make it work!

gilgames
Posts: 26
Joined: Sun Oct 14, 2012 2:38 pm

Re: About external .srt subtitles in omxplayer

Sun Oct 28, 2012 8:53 pm

jose1711_ wrote:please also check out enca. it should help with that guesswork
Thanks for the heads up! I had already tried enca and wasn't satisfied. Yes it's easier to use, but it doesn't support quite a few language encodings (greek being one of them), so it would be equally troublesome.

One other thought (in order to avoid complicated heuristics that could also slow down the player's initial startup a little bit as well) would be to check the current system's locale and *assume* that -hopefully- this is the subtitle encoding preferred. It's not perfect (since it wouldn't be correct for eg a french user using Raspbian in English locale) but it would be fast. It could be a combination of many things. Keep the proposals coming! :)

Return to “Media centres”