How to add MOV transcoding ?

General discussion about the media server. Feature requests. Hints, tips and tricks.
Post Reply
tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

How to add MOV transcoding ?

Post by tws1138 » Tue Nov 15, 2011 11:51 am

Hi Twonky Forum,

I want to stream MOV files to my Samsung TV. As my Samsung does not support this video format I have the need to transcode it to mpeg which is the easiest way to make it work for my TV.
I added the description file called "ffmpeg-mov-mpeg.desc" with the following content to the cgi-bin directory:

exec: ffmpeg -i $infile -vcodec mpeg2video -y $outfile
# capabilities
from=video/quicktime
to=video/mpeg
synchronous
priority=idle

file permissions 644

I added following line to the "resources/transcoding.db" file in the audio stanza

MOV,mov,video/quicktime,mov

I am wondering if I need to add something to the Samsung TV stanza in the resources/clients.db file.
I would assume to add something ( "MOV" ??? )to the < TR: > line - but I am not sure about that.

I found on the Twonky Wiki that I would need to check the "mpeg" box at the transcoding page of the web interface?
I thought that these setting would be to pre-transcode files to be stored in the Twonky cache.
Do I really need to check this box to enable Twonky transcoding on the fly?

I ask all this because it does not work to stream MOV files to my TV. It says "not supported file type". I tested the ffmpeg command manually and it produces a MPEG file which can be played by my TV. But somehow the "on-the-fly" trancoding does not work.

I would highly appreciate if there could be a documentation for advanced users how to add and enable new transcoding methods. I understand that Twonky can not deliver all needs for all existing DLNA clients but there should be a way to add this manually on your own. Of course this would be "Out-Of-Support" but I think it would be highly appreciated by the community.

Nevertheless I would appreciate if someone could help me to set up Twonky for on-the-fly transcoding of MOV to stream MPEG to the DLNA client.

Thank you very much in advance
tws1138

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Tue Nov 15, 2011 8:01 pm

I found on the Twonky Wiki that I would need to check the "mpeg" box at the transcoding page of the web interface?
I thought that these setting would be to pre-transcode files to be stored in the Twonky cache.
Do I really need to check this box to enable Twonky transcoding on the fly?
It is my understanding that you have to enable that to get on the fly transcoding to work
I am wondering if I need to add something to the Samsung TV stanza in the resources/clients.db file.
I would assume to add something ( "MOV" ??? )to the < TR: > line - but I am not sure about that.
In the example used in the following post
http://www.twonkyforum.com/viewtopic.ph ... 978#p38942
He was able to do it for m4a to mp3, without having to add any edit to the clients.db

Have you tried it yet, with the changes you have made,
but with the transcoding mpeg option enabled?
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

Re: How to add MOV transcoding ?

Post by tws1138 » Wed Nov 16, 2011 12:15 am

[quote="phibertron"]
Have you tried it yet, with the changes you have made,
but with the transcoding mpeg option enabled?
[/quote]

Thank you phibertron for your reply !!!

I have not yet test it with the mpeg option box checked because my understanding is that Twonky will then pre-transcode all files with NON mpeg formats to mpeg and I have some big MKVs that work with my TV and do not need to be transcoded.
I currently do not totally understand what files Twonky considers as candidates for transcoding :? Will it be all video files that are not in mpeg format or will it be just the files that are in a formet that my DLNA clients are not accepting natively (as defined in the clients.db) ???

Anyway, I will test it tomorrow evening with the checked mpeg option which will be in about 20 hours or so as I am living in Europe in the GMT+1 time zone and it just around midnight right now for me :wink:

Good Night!

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Wed Nov 16, 2011 1:04 am

Im not 100% sure it does the pre-encdoing of all your files, I didnt think that was the case
But I do know that it leaves whatever file it has encoded in cache
and cant remember where at the moment,
but I think there is somewhere to limit the size of the cache so that the older files fall off
so that you drive space doesnt get used up

The whole idea of this feature in twonky isnt documented very well
and if you scour through the forums, there are lot of expirments going on =)
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

Re: How to add MOV transcoding ?

Post by tws1138 » Wed Nov 16, 2011 11:38 pm

Hi phibertron,

checking the MPEG box did not help. My TV still says "unsupported file format". I tried to find in /var/opt/twonkymedia if enything got pre-trancoded but all video directories are empty. I fount something in /var/opt/twonkymedia/db. One of the dat files contained for the MOV file;
~>>>>
01004I782
0301Bobject.item.videoItem.movie
14008P1000359
19007Unknown
1A003MKV
1F00264
210132009-12-12T20:35:04
2200A1321210815
230132011-11-16T23:06:37
3100A1321210821
3500A1321210815
3C01E/media/backup/MKV/P1000359.MOV
3D00855987122
3E0070:00:57
43007640x480
C000214
D10011
â–’>>>>
It looks like Twonky does not even recognize the file at all - see the: UNKOWN line in the stanza of the dat file above. This indicates to me that the MOV file gets passed 1:1 to the TV and of course it can not be played as MOV file.

I had this MOV file (P1000359.MOV) converted before with ffmpeg to a MPEG file (test1.mpg) to see if my command in the desc file creates a playable file. I have put it in the same directory. Twonky recognizes it - see below: no UNKOWN line in the stanza of the dat file - and my TV can play it:
â–’>>>>
01005I1038
0301Bobject.item.videoItem.movie
14005test1
1A003MKV
1F00215
210132011-11-16T00:00:00
2200A1321469950
230132011-11-16T23:07:28
3100A1321469956
3500A1321469950
3C01B/media/backup/MKV/test1.mpg
3D0073532800
3E00B0:00:41.285
43007640x480
520052,2,0
530011
C000214
â–’>>>>
I would like to know now how to make Twonky to accept the file because I can understand that Twonky does not do any transcoding to an UNKOWN file type.

Here is what I added to the /opt/twonkymedia/resources/transcoding.db file
# Quicktime Video
MOV,mov,video/quicktime
Does this look right for MOV files?

Thank you for your support !
Cheers,
tws1138

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Thu Nov 17, 2011 1:27 am

I guess the first question to ask is
Does the MOV file in question appear in the list of video when viewed via the web interface?

If it doesnt show up there, do you have a program called mediainfo?
it can tell us what format of video and audio is in that MOV container

If it does show up there, then it should be a supported video type for twonky

Does your ffmpeg.location file have a correct path to ffmpeg executable?

I took a look at my transcoding.db for 6.0.37
I have this entry in it, which I did not put there,
it is possible its a left over from other version, but I doubt it
but this is different thatn what you put in there

MOV320x240,mp4,video/mov

Also, I found this file, ffmpeg-mov-flv.desc
So I think your ffmpeg-mov-mpeg.desc is ok

Code: Select all

# transcode video
#(c) 2008 by PacketVideo
exec: ffmpeg -i $infile -vcodec flv -f flv -s qvga -vb 256000 -ab 64000 -ac 2 -ar 44100 $outfile
# capabilities
from=video/quicktime
to=video/flv
asynchronous
priority=idle
The other thing is in the clients.db
This may or may not be needed, not sure, but if I had to guess, bases on the other usage in the file
I added MPEG to the end of the TR: line

Code: Select all

>>
NA:Samsung TV
DD:Samsung DTV
XM:DLNA15
XM:FORCE_DURATION
XM:FORCE_4TH_FIELD
XM:AARES
DX:SAMSUNGFEATLIST
DB:FIX
MT:mkv video/x-mkv
MT:mpeg,mpeg2,vdr,spts,tp,ts video/mpeg
HP:chunked
MT:m4a audio/mp4
TR:JPEGORG,JPEG160x160,JPEG640x480,JPEG1024x768,JPEG1920x1080,MPEG
One could also argue, an MT option might work, not sure though
to translate .mov mimtype to an mp4 type, if only we were so lucky

Code: Select all

MT:mov video/mp4
Let us know how it works out, either way

Oh yeah, almost forgot, you mentioned your worries about background transcoding of everything
I remembered after looking at it =)
In the transcoding.db there is this

Code: Select all

# the following lines defines output formats for background transcoding
# the format is NAME=comma separated list of profiles
# background-transcoding-group:JPEG=JPEG1920x1080
# background-transcoding-group:MP3=MP3
# background-transcoding-group:MPEG2=MPEG
# background-transcoding-group:WMV=WMV
# background-transcoding-group:MPEG4=CIF15
# background-transcoding-group:Flash=FLASH
It appears to me that one has to enable the ability to do background transcoding
by removing the # from one or more of the above
but this is just an assumption
.
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Thu Nov 17, 2011 11:52 pm

I did some testing today

I did some tests with the following, and some without it

ffmpeg-mov-mpeg.desc

# transcode video
#(c) 2008 by PacketVideo
exec: ffmpeg -i $infile -vcodec mpeg2video $outfile
# capabilities
from=video/quicktime
to=video/mpeg
asynchronous
priority=idle


I noticed this file, and it is in essence and "All" to mp4
which I leveraged when the above was not used

ffmpeg-ts-mp4.desc

# transcode quicktime video to MP4 H264 video
#(c) 2009 by PacketVideo
exec: ffmpeg -threads 2 -i $infile -vcodec libx264 -b 7500k -refs 1 -bf 3 -acodec libfaac -ac 2 $outfile
# capabilities
from=video/*
to=video/mp4
asynchronous
priority=normal


In the clients.db

The PS3 Client profile this as default

TR:MPEG,JPEGORG,MP4

The Samsung TV profile has this as default

TR:JPEGORG,JPEG160x160,JPEG640x480,JPEG1024x768,JPEG1920x1080

So I'd hope all you should have to do is add the ,MPEG to that line to use the ffmpeg-mov-mpeg.desc
or one could add ,MP4 to the line fo the use of the ffmpeg-ts-mp4.desc

I didnt have time to see the effect of the entry in the transcoding.db
The below is in mine by default

MOV320x240,mp4,video/mov

I any of my test today, I was able to get transcoding to the PS3 wich does not support MOV
I did not have to enable the mpeg or mp4 checkmarks on the transcoding in web interface
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Fri Nov 18, 2011 12:03 am

I should also note, that I avoid transcoding when ever possible, but sometimes its needed
I do all of my own encoding before hand with either handbrake
or by re-muxing from one conainer to another

For example say I had a video in a MOV conainer, taken say with an iPhone
or one that contained AVC video and AAC audio
both of which are supported in the MP4 container
So instead of having to rencode the video and lose quality and time
I just remux them into and mp4 container, and they will be 100% identical
and it is done wicked fast, or as fast as your computers hard drive limits you =)

I use the following command and then copy the file to twonky

ffmpeg -i original.MOV -vcodec copy -acodec copy new.mp4

I intend to see if I can leverage that in a twonky desc. file
just havent gotten around to it

I think the biggest thing to take away from this is
if the video and audio in the container are supported in another container
and that other container is supported by your device
I would reccomend remuxing with ffmpeg for 100% quality retention of the original

I really want to test this as an on the fly option
maybe tonghit ill try who knows

But I figured you could use these tactics as well
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

Re: How to add MOV transcoding ?

Post by tws1138 » Fri Nov 18, 2011 12:53 am

Hi phibertron,

I finally decided to go for the MPEG transcoding and I just added "mov" to the line

Code: Select all

MT:mpeg,mpeg2,vdr,spts,tp,ts,m2ts,mov video/mpeg
of the Samsung TV stanza in the clients.db file

Funnywise Twonky does immediately start a pre-transcoding process of the files (because the MPEG box is still checked !!!)

from:

Code: Select all

root:/media/backup/MKV# ll
insgesamt 196496
drwxr-xr-x 2 root root     4096 2011-11-17 23:47 ./
drwxr-xr-x 8 root root     4096 2011-09-16 21:46 ../
-rwxr--r-- 1 root root    53183073 2011-11-13 19:58 IMG_0169.mov*
-rwxr--r-- 1 root    root    55987122 2011-11-13 20:00 P1000359.mov*
to:

Code: Select all

root:/var/cache/twonkymedia/6579f06a704dd9040e4aa4d9660a26fe/MPEG# ll
insgesamt 11832
drwxr-xr-x 2 root root    4096 2011-11-17 23:35 ./
drwxr-xr-x 5 root root    4096 2011-11-17 23:23 ../
-rw-r--r-- 1 root root 6735872 2011-11-17 23:33 IMG_0169.mov.mpg
-rw-r--r-- 1 root root 3162112 2011-11-17 23:33 P1000359.mov.mpg
I was even able to capture the ffmpeg process with ps -ef | grep twonky:

Code: Select all

root      5615  1107  0 00:06 ?        00:00:00 /usr/local/bin/ffmpeg -i /media/backup/MKV/IMG_0169.mov -vcodec mpeg2video -r 25 /var/cache/twonkymedia/6579f06a704dd9040e4aa4d9660a26fe/MPEG/IMG_0169.mov.mpg
It is a little strange that Twonky does not replace the extension .mov with .mpg but just adds the new extension but I currently do not care.

But even with the transcoded files being available in the twonky cache (as shown above) my Samsung TV still says "unsupported file format".

I checked with mediainfo that the file are now really MPEG files and I can play them with VLC on my server and I can stream them when I copy them to the directory where the MOV files reside. So the files are ok and twonky recognizes them and at least pre-transcodes them.

When I try to stream the MOV files you can see on the server status page below the line the following:

Code: Select all

Active local connections:
TV	00:35:02 /media/backup/MKV/IMG_0169.mov
So my TV gets the original MOV file not the transcoded one.

It looks to me that either my TV or Twonky does not get it right to catch/provide the pointer to the transcoded file instead of using the original file over and over again. Is there a way to debug/log what file the DLNA client requests and what Twonky answers?

I would assume that the "Active local connections" should show the trancoded file path or am I wrong?

I got lost :? I do not see the missing link. Obviously twonky recognizes the mov files and does the right pre-transcoding BUT why does it provide the original file instead of the cached pre-transcoded or does the transcode on the fly ?

It is late for me now. I have to get up early. I hope you are still with me :wink: and probably have still an idea where to look. Thanks for your support.

Cheers and out
tws1138

tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

Re: How to add MOV transcoding ?

Post by tws1138 » Fri Nov 18, 2011 1:21 am

When I browse the Videos through the HTML basd web interface I have the following link for one mov file:

Code: Select all

http://192.AAA.BBB.CCC:9000/disk/NON-DLNA/O0$3$28I1549.mov
For an MP4 file which is natively supported I get:

Code: Select all

http://192.AAA.BBB.CCC:9000/disk/DLNA-PNMPEG4_P2_MP4_SP_VGA_AAC-OP01-FLAGS01700000/O0$3$28I1805.mp4
The "NON-DLNA" makes me nervous. Shouldn't it be like the one below?

Cheers, tws1138
Last edited by tws1138 on Fri Nov 18, 2011 10:44 am, edited 1 time in total.

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Fri Nov 18, 2011 1:28 am

I did play around with the MT settings
MT:mpeg,mpeg2,vdr,spts,tp,ts,m2ts,mov video/mpeg
but all they are doing is injecting a different Mime Type to the stream
which is what some clients need, I dont think this is the case
so I would remove that, as it might cause a logice issue if left there

Have you made this change to the samsung tv client profile?

TR:JPEGORG,JPEG160x160,JPEG640x480,JPEG1024x768,JPEG1920x1080,MPEG

As the TR setting is the one which in my tests made the differene on whether or not a file is
going to or not going to be sent to the client transcoded
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

tws1138
Posts: 9
Joined: Wed Jul 06, 2011 11:16 pm
AV Hardware: Twonky 6.0.28 on Ubuntu Lucid

Re: How to add MOV transcoding ?

Post by tws1138 » Fri Nov 18, 2011 11:22 am

My dear Twonky Guru phibertron !!!

Your are just awesome and you MADE MY DAY!!!

As advised I removed the "mov" entry in the MT line:

Code: Select all

MT:mpeg,mpeg2,vdr,spts,tp,ts,m2ts video/mpeg
and added "MPEG" to the TR line:

Code: Select all

TR:JPEG160x160,JPEG1920x1080,MPEG
and now it WORKS !!! :D :D :D

I have only these little values in the TR: line as this is sufficient for me
But I am a good Padavan because I was always thinking that the key must be in the TR line as I first tried to add the "MOV" to it. And when I carefully read this "explanation" line at the header of the file (I must admit that English is not my mother tongue):

Code: Select all

// TR support for this transcoded formats
it tells you that you should put there the destination format and not the source format. I did not realize that at the first stage because I thought that this is not necessary as my TV "understands" MPEG natively. But this does obviously not count for transcoded files.

Thanks a million!!!

I think that this is a very good example now for the whole community on what to consider when extending the streaming capabilities of ones DLNA client through transcoding. I guess these findings can be used for other formats as well. Thanks for that too

I will now enjoy all my taken MOV files from my several cameras over the years on my big LED TV :mrgreen:

Cheers,
tws1138

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Fri Nov 18, 2011 6:58 pm

Brilliant! :D

I am glad we got this working for you
Yeah, the comments at the top of the db files client/transcoding
are a wealth of information, but sometimes, they arent obvious at first

You appear to be comfortable on the computer,
imagine trying to explain this to a non-techie... :?

Google translate is my freind too
I miss EU, havent been in a while, maybe in the spring

Enjoy!
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

Re: How to add MOV transcoding ?

Post by phibertron » Mon Nov 21, 2011 3:59 pm

A couple of other settings you might want to take a look at

# directory for cached/transcoded files
cachedir=C:\Documents and Settings\All Users\Application Data\TwonkyMedia\db\cache

# max space files take under the directory for cached/transcoded files
cachemaxsize=

The cachemaxsize is one to look at, if your ever conncerned about your drive fillng up with
I assume that it is used like the other settings and is based off of 1024 or 1000
for ex: 16384 would be 16MB
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

Post Reply