Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#7252 - SubRip (srt) subtitle support in MPEG Player. (Edit: +overlay timebar)

Attached to Project: Rockbox
Opened by Antoine Cellerier (dionoea) - Saturday, 02 June 2007, 16:18 GMT+2
Last edited by Antoine Cellerier (dionoea) - Sunday, 14 October 2007, 22:49 GMT+2
Task Type Patches
Category Video
Status New
Assigned To No-one
Player Type All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Private No

Details

This patch adds SubRip subtitle support to MPEG Player.
http://wiki.multimedia.cx/index.php?title=SubRip

Files need to have the same name as the video file with a ".srt" extension.

I know that the OSD rendering is not implement in a way that linuxstb and jhMikeS would like but I still wanted to post the patch here in case anyone felt like adapting it. (Current OSD only renders on top of the video area, it can be adapted to add other OSD channels ... like display a seek bar, volume control, playback state, etc.)

Enjoy,

Edit: I've also added a timebar display (when changing the volume)
   rockbox.mpegplayer.srt.patch (18 KiB)
 apps/plugins/mpegplayer/SOURCES      |    1 
 apps/plugins/mpegplayer/mpegplayer.c |   84 +++++++
 apps/plugins/mpegplayer/subtitles.c  |  386 +++++++++++++++++++++++++++++++++++
 apps/plugins/mpegplayer/subtitles.h  |   71 ++++++
 4 files changed, 541 insertions(+), 1 deletion(-)

This task depends upon

Comment by Anonymous Submitter - Saturday, 02 June 2007, 22:30 GMT+2
I miss fast forward and rewind more than every other feature like sub titles...but it sounds nice.
Comment by Pablo (pencha) - Saturday, 21 July 2007, 00:34 GMT+2
I just posted a request for this!!
then I discovered the Patches section and found this!
I´ll try it as soon as I discover how to install it
Comment by Andrea Minini Saldini (gorman) - Thursday, 23 August 2007, 16:55 GMT+2
Is this available in any precompiled build? Does it work with recent versions of the code?
Comment by Martin H*** (webtaz) - Friday, 21 September 2007, 18:35 GMT+2
Has to be synced, i think.
Comment by Antoine Cellerier (dionoea) - Sunday, 30 September 2007, 18:15 GMT+2
Updated patch to make it apply with latest SVN (r14918).
   rockbox.mpegplayer.srt.patch (17.5 KiB)
 SOURCES      |    1 
 mpegplayer.c |   83 ++++++++++++
 subtitles.c  |  386 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 subtitles.h  |   71 ++++++++++
 4 files changed, 540 insertions(+), 1 deletion(-)

Comment by benoit (snk4ever) - Tuesday, 09 October 2007, 16:37 GMT+2
Can it be applied together with the new mpegplayer http://www.rockbox.org/tracker/task/7487 ?
It fails for me (applying the 7487 before this patch).
Comment by Antoine Cellerier (dionoea) - Thursday, 11 October 2007, 14:39 GMT+2
I can't tell if it will ... depends if those two patches change the same lines of code or not. (+ due to recent mpegplayer changes, the patch might need a re-sync. I'll probably update it this week end)
Comment by benoit (snk4ever) - Thursday, 11 October 2007, 14:42 GMT+2
ok, I'll keep looking at your updates and try again !
Comment by Antoine Cellerier (dionoea) - Sunday, 14 October 2007, 17:15 GMT+2
Updated to work with revision 15105.
   rockbox.mpegplayer.srt.patch (17.6 KiB)
 SOURCES      |    1 
 mpegplayer.c |   80 ++++++++++++
 subtitles.c  |  386 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 subtitles.h  |   71 ++++++++++
 4 files changed, 537 insertions(+), 1 deletion(-)

Comment by Antoine Cellerier (dionoea) - Sunday, 14 October 2007, 19:46 GMT+2
Added a time bar display (enabled for 3 seconds when any volume related button is pressed ... I didn't want to add another button).
   rockbox.mpegplayer.srt.patch (22.2 KiB)
 SOURCES      |    1 
 mpegplayer.c |   94 +++++++++++
 subtitles.c  |  476 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 subtitles.h  |   82 ++++++++++
 4 files changed, 652 insertions(+), 1 deletion(-)

Comment by Antoine Cellerier (dionoea) - Sunday, 14 October 2007, 22:48 GMT+2
Fix date function used. (Fixes subs when starting the video after seeking)
   rockbox.mpegplayer.srt.patch (22.3 KiB)
 SOURCES      |    1 
 mpegplayer.c |   94 +++++++++++
 subtitles.c  |  479 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 subtitles.h  |   82 ++++++++++
 4 files changed, 655 insertions(+), 1 deletion(-)

Comment by benoit (snk4ever) - Monday, 15 October 2007, 13:42 GMT+2
I tried to apply it, it seems to successfuly patch but doesn't compile.
I patch from the /path_to_source/apps/plugins/mpegplayer directory and when compiling I get this error :

subtitles.c: In function `uint8_buffer_putsxyofs':
subtitles.c:320: error: too few arguments to function
subtitles.c:328: error: too few arguments to function
make[3]: *** [/home/user/rockbox15TEC/testBuid/apps/plugins/mpegplayer/subtitles.o] Error 1
make[2]: *** [mpegplayer] Error 2
make[1]: *** [rocks] Error 2
make: *** [build] Error 2
Comment by Antoine Cellerier (dionoea) - Monday, 15 October 2007, 14:14 GMT+2
Was that applied on a clean svn checkout? (Are you using something like the multifont patch? I've seen reports on the unsupported builds forum that my patch doesn't work with it and your error seems to be on font related functions)
Comment by benoit (snk4ever) - Monday, 15 October 2007, 14:29 GMT+2
I'm trying on a clean SVN right now
Comment by benoit (snk4ever) - Monday, 15 October 2007, 14:43 GMT+2
OK, this time it compiles, but the simulator "segmentation-faults" when I launch a video, maybe it is usual on the simulator.
I'll try to combine it with other patches, excluding the multifont.
Comment by Antoine Cellerier (dionoea) - Monday, 15 October 2007, 15:01 GMT+2
It worked fine on the iPod Video simulator yesterday (well ... I had segfaults some of the time when changing the start point, not sure if they're subs related though)

Edit: you could try runing the sim in gdb to see where it segfaults (and post a backtrace here ... or fix it yourself :) )
Comment by benoit (snk4ever) - Monday, 15 October 2007, 17:08 GMT+2
What device are you using for your tests ?
I just tried on my Gigabeat F40 for real and it displayed the 1st sentence of my .srt file. Then at the time of displaying the 2nd, the device froze totally.
I can give you the mini-clip and srt file, I did the srt myself just for testing, it's some crap text :
http://snk5ever.free.fr/taek1.mpg
http://snk5ever.free.fr/taek1.srt
Comment by benoit (snk4ever) - Monday, 15 October 2007, 17:10 GMT+2
I don't knwo if this has an importance but the file was made with a unix carriage return software.
Comment by Antoine Cellerier (dionoea) - Monday, 15 October 2007, 17:19 GMT+2
The subs file looks valid. I'll give it a try when I get back home (the only issue might be a segfault when the last sub line is read ... since I never really tested it all the way to the end of the movie).
Comment by Antoine Cellerier (dionoea) - Monday, 15 October 2007, 22:12 GMT+2
This patch add lots of error checking in the subs parsing function (which fixes all the segfaults I was able to come up with while editing the subtitles file).
It also restricts overlay rendering to normal video playback (== it's disabled for video thumbnails when setting the start time)

I guess that the next step(s) would be to:
* Make it possible to configure a delay (in case subs and video/audio aren't exactly synced)
* Make it possible to choose the subtitle's position on the video (ie: at the bottom of the screen instead of at the top ...)
* ...

Edit: Updated patch to make sure that the last line was always displayed. (Nice test video btw :) )
   rockbox.mpegplayer.srt.patch (23.1 KiB)
 SOURCES      |    1 
 mpegplayer.c |   96 +++++++++++
 subtitles.c  |  503 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 subtitles.h  |   83 +++++++++
 4 files changed, 682 insertions(+), 1 deletion(-)

Comment by Antoine Cellerier (dionoea) - Monday, 15 October 2007, 23:23 GMT+2
About the multifont patch, if you're applying it with this patch you'll need to add a 3rd argument of rb->get_lcdgetcurfont() (or maybe just 0) to the two functions which trigger a compile error (font_get_bits and font_get_width).
Comment by Antoine Cellerier (dionoea) - Tuesday, 30 October 2007, 17:59 GMT+2
Benoit, have you been able to test the patch again? (and get it to work correctly)
Comment by Phil Light (phillight) - Saturday, 15 March 2008, 22:14 GMT+2
Synced to current SVN.

Currently when seeking in a file, you will see all subtitles up to that point in the video quickly flash by. This should be very simple to fix.
   srt_20080315.patch (19.7 KiB)
 apps/plugins/mpegplayer/stream_mgr.c    |    4 
 apps/plugins/mpegplayer/mpegplayer.c    |    2 
 apps/plugins/mpegplayer/stream_mgr.h    |    2 
 apps/plugins/mpegplayer/stream_thread.h |    4 
 apps/plugins/mpegplayer/SOURCES         |    1 
 apps/plugins/mpegplayer/subtitles.c     |  386 ++++++++++++++++++++++++++++++++
 apps/plugins/mpegplayer/subtitles.h     |   71 +++++
 apps/plugins/mpegplayer/video_thread.c  |   91 +++++++
 8 files changed, 555 insertions(+), 6 deletions(-)

Comment by Phil Light (phillight) - Saturday, 15 March 2008, 22:42 GMT+2
Oops. Now based on the patch from 15th Oct, with timebar removed. Works correctly when seeking as well.
   srt_20080315b.patch (21.5 KiB)
 apps/plugins/mpegplayer/stream_mgr.c    |    4 
 apps/plugins/mpegplayer/mpegplayer.c    |    2 
 apps/plugins/mpegplayer/stream_mgr.h    |    2 
 apps/plugins/mpegplayer/stream_thread.h |    4 
 apps/plugins/mpegplayer/SOURCES         |    1 
 apps/plugins/mpegplayer/subtitles.c     |  454 ++++++++++++++++++++++++++++++++
 apps/plugins/mpegplayer/subtitles.h     |   83 +++++
 apps/plugins/mpegplayer/video_thread.c  |   85 +++++
 8 files changed, 629 insertions(+), 6 deletions(-)

Comment by Marcoen Hirschberg (marcoen) - Saturday, 28 June 2008, 21:56 GMT+2
Just tried it. Works pretty well, although I would prefer the text on the bottom of the screen and lines longer than the screen width are broken off. Maybe I should work on it :)

Loading...