Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[mediatomb] configuration help needed
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Sat Aug 25, 2012 4:52 pm    Post subject: [mediatomb] configuration help needed Reply with quote

Hello,

Remux is working, mediatomb configuration not, see bellow

When you're connecting a TV to a DNLA/uPNP server, it's only possible to send 1 stream at a time. In order to handle subtitle, mediatomb proposes to include texts directly in the video using transcoding.

On the other hand, my TV is able to display sub-title embedded in mkv.

So, any way convert AVI + SRT files into MKV ? I don't want changing video encoding, only the container.

Thanks

Laurent


Last edited by destroyedlolo on Wed Aug 29, 2012 11:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Sat Aug 25, 2012 5:19 pm    Post subject: Reply with quote

Do you mean while streaming? Dunno, but may be possible using ffmpeg or mencoder. If you'd like to do it beforehand, just use mmg(GUI) or mkvmerge from the mkvtoolnix package.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Sun Aug 26, 2012 10:03 am    Post subject: Reply with quote

Sorry, my english is propably not so clear :)

I don't want to re-encode the video (i.e, from XVid to h.264) because there is no need. What I'm looking for is a way to convert an .SRT and his .AVI companion to an .MKV on the fly, when I'm clicking on the .SRT on my TV.

truc.avi + truc.avi.srt => mkv sent to the TV

but on the fly, that is the result is not stored as a file but directly streamed to the TV.

(the proposed mediatomb solution for SRT is to render subtitle directly in a transcoded video stream which is very CPU intensive for nothing ... in my case)
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Sun Aug 26, 2012 10:28 am    Post subject: Reply with quote

What I'm proposing is no re-encoding, it just demuxes the stuff in the .avi and remuxes it into .mkv. Depending on your CPU and HDD-speed, that's pretty quick (takes <1min per 1.5gb file on my machine) and no quality is lost. If (all) your equipment is capable of playing .mkv anyway, there's no point storing the files in .avi, since mkv is by far a superior container.

As I said, I'm pretty sure it can be done on the fly with ffmpeg, but I wouldn't know from the top of my head how to do it.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sun Aug 26, 2012 8:35 pm    Post subject: Reply with quote

media-video/mkvtoolnix
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Tue Aug 28, 2012 10:37 pm    Post subject: Reply with quote

I did some tests with ffmpeg I failed :

Code:
ffmpeg -i Xmass2010-AXmassCarol.mkv -vcodec copy -acodec copy -i Doctor.Who.514.Xmas.Special.2010.FR.TAG.srt tst.mkv
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun 23 2012 16:00:07 with gcc 4.5.3
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --enable-shared --cc=gcc --cxx=g++ --ar=i686-pc-linux-gnu-ar --optflags='-O2 -march=i686 -pipe -fomit-frame-pointer' --extra-cflags='-O2 -march=i686 -pipe -fomit-frame-pointer' --extra-cxxflags='-O2 -march=i686 -pipe -fomit-frame-pointer' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-network --disable-vaapi --disable-vdpau --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libfaac --enable-nonfree --disable-indev=v4l --disable-indev=v4l2 --disable-indev=oss --disable-indev=jack --enable-x11grab --disable-outdev=oss --enable-libfreetype --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libspeex --enable-libopenjpeg --disable-amd3dnowext --disable-altivec --disable-avx --disable-mmx2 --disable-ssse3 --disable-vis -  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, matroska,webm, from 'Xmass2010-AXmassCarol.mkv':
  Metadata:
    title           : Avidemux
    AUTHOR          : Avidemux
    ENCODER         : Lavf53.24.0
  Duration: 01:01:41.76, start: 0.000000, bitrate: 632 kb/s
    Stream #0:0: Video: h264 (High), yuvj420p, 624x352 [SAR 1:1 DAR 39:22], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Stream #0:1: Audio: aac, 48000 Hz, stereo, s16 (default)
Unknown decoder 'copy'


It seems it doesn't like having all field copied.

Then I've tried with mkvmerge which is able to add subtitle field.

Code:
mkvmerge -o tst.mkv Xmass2010-AXmassCarol.mkv --language 0:fr --sub-charset 0:ISO-8859-15 Doctor.Who.514.Xmas.Special.2010.FoV.FR.TAG.srt
mkvmerge v5.0.1 ('Es ist Sommer') compilé le Aug  5 2012 à 20:10:01.
'Xmass2010-AXmassCarol.mkv' : utilisation du démultiplexeur Matroska.
'Doctor.Who.514.Xmas.Special.2010.FoV.FR.TAG.srt' : utilisation du lecteur de sous-titres SRT.
'Xmass2010-AXmassCarol.mkv' piste 1 : utilisation du module de sortie vidéo MPEG-4 partie 10 (AVC).
'Xmass2010-AXmassCarol.mkv' piste 2 : utilisation du module de sortie AAC.
'Doctor.Who.514.Xmas.Special.2010.FoV.FR.TAG.srt' piste 0 : utilisation du module de sous-titrage texte.
Le fichier 'tst.mkv' est ouvert en écriture.
Progression : 100%
Les entrées d'index sont créées...
Le multiplexage a duré 29 secondes.


--sub-charset 0:ISO-8859-15 is needed because sub came generally in ISO format, and MKV needs UTF-8

Now, the remaining problem is to include that in mediatomb ...
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Wed Aug 29, 2012 11:09 pm    Post subject: [mediatomb] configuration help needed Reply with quote

So my remux script is working ... but I don't succeed to configure mediatomb :?

