Menu

Transcoding Subtitles

Help
2009-04-27
2015-12-11
  • jeremy rottman

    jeremy rottman - 2009-04-27

    I have been fighting with this for well over two days. I have read the faq on how to piggyback the subtitles into my transcoded video. But I am at a loss as what to do.

    Can anyone point me in the right direction on how to get this working?

     
  • dark

    dark - 2009-10-07

    I have the same problem, i cant do it working.  :( i follow " the how to piggyback  the subtitles" and is not working this is my config.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">
          <server>
            <ui enabled="yes">
              <accounts enabled="no" session-timeout="30">
                <account user="mediatomb" password="mediatomb"/>
              </accounts>
            </ui>
            <name>MediaTomb</name>
            <udn>uuid:871f4fdc-0b2d-4b64-9028-7dd1a7351523</udn>
            <home>/home/jorge/.mediatomb/</home>
            <webroot>/usr/share/mediatomb/web</webroot>
            <storage>
              <sqlite3 enabled="yes">
                <database-file>sqlite3.db</database-file>
              </sqlite3>
              <mysql enabled="no">
                <host>localhost</host>
                <username>mediatomb</username>
                <database>mediatomb</database>
              </mysql>
            </storage>
            <protocolInfo extend="no"/><!- For PS3 support change to "yes" ->
            <!-
               Uncomment the lines below to get rid of jerky avi playback on the
               DSM320 or to enable subtitles support on the DSM units
            ->
            <!-
            <custom-http-headers>
              <add header="X-User-Agent: redsonic"/>
            </custom-http-headers>
       
            <manufacturerURL>redsonic.com</manufacturerURL>
            <modelNumber>105</modelNumber>
            ->
            <!- Uncomment the line below if you have a Telegent TG100 ->
            <!-
               <upnp-string-limit>101</upnp-string-limit>
            ->
          </server>
          <import hidden-files="no">
            <scripting script-charset="UTF-8">
              <common-script>/usr/share/mediatomb/js/common.js</common-script>
              <playlist-script>/usr/share/mediatomb/js/playlists.js</playlist-script>
              <virtual-layout type="builtin">
                <import-script>/usr/share/mediatomb/js/import.js</import-script>
              </virtual-layout>
            </scripting>
            <mappings>
              <extension-mimetype ignore-unknown="no">
                <map from="mp3" to="audio/mpeg"/>
                <map from="ogg" to="application/ogg"/>
                <map from="asf" to="video/x-ms-asf"/>
                <map from="asx" to="video/x-ms-asf"/>
                <map from="wma" to="audio/x-ms-wma"/>
                <map from="wax" to="audio/x-ms-wax"/>
                <map from="wmv" to="video/x-ms-wmv"/>
                <map from="wvx" to="video/x-ms-wvx"/>
                <map from="wm" to="video/x-ms-wm"/>
                <map from="wmx" to="video/x-ms-wmx"/>
                <map from="m3u" to="audio/x-mpegurl"/>
                <map from="pls" to="audio/x-scpls"/>
                <map from="flv" to="video/x-flv"/>
                <map from="avi" to="video/avi"/>
                <map from="mkv" to="video/x-matroska"/>
                <map from="srt" to="video/subtitle"/>
                <!- Uncomment the line below for PS3 divx support ->
                <!- <map from="avi" to="video/divx"/> ->
                <!- Uncomment the line below for D-Link DSM / ZyXEL DMA-1000 ->
                <!- <map from="avi" to="video/avi"/> ->
              </extension-mimetype>
              <mimetype-upnpclass>
                <map from="audio/*" to="object.item.audioItem.musicTrack"/>
                <map from="video/*" to="object.item.videoItem"/>
                <map from="image/*" to="object.item.imageItem"/>
              </mimetype-upnpclass>
              <mimetype-contenttype>
                <treat mimetype="audio/mpeg" as="mp3"/>
                <treat mimetype="application/ogg" as="ogg"/>
                <treat mimetype="audio/x-flac" as="flac"/>
                <treat mimetype="image/jpeg" as="jpg"/>
                <treat mimetype="audio/x-mpegurl" as="playlist"/>
                <treat mimetype="audio/x-scpls" as="playlist"/>
                <treat mimetype="audio/x-wav" as="pcm"/>
                <treat mimetype="video/x-msvideo" as="avi"/>
              </mimetype-contenttype>
            </mappings>
          </import>
          <transcoding enabled="no">
            <mimetype-profile-mappings>
              <transcode mimetype="video/subtitle" using="mencoder-srt"/>
              <transcode mimetype="video/x-flv" using="vlcmpeg"/>
              <transcode mimetype="application/ogg" using="vlcmpeg"/>
              <transcode mimetype="application/ogg" using="oggflac2raw"/>
              <transcode mimetype="audio/x-flac" using="oggflac2raw"/>
            </mimetype-profile-mappings>
            <profiles>
              <profile name="oggflac2raw" enabled="no" type="external">
                <mimetype>audio/L16</mimetype>
                <accept-url>no</accept-url>
                <first-resource>yes</first-resource>
                <accept-ogg-theora>no</accept-ogg-theora>
                <agent command="ogg123" arguments="-d raw -f %out %in"/>
                <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
              </profile>
              <profile name="vlcmpeg" enabled="no" type="external">
                <mimetype>video/mpeg</mimetype>
                <accept-url>yes</accept-url>
                <first-resource>yes</first-resource>
                <accept-ogg-theora>yes</accept-ogg-theora>
                <agent command="vlc" arguments="-I dummy %in -sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
                <buffer size="14400000" chunk-size="512000" fill-size="120000"/>
              </profile>
            </profiles>
            <profiles>
              <agent command="/home/jorge/.mediatomb/mediatomb-mencoder-srt" arguments="%in %out"/>
            </profiles>
          </transcoding>
        </config>

     
  • dark

    dark - 2009-10-12

    No one to help for subtitles??

     
  • ZenLord

    ZenLord - 2009-12-01

    I got it working. Some things that were not mentioned in the documentation, but will be obvious to some people:

    * the external transcode-script has to be made executable
    * check the location of the font-file and adapt the script accordingly
    * mencoder has to be installed
    * in your transcoding profile, you need entries for mime-type and … among others

    If it still doesn't work, start mediatomb as a daemon and watch the output in your terminal. You could also try to run the transcoding script manually and check the output.

     
  • Jeroenp

    Jeroenp - 2010-03-16

    Which Mediatomb version are you guys using? I built my 0.12 on 2009-09-24. I dont remember which revision. I tried all of the above (from zenlord), but I guess the piggybacking-script is exiting or something. My PS3 only shows the files as "Incompatible data"

     
  • ZenLord

    ZenLord - 2010-03-16

    My setup is still working and I have rebuilt my mediatomb-svn several times.

    What is the output you are getting when you start mediatomb manually and you start a srt-file from your ps3?

     
  • Jeroenp

    Jeroenp - 2010-03-16

    I just tried it and this is what I get..

    2010-03-16 17:44:02    INFO: Arguments: %in %out
        Last message repeated 1 times
    Invalid and inefficient vfw-avi packed B frames detected
    Invalid and inefficient vfw-avi packed B frames detected
        Last message repeated 1 times
    Invalid and inefficient vfw-avi packed B frames detected
    Invalid and inefficient vfw-avi packed B frames detected
        Last message repeated 1 times
    Invalid and inefficient vfw-avi packed B frames detected
    Invalid and inefficient vfw-avi packed B frames detected

    The first time there is a Corrupted Data error, the next time it says there is a Netwerk error (0x0000000) while I can still go on the internet..

     
  • Jeroenp

    Jeroenp - 2010-03-16

    Just retried it, and now it only displays the

    2010-03-16 17:44:02 INFO: Arguments: %in %out

    It seems the "invalid and inefficient" message is not related to the srt-file..

     
  • Jeroenp

    Jeroenp - 2010-03-16

    I just updated mediaTomb by building it again from SVN, using the existing config. It now outputs something:

    MEncoder 2:1.0~rc2-0ubuntu13.1 (C) 2000-2007 MPlayer Team
    CPU: Intel(R) Celeron(R) CPU 2.30GHz (Family: 15, Model: 2, Stepping: 7)
    CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
    Compiled with runtime CPU detection.
    success: format: 0  data: 0x0 - 0x2bd50800
    AVI file format detected.
    Video stream found, -vid 0
    Audio stream found, -aid 1
    VIDEO:    664x282  12bpp  23.976 fps  854.4 kbps (104.3 kbyte/s)
    filefmt:3  fourcc:0x44495658  size:664x282  fps:23.98  ftime:=0.0417
    ==========================================================================
    Opening audio decoder:  MPEG layer-2, layer-3
    AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
    Selected audio codec:  afm: mp3lib (mp3lib MPEG layer-2, layer-3)
    ==========================================================================
    SUB: Detected subtitle file format: subviewer
    SUB: Read 770 subtitles.
    SUB: Adjusted 3 subtitle(s).
    PACKET SIZE: 2048 bytes, deltascr: 36864
    Opening video filter:
    Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
    Opening video filter:
    ==========================================================================
    Opening video decoder:  FFmpeg's libavcodec codec family
    Selected video codec:  vfm: ffmpeg (FFmpeg MPEG-4)
    ==========================================================================
    Limiting audio preload to 0.4s.
    Increasing audio density to 4.
    VDec: vo config request - 664 x 282 (preferred colorspace: Planar YV12)
    VDec: using Planar YV12 as output csp (no 0)
    Movie-Aspect is 2.35:1 - prescaling to correct movie aspect.
    videocodec: libavcodec (664x282 fourcc=3267706d )
    MPEG1/2 does not support 27021/1127 fps
    Could not open codec.
    FATAL: Cannot initialize video driver.

    Exiting…

    is it the libavcode that I need or is it something else that I might have missed?

     
  • headrush69

    headrush69 - 2010-03-16

    I convert all my videos to h.264 now but when I did use trancoding I had the same problem.

    I had to send extra options to mencoder to get the transcoding to work.

    Here is what is in my /usr/local/bin/mencoder-srt script:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #!/bin/bash
    srt="$1"
    output="$2"
    # filename must be of the form "movie name.XX[X].srt" or "movie name.srt"
    base_name="$(echo $srt | sed 's/\..\{2,3\}\.srt$//' | sed 's/\.srt$//')"
    extensions="avi mp4 mpg mov"
    for ext in $extensions ; do
        input=$base_name.$ext;
        if [[ -e $input ]]; then break; fi
    done
    exec mencoder "$input" -oac lavc -ovc lavc -of mpeg -lavcopts vcodec=mpeg2video:keyint=1:vbitrate=200000:vrc_maxrate=9000:vrc_buf_size=1835 -vf harddup -mpegopts muxrate=12000 -fps 30 -sub "$srt" -font "/usr/share/fonts/dejavu/DejaVuSans.ttf" -o "$output"
    
     
  • Jeroenp

    Jeroenp - 2010-03-17

    Thanks for your reply. Unfortunately I f*cked up.. I got all segfaults after my latests post.. Still I'm not sure what segfaults mean..

    Anyway I tried rebuilding mediatomb from svn after the segfaults.. Well that didn't go as planned so i'm rebuilding all the needed libs again too..
    If I have it working again I will try your subtitle script and I'll get back to you..

    Thanks again for the reply :)

     
  • Jeroenp

    Jeroenp - 2010-03-22

    Hey there,

    MediaTomb is working again with all-new libraries :D yay! Well, that's the good news. I setup the script mentioned above, but the bad news is, it doesn't even display the .srt files on the PS3. I checked my config several times but I couldn't find what was missing.

    I made a " <map from="srt" to="video/subtitle" />" entry and a transcoding profile but the .srt files still dont show up. I even tried adding them manually from the webinterface.

    Does any of you guys know  a solution for this? It's driving me mad that I can't test the subtitlescript mentioned above :(

     
  • Anonymous

    Anonymous - 2010-03-22

    I don't know if I can be helpful, anyway…
    When something doesn't seem to work on mediatomb I start it from commandline (not daemon) so I can see all the messages.
    You should print the command launched when you click on the video, then try to launch manually the command in a separate terminal and check if that command creates the video with subtitles.
    I didn't tried to transcoding subtitles, but this method helped me to transcode youtube/apple video on my PS3.

    For example if your script launches something like
    mencoder $1 -opt1 $opt1 -opt2 $opt2
    you should also print:
    echo mencoder $1 -opt1 $opt1 -opt2 $opt2

    Hope it helps to track what's wrong.

    Cheers

     
  • Jeroenp

    Jeroenp - 2010-03-22

    Well in this case I have trouble adding the .srt files, I read somewhere that if modify the extensions, you have to build your mediadb from scratch.. im gonna try this tonight when im back at home

     
  • Jin

    Jin - 2010-03-22

    Uhm… actually, you need just the vlcmpeg profile with the soverlay option, then simply put your .srt or other subtitle files in the same directory as the video file, and name it exactly the same, just with the different extension,i.e.:

    video.avi
    video.srt

    VLC, with the soverlay parameter, will then pick up the subtitles automatically and blend them into the stream.

     
  • Jeroenp

    Jeroenp - 2010-03-25

    hi jin_eld and headrush69,

    I've finally managed to come around and try your suggestions. I tried them with filenames withouth spaces in them, just to be sure..

    @headrush69: Again, the subtitle configuration did not work me, It says "Incompatibe Data" alreade in thee PS3 file browser.

    @jin_eld Apart from not seeing the subtitles, I also saw you can't pauze or seek in the stream if you encode with vlc. I've always used ffmpeg in my previous configuration and it looks like ffmpeg can allow these actions while playing. That's a big plus for me.

    Thank you both for your replies, unfortunately they didn't work for my situation :(

     
  • Jeroenp

    Jeroenp - 2010-03-25

    Some extra information about jin_eld's suggestion: the video itself runst fine but without the subtitles…

    Running mediatomb from the commandline doesnt give anything as the video wont play with head_rush69's solution

     
  • headrush69

    headrush69 - 2010-03-25

    Let's separate whther this is a encoder or mediatomb problem.

    If you take the mencoder code I gave above, and run it manually substituting your pathname for vieo and subtitle files, does it play and add the subtitles.

    If no, please post any message from mencoder.

     
  • headrush69

    headrush69 - 2010-03-25

    P.S. Depending on your Linux distro, you might have to correct the pathname to your font location used on that encoder line also.

     
  • Jin

    Jin - 2010-03-25

    @jin_eld Apart from not seeing the subtitles, I also saw you can't pauze or seek in the stream if you encode with vlc. I've always used ffmpeg in my previous configuration and it looks like ffmpeg can allow these actions while playing. That's a big plus for me.

    No, it does not matter - as soon as you transcode something you lose the ability to seek (pause depends on the player).

    I would also suggest to try the VLC options on command line first, once you have it working you can then integrate this options into your config.xml

     
  • Jeroenp

    Jeroenp - 2010-03-28

    Yes, it finally works! I screwed up my config.xml again, but I let it regenerate now adding only the code needed for the .srt files. I had two version of the transcoder script, the wiki version and the one headrush69 provided me.

    I only fixed the font path in the wiki script, but I was working with headrush's…. STUPID STUPID STUPID!

    Now it work, so thanks a lot to all of you guys who replied! I adjusted the font using the "-subfont-text-scale" option and adjusted the framerate to 25. The default value of 30 cause the audio/video to get out of sync.

    It's too bad I cant pause the file. I don't mind not being able to seek. Do you know which players offer this option or whether you can enable this using mencoder?

    In the gentoo forums they play with ffmpegthumbnailer, so pause will be enabled http://forums.gentoo.org/viewtopic-p-6136607.html?sid=975d4f5f210c1443916b4e38f0813d1f#6136607
    An interesting thought although I'm very sure that doesnt play subtitles hahaha

    Well, if the whole Pause thing isn't possible, I could live with it.

    Thanks a million again you guys for trying, and succeeding, to help me!

     
  • Anonymous

    Anonymous - 2010-03-29

    You can pause the movie on PS3 pressing the Playstation button ;)

     
  • Paul Littlefield

    This is running on a headless server, so not sure if I can test it?

    I have checked my font path and the config.xml 3 times.

    I have even tried using the mediatomb --debug option, but so much flies past the screen, I am not sure what to search for.

    Does anyone else run mediatomb on a headless server and how do I test it from a laptop before I go running it on the Smart TV?

    Thanks!

     

Log in to post a comment.