FAQ  •  Register  •  Login

how to make a ffmpeg wrapper ?

<<

xrensgory

Serviio newbie

Posts: 2

Joined: Thu Dec 08, 2011 12:24 pm

Post Thu Dec 08, 2011 12:34 pm

how to make a ffmpeg wrapper ?

Hi!
I use serviio 0.6.0.1 on FreeBSD/amd64 from ports collection. And I have some problems when playing videos on xbox360 slim.
Playing is very laggy.
My hardware is intel quad-core Q6600 running at 2,4GHz with 8GB of RAM.
Careful study showed that FFmpeg works in one thread. I wrote a ffmpeg wrapper called ffmpeg-mt, which clearly indicated the parameters:
/usr/local/bin/ffmpeg-mt
  Code:
#!/bin/sh
/usr/local/bin/ffmpeg -threads 4 $@


And edited /usr/local/sbin/serviiod
  Code:
gsed -i 's/ffmpeg"/ffmpeg-mt"/' /usr/local/sbin/serviiod


cat /usr/local/sbin/serviiod
  Code:
#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  Serviio start Script                                                    ##
##                                                                          ##
### ====================================================================== ###

SERVIIO_HOME=/usr/local/share/java/classes/serviio
SERVIIO_CLASS_PATH="$SERVIIO_HOME/serviio.jar"
# Setup the classpath
for j in derby jcs concurrent freemarker httpcore jaudiotagger  \
    jul-to-slf4j jcl-over-slf4j log4j sanselan slf4j-api        \
    slf4j-log4j12 org.restlet org.restlet.ext.xstream xstream   \
    rome rome-modules jdom groovy-all winp org.restlet.ext.gson gson
do
        SERVIIO_CLASS_PATH="$SERVIIO_CLASS_PATH:$SERVIIO_HOME/$j.jar"
done
SERVIIO_CLASS_PATH="$SERVIIO_CLASS_PATH:/usr/local/etc/serviio"

# Setup Serviio specific properties
JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dderby.system.home=/var/db/serviio -Dserviio.home=$SERVIIO_HOME -Dffmpeg.location=/usr/local/bin/ffmpeg-mt"


# A kludge to get the -D... flags to Java, rather than to Serviio itself:
for o in "$@"
do
        case $o in
        -D*)
                JAVA_OPTS="$JAVA_OPTS $o"
                ;;
        esac
done

# Execute the JVM in the foreground
exec java -Xmx384M $JAVA_OPTS -classpath "$SERVIIO_CLASS_PATH" org.serviio.MediaServer "$@"


In this case the wrapper correctly work from the command line, but does not runs from serviio.

grep -A 3 ffmpeg-mt /var/log/serviio/serviio.log
  Code:
2011-12-08 06:30:48,121 WARN  [ProcessExecutor] Process /usr/local/bin/ffmpeg-mt has a return code of 1! This is a possible error.
2011-12-08 06:30:55,726 ERROR [ResourceTransportRequestHandler] Error while processing resource, sending back 500 error. Message: Transcoded file '/home/archive/pub/tmp/Serviio/transcoding-temp-26192-ASF.stf' cannot be found, FFmpeg execution probably failed
java.io.IOException: Transcoded file '/home/archive/pub/tmp/Serviio/transcoding-temp-26192-ASF.stf' cannot be found, FFmpeg execution probably failed
        at org.serviio.delivery.resource.AbstractTranscodingDeliveryEngine.retrieveTranscodedResource(AbstractTranscodingDeliveryEngine.java:115)


How do I correctly specify serviio to run ffmpeg in 4 threads?
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Dec 08, 2011 1:45 pm

Re: how to make a ffmpeg wrapper ?

The wmv encoder in FFMpeg only works with 1 thread, that's why it fails and that's why Serviio ignores the threads setting for wmv encoding.
<<

xrensgory

Serviio newbie

Posts: 2

Joined: Thu Dec 08, 2011 12:24 pm

Post Thu Dec 08, 2011 2:02 pm

Re: how to make a ffmpeg wrapper ?

damn.. i forgot it.. But anyway thank you for your help :)
<<

abeloin

Serviio newbie

Posts: 3

Joined: Thu Nov 10, 2011 2:17 am

Location: Canada

Post Mon Dec 19, 2011 8:47 am

Re: how to make a ffmpeg wrapper ?

Maybe useful to some.

I have a similar lag issue on the Xbox 360's with transcoded 1920x1080 video. Changing the bitrate didn't helped and as my TV is only 480p, I've resized the video in the transcoding phase(meaning any transcoded video will be resized).

EX: Serviio reside in /opt/serviio

Create a file ffmpeg-custom in the folder /opt/serviio/bin. Make it executable.
  Code:
#!/bin/bash
args=("$@")
/usr/bin/ffmpeg -vf scale=640:-1 "${args[@]}"


Edit /opt/serviio/bin/serviio.sh and add the following in JAVA_OPTS:
  Code:
-Dffmpeg.location=/opt/serviio/bin/ffmpeg-custom
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Mon Dec 19, 2011 8:56 am

Re: how to make a ffmpeg wrapper ?

You coud also use ServiioService.exe.vmoptions: -Dffmpeg.location=
Like this
viewtopic.php?f=11&t=2956&start=30#p27617
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator

Return to Transcoding

Who is online

Users browsing this forum: No registered users and 29 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.