Here part of my configuration :
Quote:
<mappings>
...
<extension-mimetype ignore-unknown="no">
...
<map from="srt" to="video/subtitle"/>
</extension-mimetype>
</mappings>
<transcoding enabled="yes">
<mimetype-profile-mappings>
...
<transcode mimetype="video/subtitle" using="include-sub"/>
</mimetype-profile-mappings>
<profiles>
<profile name="include-sub" enabled="yes" type="external">
<mimetype>video/x-matroska</mimetype>
<accept-url>no</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<agent command="/usr/local/bin/include-srt" arguments="%in %out"/>
<buffer size="10485760" chunk-size="262144" fill-size="524288"/>
</profile>
</profiles>
</transcoding>


When I select an srt, my script is never called and VLC switch to the next available video :(

Any idea ?
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Fri Sep 07, 2012 4:04 pm    Post subject: Reply with quote

Well ...

I found out why my script was never called, it's because all SRT files stayed as "text/plain".

Gentoo's Wiki related to mediatomb says "If you have added or changed a mimetype mapping after importing your content, you will need to re-import it as mimetype mappings are only set during import.", and a simple refresh is not enough : I had to remove the directory tree from Mediatomb's DB and reimport it. Unfortunately, it's not clearly said in Mediatomb site :?

Now my script is correctly launched BUT vlc is complaining about the result :
Code:
main warning: AStreamSeekStream: can't seek
mkv error: cannot find any cluster, damaged file ?
ps error: cannot peek
mjpeg warning: no more data
mjpeg error: cannot peek
mpgv error: cannot peek
avformat warning: cannot peek
ps error: cannot peek
main error: no suitable demux module for `http/://192.168.0.15:49152/content/media/object_id/84/res_id/none/pr_name/include-sub/tr/1'
main error: cannot pre fill buffer

and it's doing another request for the same file.

So,
  • or it's because the conversion took too long (about 1' on my old hardware),
  • or because the result is not seekable because it's a pipe ...


All in all, I don't see how I can go further :cry:
Back to top
View user's profile Send private message
BT
Guru
Guru


Joined: 13 Jun 2004
Posts: 318

PostPosted: Sat Sep 08, 2012 2:13 am    Post subject: Reply with quote

destroyedlolo,

It's possible to transcode on-the-fly with subtitles enabled with the method described below. This method assumes your TV accepts mpeg2 video.

You don't need the srt mimetype mapping so you can remove it. You will be using the default avi mimetype mapping in config.xml which is video/divx.

Add the following mimetype-profile mapping.
Code:
    <mimetype-profile-mappings>
      <transcode mimetype="video/divx" using="video2mpeg"/>
    </mimetype-profile-mappings>

Add the following transcoding profile.
Code:
    <profiles>
      <profile name="video2mpeg" enabled="yes" type="external">
        <mimetype>video/mpeg</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <hide-original-resource>yes</hide-original-resource>
        <accept-ogg-theora>yes</accept-ogg-theora>
        <sample-frequency>48000</sample-frequency>
        <audio-channels>2</audio-channels>
        <agent command="/usr/local/bin/video2mpeg" arguments="%in %out"/>
        <buffer size="10485760" chunk-size="262144" fill-size="524288"/>
      </profile>
    </profiles>

Add the following transcoding script in /usr/local/bin and name it video2mpeg. Make sure that VLC has the encode and truetype use flags enabled. The truetype use flag is needed for subtitle support. You should probably test the script without MediaTomb to ensure it's working.
Code:
#!/bin/sh

VLC_PATH="/usr/bin/vlc"
INPUT="$1"
OUTPUT="$2"
VIDEO_CODEC="mp2v"
VIDEO_BITRATE="4096"
VIDEO_FRAMERATE="25"
AUDIO_CODEC="mpga"
AUDIO_BITRATE="192"
AUDIO_SAMPLERATE="48000"
AUDIO_CHANNELS="2"
FORMAT="ps"

exec "${VLC_PATH}" "${INPUT}" -I dummy --sout="#transcode{vcodec=${VIDEO_CODEC},\
vb=${VIDEO_BITRATE},fps=${VIDEO_FRAMERATE},acodec=${AUDIO_CODEC},ab=${AUDIO_BITRATE},\
samplerate=${AUDIO_SAMPLERATE},channels=${AUDIO_CHANNELS},audio-sync,soverlay}:\
standard{access=file,mux=${FORMAT},dst=${OUTPUT}}" vlc://quit

Restart MediaTomb. If you have changed any mimetype mappings you should re-import all your files again.

With this method avi files will be transcoded regardless if they have srt files or not. If you prefer to only transcode avi files that have subtitles, then you can workaround this by renaming those avi files with a different extension. For example if you used .avis you would map the avis extension to video/subtitle. You then change the transcode mimetype-profile mapping from video/divx to video/subtitle. Restart MediaTomb and re-import all your files again.
Back to top
View user's profile Send private message
destroyedlolo
l33t
l33t


Joined: 17 Jun 2011
Posts: 846
Location: Close to Annecy (France)

PostPosted: Sat Sep 08, 2012 12:02 pm    Post subject: Reply with quote

Hi BT,

I know this method : It's the methods I used before I got my connected TV because it's the only way I can stream something to my settopbox (FreeBox).
But I would like to avoid it : it's re-encoding the video on the fly on the server that's consuming lot of resources and creates quality loss which is not the case with mkvmerge as the video is kept, only the container is changed.

BT wrote:
then you can workaround this by renaming those avi files with a different extension.

If I have to touch my original video, I would prefer convert it to an mkv with sub-title included in an other track.

Bye
Back to top
View user's profile Send private message
BT
Guru
Guru


Joined: 13 Jun 2004
Posts: 318

PostPosted: Sat Sep 08, 2012 12:21 pm    Post subject: Reply with quote

I didn't realize that you only want to remux. In that case I don't believe it's possible to remux on-the-fly to mkv because as you have pointed out the stream is not seekable. I think your best option is to manually remux to mkv.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum