mplayer / ffmpeg / mediainfo on the DS-409+

Questions about using 3rd party Media Streaming software may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.

mplayer / ffmpeg / mediainfo on the DS-409+

Postby Ancoron » Thu Jan 28, 2010 6:26 pm

Hi *,

finally I've managed to compile a better and faster ffmpeg, mplayer and mediainfo (http://mediainfo.sourceforge.net/en) for my DS-409+.

As a test I wrote up a script that is used to create a video overview image with several screens and technical information like this:

Image

This script finishes that task on the DS in 17 seconds:
Code: Select all
diskstation> time sh imagegrabber-busybox -big -fast -idx /volume1/Video/Animations\ -\ Shorts/elephantsdream-1920-hd-mpeg4-su-ac3.avi
mediainfo = /opt/bin/mediainfo
mplayer   = /usr/local/bin/mplayer
ffmpeg    = /usr/local/bin/ffmpeg
convert   = /opt/bin/convert
montage   = /opt/bin/montage
Retrieving video details...
  --> file size = 260.777 MiB
  --> duration = 653 seconds
  --> resolution = 1920x1080 pixels
  --> video codec = S-Mpeg 4 v2
  --> audio codec = AC-3
  --> frame rate = 24.000
  --> frame count = 15691
  --> display aspect ratio = 16:9
AVI: ODML: Broken (incomplete?) file detected. Will use traditional index.
  --> printed duration = 00:02:32
  --> printed frame rate = 24.000
Generating video info...
  --> field values
  --> field labels
Extracting screen #1 (00:00:15)...
Extracting screen #2 (00:00:30)...
Extracting screen #3 (00:00:45)...
Extracting screen #4 (00:01:00)...
Extracting screen #5 (00:01:16)...
Extracting screen #6 (00:01:31)...
Extracting screen #7 (00:01:46)...
Extracting screen #8 (00:02:01)...
Extracting screen #9 (00:02:16)...
Building final overview image (using +/-append) ...
real    0m 17.08s
user    0m 15.57s
sys     0m 1.09s


For a comparison I tried the same script (modifying some paths only) on a Quad-Core Linux PC. After 5 runs it had the video file almost completely in file cache so almost no NFS overhead is involved:
Code: Select all
ancoron@quadcore:~$ time imagegrabber-busybox -big -fast -idx /net/diskstation/video/Animations\ -\ Shorts/elephantsdream-1920-hd-mpeg4-su-ac3.avi
mediainfo = /usr/bin/mediainfo
mplayer   = /usr/bin/mplayer
ffmpeg    = /usr/bin/ffmpeg
convert   = /usr/bin/convert
montage   = /usr/bin/montage
Retrieving video details...
  --> file size = 260.777 MiB
  --> duration = 653 seconds
  --> resolution = 1920x1080 pixels
  --> video codec = S-Mpeg 4 v2
  --> audio codec = AC-3
  --> frame rate = 24.000
  --> frame count = 15691
  --> display aspect ratio = 16:9
AVI: ODML: Broken (incomplete?) file detected. Will use traditional index.
  --> printed duration = 00:02:32
  --> printed frame rate = 24.000
Generating video info...
  --> field values
  --> field labels
Extracting screen #1 (00:00:15)...
Extracting screen #2 (00:00:30)...
Extracting screen #3 (00:00:45)...
Extracting screen #4 (00:01:00)...
Extracting screen #5 (00:01:16)...
Extracting screen #6 (00:01:31)...
Extracting screen #7 (00:01:46)...
Extracting screen #8 (00:02:01)...
Extracting screen #9 (00:02:16)...
Building final overview image (using +/-append) ...

real    0m19.457s
user    0m42.690s
sys     0m0.670s


Well, that's nice. :-)

mediainfo

Compiling mediainfo was just straight forward as it doesn't have any external dependency. I just had to add some options for cross-compiling and disabling parallel make:
Code: Select all
CONFIG_OPTS="--host=powerpc-unknown-linux --target=powerpc-unknown-linux --build=i686-pc-linux --prefix=/usr/local"
ZenLib_Options=""

CC=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-gcc
export CC
CXX=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-g++
export CXX
LD=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ld
export LD
RANLIB=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ranlib
export RANLIB
CFLAGS="-I/usr/local/powerpc-linux-gnuspe/include -mcpu=8548 -mhard-float -mfloat-gprs=double"
export CFLAGS
CXXFLAGS="$CFLAGS"
export CXXFLAGS
LDFLAGS="-L/usr/local/powerpc-linux-gnuspe/lib"
export LDFLAGS

#############################################################################
# Setup for parallel builds
Zen_Make()
{
 make
}


Just make sure to include the custom configure options:
Code: Select all
./configure $ZenLib_Options $CONFIG_OPTS $*


ffmpeg

Compiling ffmpeg required some other libraries and header files obtained through IPKG. But in the end it was very straight forward too:
Code: Select all
./configure --enable-cross-compile --disable-altivec --cross-prefix=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe- --arch=powerpc --prefix=/usr/local --extra-cflags="-I/usr/local/powerpc-linux-gnuspe/opt/include -I/usr/local/powerpc-linux-gnuspe/include -mcpu=8548 -mhard-float -mfloat-gprs=double" --extra-ldflags="-L/usr/local/powerpc-linux-gnuspe/opt/lib -L/usr/local/powerpc-linux-gnuspe/lib -R/usr/local/lib:/opt/lib" --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libxvid --disable-ffserver --disable-ffplay --disable-network --disable-devices --disable-vhook


This is against which libraries my ffmpeg is linked:
Code: Select all
diskstation> sh /root/ldd /usr/local/bin/ffmpeg
        libavfilter.so.0 => /usr/local/lib/libavfilter.so.0 (0x0ffdb000)
        libpostproc.so.51 => /usr/local/lib/libpostproc.so.51 (0x0ffb1000)
        libswscale.so.0 => /usr/local/lib/libswscale.so.0 (0x0ff6a000)
        libavdevice.so.52 => /usr/local/lib/libavdevice.so.52 (0x0ff48000)
        libavformat.so.52 => /usr/local/lib/libavformat.so.52 (0x0fe36000)
        libavcodec.so.52 => /usr/local/lib/libavcodec.so.52 (0x0f7be000)
        libavutil.so.49 => /usr/local/lib/libavutil.so.49 (0x0f78b000)
        libm.so.6 => /lib/libm.so.6 (0x0f6e8000)
        libc.so.6 => /lib/libc.so.6 (0x0f58a000)
        libz.so.1 => /opt/lib/libz.so.1 (0x0f557000)
        libbz2.so.1.0 => /opt/lib/libbz2.so.1.0 (0x0f524000)
        libmp3lame.so.0 => /opt/lib/libmp3lame.so.0 (0x0f48e000)
        libvorbisenc.so.2 => /opt/lib/libvorbisenc.so.2 (0x0f378000)
        libvorbis.so.0 => /opt/lib/libvorbis.so.0 (0x0f32b000)
        libxvidcore.so.4 => /opt/lib/libxvidcore.so.4 (0x0f221000)
        /lib/ld.so.1 (0x30000000)
        libogg.so.0 => /opt/lib/libogg.so.0 (0x0f1fb000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x0f18a000)



mplayer

Mplayer is a bit of a beast when it comes to cross-compiling as its configure script doesn't provide parameters for separate host and target gcc. Therefore I just configured mplayer for the target:
Code: Select all
./configure --prefix=/usr/local --disable-vm --disable-xf86keysym --disable-tv --enable-rpath --enable-cross-compile --cc=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-gcc --as=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-as --nm=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-nm --ar=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ar --ranlib=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ranlib --target=powerpc-unknown-linux --extra-cflags="-I/usr/local/powerpc-linux-gnuspe/opt/include -I/usr/local/powerpc-linux-gnuspe/include -mcpu=8548 -mhard-float -mfloat-gprs=double" --extra-ldflags="-L/usr/local/powerpc-linux-gnuspe/lib -L/usr/local/powerpc-linux-gnuspe/opt/lib -R/usr/local/lib:/opt/lib" --enable-png --enable-jpeg


After that don't just run make, as this won't work. I had to modify the generated config.mak file to use the correct host gcc and to disable stripping:
Code: Select all
HOST_CC = gcc
...
INSTALLSTRIP =


But after that change make && make install just went through (although I encountered a lot of compile warnings). The output of ldd on the syno box shows up like this:
Code: Select all
diskstation> sh /root/ldd /usr/local/bin/mplayer
        libjpeg.so.62 => /opt/lib/libjpeg.so.62 (0x0ffbc000)
        libfreetype.so.6 => /opt/lib/libfreetype.so.6 (0x0ff24000)
        libfontconfig.so.1 => /opt/lib/libfontconfig.so.1 (0x0fed1000)
        libbz2.so.1.0 => /opt/lib/libbz2.so.1.0 (0x0fe9e000)         
        libxvidcore.so.4 => /opt/lib/libxvidcore.so.4 (0x0fd94000)
        libm.so.6 => /lib/libm.so.6 (0x0fcf1000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x0fc80000)
        libdl.so.2 => /lib/libdl.so.2 (0x0fc5d000)
        libmp3lame.so.0 => /opt/lib/libmp3lame.so.0 (0x0fbc7000)
        libc.so.6 => /lib/libc.so.6 (0x0fa69000)
        libz.so => /opt/lib/libz.so (0x0fa36000)
        libexpat.so.1 => /opt/lib/libexpat.so.1 (0x0f9f0000)
        /lib/ld.so.1 (0x30000000)


If anyone needs further instructions please don't hesitate.

Ancoron
Ancoron
Beginner
Beginner
 
Posts: 22
Joined: Wed Jul 15, 2009 9:52 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby Ancoron » Fri Jan 29, 2010 3:58 am

Just installed a lot of other libraries trough ipkg and recompiled mplayer with a slightly different configuration:
Code: Select all
PKG_CONFIG_PATH=/usr/local/powerpc-linux-gnuspe/opt/lib/pkgconfig
export PKG_CONFIG_PATH

./configure --prefix=/usr/local --enable-rpath --enable-cross-compile --host-cc=/usr/bin/gcc --cc=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-gcc --as=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-as --nm=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-nm --ar=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ar --ranlib=/usr/local/powerpc-linux-gnuspe/bin/powerpc-linux-gnuspe-ranlib --target=powerpc-unknown-linux --extra-cflags="-I/usr/local/powerpc-linux-gnuspe/powerpc-linux-gnuspe/sys-include -I/usr/local/powerpc-linux-gnuspe/include -I/usr/local/powerpc-linux-gnuspe/opt/include -mcpu=8548 -mhard-float -mfloat-gprs=double" --extra-ldflags="-L/usr/local/powerpc-linux-gnuspe/lib -L/usr/local/powerpc-linux-gnuspe/opt/lib -R/usr/local/lib:/opt/lib" --enable-png --enable-jpeg

sed -ie 's/^INSTALLSTRIP = .*$/INSTALLSTRIP = /g' config.mak


Now it uses the correct host GCC and with the help of PKG_CONFIG_PATH it also finds the correct includes and linking options for enabling e.g. theora support.

The configuration script now outputs this:
Code: Select all
  Install prefix: /usr/local
  Data directory: /usr/local/share/mplayer
  Config direct.: /usr/local/etc/mplayer 

  Byte order: big-endian
  Optimizing for:

  Languages:
    Messages/GUI: en
    Manual pages: en
    Documentation: en

  Enabled optional drivers:
    Input: ftp tv cddb cdda dvb network
    Codecs: xvid libavcodec(internal) xanim faad2(internal) musepack libmpeg2(internal) liba52(external) mp3lib(internal) libtheora speex tremor(internal) libmad
    Audio output: oss mpegpes(dvb)
    Video output: pnm jpeg mpegpes(dvb) yuv4mpeg md5sum tga

  Disabled optional drivers:
    Input: dvdnav vstream pvr radio tv-v4l2 tv-v4l1 tv-dshow live555 nemesi libdvdcss(internal) dvdread vcd smb
    Codecs: libschroedinger libdirac x264 libdv libopencore_amrwb libopencore_amrnb qtx real win32 faac libdca toolame twolame liblzo gif OpenJPEG
    Audio output: sun alsa openal jack pulse nas esd arts v4l2 ivtv dxr2 sdl
    Video output: zr zr2 v4l2 ivtv dxr3 dxr2 sdl vesa gif89a matrixview opengl fbdev svga caca aa ggi xmga mga xvidix winvidix cvidix 3dfx dga vdpau xvmc xv x11 dfbmga directfb bl xvr100 tdfx_vid wii s3fb tdfxfb


...and an ldd on the syno box yields the correct linking:
Code: Select all
diskstation> sh root/ldd /usr/local/bin/mplayer
        libjpeg.so.62 => /opt/lib/libjpeg.so.62 (0x0ffbc000)
        libcdio_cdda.so.0 => /opt/lib/libcdio_cdda.so.0 (0x0ff93000)
        libcdio.so.7 => /opt/lib/libcdio.so.7 (0x0ff52000)
        libcdio_paranoia.so.0 => /opt/lib/libcdio_paranoia.so.0 (0x0ff29000)
        libfreetype.so.6 => /opt/lib/libfreetype.so.6 (0x0fe91000)
        libfontconfig.so.1 => /opt/lib/libfontconfig.so.1 (0x0fe3e000)
        libbz2.so.1.0 => /opt/lib/libbz2.so.1.0 (0x0fe0b000)
        libmad.so.0 => /opt/lib/libmad.so.0 (0x0fdd4000)
        libspeex.so.1 => /opt/lib/libspeex.so.1 (0x0fd99000)
        libtheora.so.0 => /opt/lib/libtheora.so.0 (0x0fd3d000)
        libogg.so.0 => /opt/lib/libogg.so.0 (0x0fd17000)
        liba52.so.0 => /opt/lib/liba52.so.0 (0x0fce8000)
        libmpcdec.so.5 => /opt/lib/libmpcdec.so.5 (0x0fcb9000)
        libxvidcore.so.4 => /opt/lib/libxvidcore.so.4 (0x0fbaf000)
        libm.so.6 => /lib/libm.so.6 (0x0fb0c000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x0fa9b000)
        libdl.so.2 => /lib/libdl.so.2 (0x0fa78000)
        libmp3lame.so.0 => /opt/lib/libmp3lame.so.0 (0x0f9e2000)
        libc.so.6 => /lib/libc.so.6 (0x0f884000)
        libz.so => /opt/lib/libz.so (0x0f851000)
        libexpat.so.1 => /opt/lib/libexpat.so.1 (0x0f80b000)
        /lib/ld.so.1 (0x30000000)


So there is a lot of power in the ipkg's currently available. The only thing that powerpc really lacks of are the win32 codecs that are not available for this architecture yet. But that doesn't stop mplayer from playing e.g. WMV files correctly.

With the latest build I've verified that this version can deal with almost all formats (well, as I don't have any crappy Real-thing here I can't test that). At least the following formats (including various codecs) are fine: avi, mkv, wmv, flv, mov, mp4, mpg, mpeg, vob.

I have yet a single file to find where this mplayer fails.

Ancoron

P.S.: My next task will be to enable x264 de-/encoding support. After that I'll try to find out why dvdnav support is not enabled although we have the libraries.
Ancoron
Beginner
Beginner
 
Posts: 22
Joined: Wed Jul 15, 2009 9:52 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby blouz » Mon Feb 08, 2010 1:00 pm

Thanks for all these informations.
Let us know if you manage to get x264 !
blouz
Beginner
Beginner
 
Posts: 27
Joined: Fri Nov 20, 2009 2:15 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby Ancoron » Fri Feb 19, 2010 11:34 pm

Unfortunately the x264 devs are not that responsive in this case.

I took a look into their source code and they seem to strictly depend on the AltiVec extensions on PowerPC architecture which we don't have.

I asked them on their developers mailing list but didn't get any response yet. So I'm afraid we might never see x264 encoding support on our boxes.

Ancoron
Ancoron
Beginner
Beginner
 
Posts: 22
Joined: Wed Jul 15, 2009 9:52 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby Ancoron » Wed Sep 01, 2010 6:12 pm

For anyone interested, here's the script I used to get video overview screens.

For this script to work you'll have to install at least the ImageMagick using ipkg and maybe others as I use a lot of awk/egrep/sed here.

Code: Select all
#!/bin/sh
NUM_PIC=
COLS=""
FILE=""
THUMB_W=160
# MEDIAINFO=""
MEDIAINFO="`which mediainfo`"
OUTPUT="screens.jpg"
USE_ALTERNATIVE=""
TRY_FFMPEG=""
O_FPS=
AUTO=
LABEL_TIME="%c"
SPACING="2+2"
SHADOW="-shadow"
NORMALIZE=""
DEBUG_LOG="imagegrabber_debug.log"
CMD_LOG="imagegrabber_commands.log"
TMP_DIR=/volume1/@tmp/imagegrabber

IM_EXT="mpc"
FRAME_EXT="png"

DEBUG=""
FAST=""
IDX=""

META=0

while [ -n "$1" ]; do
   case "$1" in
      -n)
         shift
         NUM_PIC=$1
         ;;
      -std)
         # standard...
         THUMB_W=180
         COLS="-tile 4x"
         AUTO=1
         META=1
         ;;
      -big)
         # big...
         THUMB_W=250
         COLS="-tile 3x"
         AUTO=1
         META=2
         ;;
      -small)
         # small...
         THUMB_W=120
         COLS="-tile 5x"
         AUTO=1
         META=3
         ;;
      -w)
         shift
         THUMB_W=$1
         ;;
      -c)
         shift
         COLS="-tile ${1}x"
         ;;
      -o)
         shift
         OUTPUT="$1"
         ;;
      -ofps)
         shift
         O_FPS=$1
         ;;
      -x)
         USE_ALTERNATIVE="1"
         ;;
      -mplayer)
         MEDIAINFO=""
         ;;
      -notime)
         LABEL_TIME=""
         ;;
      -noshadow)
         SPACING="1+1"
         SHADOW=""
         ;;
      -normalize)
         NORMALIZE="-normalize"
         ;;
      -debug)
         DEBUG="true"
         ;;
      -idx)
         IDX="-idx"
         ;;
      -fast)
         FAST="true"
         ;;
      *)
         FILE="$@"
         ;;
   esac
   shift
done

ext="`echo "$FILE" | sed -ne 's/^.*\.\(avi\|wmv\|m4v\|flv\|mov\|mkv\|divx\|mpg\|mpeg\)$/\1/Igp'`"
base="`basename "$FILE" ".$ext"`"

if [ -n "$AUTO" -a "$OUTPUT" = "screens.jpg" ]; then
   OUTPUT="screens_$base.jpg"
fi

export LD_LIBRARY_PATH="/usr/local/lib:/opt/lib"

MEDIAINFO=`which mediainfo`
MPLAYER=/usr/local/bin/mplayer
FFMPEG=/usr/local/bin/ffmpeg
CONVERT=`which convert`
MONTAGE=`which montage`

echo "mediainfo = $MEDIAINFO"
echo "mplayer   = $MPLAYER"
echo "ffmpeg    = $FFMPEG"
echo "convert   = $CONVERT"
echo "montage   = $MONTAGE"

if [ -z "$FILE" ]; then
   echo "Please specify a file name"
   exit 1
fi

getDisplayTime()
{
   seconds=$1
   str=""
   rest=0
   if [ -z "$seconds" ]; then
      echo "00:00:00"
      return
   fi

   if [ "$seconds" -ge "60" ]; then
      rest=`echo "$seconds % 60" | bc`
      str="$rest"
      [ "$rest" -gt "9" ] || str="0$rest"
      seconds=`echo "($seconds - $rest) / 60" | bc`
   else
      str="$seconds"
      [ "$seconds" -gt "9" ] || str="0$seconds"
      seconds=0
   fi

   str=":$str"

   if [ "$seconds" -ge "60" ]; then
      rest=`echo "$seconds % 60" | bc`
      str="${rest}${str}"
      [ "$rest" -gt "9" ] || str="0${str}"
      seconds=`echo "($seconds - $rest) / 60" | bc`
   else
      str="${seconds}${str}"
      [ "$seconds" -gt "9" ] || str="0${str}"
      seconds=0
   fi

   str=":$str"

   str="${seconds}${str}"
   [ "$seconds" -gt "9" ] || str="0${str}"

   echo "$str"
}

getTime()
{
   echo "`date +'%Y-%m-%d %H:%M:%S.%N'`"
}

[ ! -d "$TMP_DIR" ] || rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"

echo "" > "$DEBUG_LOG"
echo "" > "$CMD_LOG"

echo "Retrieving video details..."
filename=`basename "$FILE"`

filesize=`du -k "$FILE" | sed -e 's/^\([0-9]*\).*$/\1/g'`
size_b=$filesize
x=0
while [ "`echo "$filesize / 1024" | bc`" -ge "1" -a "$x" -lt "5" ]; do
   filesize=`echo "scale=3;$filesize / 1024" | bc`
   x=`echo "$x+1" | bc`
done
if [ "$x" -eq "0" ]; then
   filesize="$filesize KiB"
elif [ "$x" -eq "1" ]; then
   filesize="$filesize MiB"
elif [ "$x" -eq "2" ]; then
   filesize="$filesize GiB"
elif [ "$x" -eq "3" ]; then
   filesize="$filesize TiB"
elif [ "$x" -eq "4" ]; then
   filesize="$filesize PiB"
fi

echo "  --> file size = $filesize"

duration="0s"
ds=0
width=0
height=0
fps=0
ac="unknown"
vc="unknown"
framecount=0
mds=0
asr=""

if [ -n "$MEDIAINFO" ]; then
   # use mediainfo...
   echo "[`getTime`] $MEDIAINFO -F \"$FILE\"" >>"$CMD_LOG"
   mi="`$MEDIAINFO -F "$FILE"`"
   ds=`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==1 && $1 ~ /Duration/ && $2 ~ /^[0-9]+$/) {print $2}}'`
   ds=`echo "$ds / 1000" | bc`
   echo "  --> duration = $ds seconds"
   width=`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Width[ ]*$/ && $2 ~ /^[0-9]+$/) {print $2}}'`
   height=`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Height[ ]*$/ && $2 ~ /^[0-9]+$/) {print $2}}'`
   echo "  --> resolution = ${width}x${height} pixels"
   vc="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==1 && $1 ~ /^Video_Format_WithHint_List[ ]*$/) {print $2}}'`"
   [ -n "$vc" ] || vc="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Codec ID\/Hint[ ]*$/) {print $2}}'`"
   [ -n "$vc" ] || vc="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Codec ID\/Info[ ]*$/) {print $2}}'`"
   [ -n "$vc" ] || vc="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Writing library\/Name[ ]*$/) {print $2}}'`"
   echo "  --> video codec = ${vc}"
   ac="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==1 && $1 ~ /^Audio_Format_WithHint_List[ ]*$/) {print $2}}'`"
   [ -n "$ac" ] || ac="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==3 && $1 ~ /^Codec ID\/Hint[ ]*$/) {print $2}}'`"
   [ -n "$ac" ] || ac="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==3 && $1 ~ /^Codec ID\/Info[ ]*$/) {print $2}}'`"
   [ -n "$ac" ] || ac="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==3 && $1 ~ /^Format[ ]*$/) {print $2}}'`"
   acount=`echo "$ac" | wc -l`
   if [ "$acount" -gt "1" ]; then
      # handle multiple audio streams...
      tmpn=1
      tmpac="`echo "$ac" | head -1`"
      while [ "$tmpn" -lt "$acount" ]; do
         tmp="`echo "$ac" | head -$tmpn | tail -1`"
         tmpac="$tmpac / $tmp"
      done
   fi
   echo "  --> audio codec = ${ac}"
   fps="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Frame rate[ ]*$/ && $2 ~ /^[0-9]+\.[0-9]+$/) {print $2}}'`"
   echo "  --> frame rate = ${fps}"
   framecount=`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Frame count[ ]*$/ && $2 ~ /^[0-9]+$/) {print $2}}'`
   echo "  --> frame count = ${framecount}"
   asr="`echo "$mi" | awk 'BEGIN {FS=" : "; s=0;} /^General$/ {s=1} /^Video$/ {s=2} /^Audio( #[0-9]*)?$/ {s=3} {if(s==2 && $1 ~ /^Display aspect ratio[ ]*$/ && $2 ~ /^[0-9\.]+:[0-9\.]+$/) {print $2}}'`"
   echo "  --> display aspect ratio = ${asr}"
   [ -z "$asr" ] || asr=" ($asr)";
else
   # use mplayer -identify...
   echo "[`getTime`] mplayer -nolirc -noconfig all -vo null -ao null -frames 0 -msglevel identify=6 \"$FILE\" | egrep '^(Selected (audio|video) codec|(ID_.*=[^0]))'" >>"$CMD_LOG"
   $MPLAYER -nolirc -noconfig all $IDX -vo null -ao null -frames 0 -msglevel identify=6 "$FILE" | egrep '^(Selected (audio|video) codec|(ID_.*=[^0]))' > "${TMP_DIR}/ig_info.txt"
   ds=`sed -ne 's/^ID_LENGTH=\([0-9]*\).*$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   echo "  --> duration = $ds seconds"
   width=`sed -ne 's/^ID_VIDEO_WIDTH=\([0-9]*\).*$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   height=`sed -ne 's/^ID_VIDEO_HEIGHT=\([0-9]*\).*$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   echo "  --> resolution = ${width}x${height} pixels"
   vc=`sed -ne 's/^Selected video codec.\+: \(.*\)$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   echo "  --> video codec = ${vc}"
   ac=`sed -ne 's/^Selected audio codec.\+: \(.*\)$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   echo "  --> audio codec = ${ac}"
   fps=`sed -ne 's/^ID_VIDEO_FPS=\(.*\)$/\1/gp' "${TMP_DIR}/ig_info.txt"`
   echo "  --> frame rate = ${fps}"
   echo "[`getTime`] mplayer -nolirc -noconfig all -nosound -vo null -benchmark \"$FILE\" | sed -ne 's/^V: .* \([0-9]\+\)\/[0-9]\+.*$/\1/gp'" >>"$CMD_LOG"
   framecount=`$MPLAYER -nolirc -noconfig all $IDX -nosound -vo null -benchmark "$FILE" | sed -ne 's/^V: .* \([0-9]\+\)\/[0-9]\+.*$/\1/gp'`
   echo "  --> frame count = ${framecount}"
fi

mds=`$MPLAYER -nolirc -noconfig all $IDX -vo null -nosound -frames 0 -msglevel identify=6 "$FILE" | sed -ne 's/^ID_LENGTH=\([0-9]*\).*$/\1/gp'`

if [ -z "$mds" ]; then
   echo "WARNING: mplayer failed!"
   TRY_FFMPEG="true"
   echo "[`getTime`] $FFMPEG -i \"$FILE\" 2>&1 | sed -ne 's/^[ ]*Duration: \([0-9]*:[0-9]*:[0-9]*\).*$/\1/gp' | sed -e 's/^\([0-9]*\):\([0-9]*\):\([0-9]*\)$/3600 * \1 + 60 * \2 + \3/g' | bc" >>"$CMD_LOG"
   mds=`$FFMPEG -i "$FILE" 2>&1 | sed -ne 's/^[ ]*Duration: \([0-9]*:[0-9]*:[0-9]*\).*$/\1/gp' | sed -e 's/^\([0-9]*\):\([0-9]*\):\([0-9]*\)$/3600 * \1 + 60 * \2 + \3/g' | bc`
fi

if [ -n "$mds" ]; then
   [ "$mds" -eq "$ds" ] || ds=$mds
else
   echo "ERROR: neither mplayer nor ffmpeg are working correctly"
   exit 2
fi

duration="`getDisplayTime $ds`"
echo "  --> printed duration = $duration"

[ -z "$O_FPS" ] || fps=$O_FPS
echo "  --> printed frame rate = $fps"

if [ -n "$AUTO" -a -z "$NUM_PIC" ]; then
   # calculate number of frames to grab...
   case $META in
      2)
         # tile 3x
         if [ "$ds" -lt "60" ]; then
            NUM_PIC=3
         elif [ "$ds" -lt "120" ]; then
            NUM_PIC=6
         elif [ "$ds" -lt "600" ]; then
            NUM_PIC=9
         elif [ "$ds" -lt "900" ]; then
            NUM_PIC=12
         elif [ "$ds" -lt "1800" ]; then
            NUM_PIC=18
         elif [ "$ds" -lt "3600" ]; then
            NUM_PIC=24
         elif [ "$ds" -lt "7200" ]; then
            NUM_PIC=33
         else
            # maximum...
            NUM_PIC=39
         fi
         ;;
      3)
         # tile 5x
         if [ "$ds" -lt "60" ]; then
            NUM_PIC=5
         elif [ "$ds" -lt "120" ]; then
            NUM_PIC=10
         elif [ "$ds" -lt "600" ]; then
            NUM_PIC=15
         elif [ "$ds" -lt "900" ]; then
            NUM_PIC=20
         elif [ "$ds" -lt "1800" ]; then
            NUM_PIC=30
         elif [ "$ds" -lt "3600" ]; then
            NUM_PIC=50
         elif [ "$ds" -lt "7200" ]; then
            NUM_PIC=70
         else
            # maximum...
            NUM_PIC=100
         fi
         ;;
      *)
         # tile 4x
         if [ "$ds" -lt "60" ]; then
            NUM_PIC=4
         elif [ "$ds" -lt "120" ]; then
            NUM_PIC=8
         elif [ "$ds" -lt "600" ]; then
            NUM_PIC=12
         elif [ "$ds" -lt "900" ]; then
            NUM_PIC=16
         elif [ "$ds" -lt "1800" ]; then
            NUM_PIC=20
         elif [ "$ds" -lt "3600" ]; then
            NUM_PIC=24
         elif [ "$ds" -lt "7200" ]; then
            NUM_PIC=32
         else
            # maximum...
            NUM_PIC=36
         fi
         ;;
   esac
elif [ -z "$NUM_PIC" ]; then
   NUM_PIC=12
fi

echo "Generating video info..."
echo "  --> field values"
echo "[`getTime`] $CONVERT -gravity east -background White -fill black -font Helvetica -pointsize 12 label:\"file: \\nsize: \\nduration: \\nresolution: \\nframe rate: \\nvideo: \\naudio: \" \"${TMP_DIR}/ig_info_left.$IM_EXT\"" >>"$CMD_LOG"
$CONVERT -gravity east -background White -fill black -font Helvetica -pointsize 12 label:"file: \nsize: \nduration: \nresolution: \nframe rate: \nvideo: \naudio: " "${TMP_DIR}/ig_info_left.$IM_EXT"
echo "  --> field labels"
echo "[`getTime`] $CONVERT -gravity west -background White -fill black -font Helvetica -pointsize 12 label:\"$filename\n$filesize\n$duration\n${width}x${height}${asr}\n$fps\n$vc\n$ac\" \"${TMP_DIR}/ig_info_right.$IM_EXT\"" >>"$CMD_LOG"
$CONVERT -gravity west -background White -fill black -font Helvetica -pointsize 12 label:"$filename\n$filesize\n$duration\n${width}x${height}${asr}\n$fps\n$vc\n$ac" "${TMP_DIR}/ig_info_right.$IM_EXT"
# $CONVERT -splice 20x10 -background none -fill black -font Helvetica -pointsize 14 label:"file: $filename\nsize: $filesize\nlength: $duration\ndimensions: ${width}x${height}\nvideo: $vc\naudio: $ac" "${TMP_DIR}/ig_info.png"
# $MONTAGE -title '' -label '' "${TMP_DIR}/ig_info_left.$IM_EXT" "${TMP_DIR}/ig_info_right.$IM_EXT" -tile x1 -mode Concatenate -background none "${TMP_DIR}/ig_info_tmp.$IM_EXT"
echo "[`getTime`] $CONVERT \"${TMP_DIR}/ig_info_left.$IM_EXT\" \"${TMP_DIR}/ig_info_right.$IM_EXT\" +append -background White \"${TMP_DIR}/ig_info_tmp.$IM_EXT\"" >>"$CMD_LOG"
$CONVERT "${TMP_DIR}/ig_info_left.$IM_EXT" "${TMP_DIR}/ig_info_right.$IM_EXT" +append -background White "${TMP_DIR}/ig_info_tmp.$IM_EXT"
echo "[`getTime`] $CONVERT \"${TMP_DIR}/ig_info_tmp.$IM_EXT\" -bordercolor White -border 20x10 -background White \"${TMP_DIR}/ig_info.$IM_EXT\"" >>"$CMD_LOG"
$CONVERT "${TMP_DIR}/ig_info_tmp.$IM_EXT" -bordercolor White -border 20x10 -background White "${TMP_DIR}/ig_info.$IM_EXT"

num=0
screens=""
if [ -n "$TRY_FFMPEG" ]; then
   # ffmpeg needs a height...
   THUMB_H=`echo "$THUMB_W * $height / $width" | bc`
   # ffmpeg requires width & height to be multiple of 2...
   [ "`echo "$THUMB_H % 2" | bc`" -eq "0" ] || THUMB_H=`echo "$THUMB_H + 1" | bc`

   if [ -z "$USE_ALTERNATIVE" ]; then
      while [ "$num" -lt "$NUM_PIC" ] ; do
         num=`echo "$num + 1" | bc`
         FRAME=`echo "$ds * $num/($NUM_PIC + 1)" | bc`
         echo "Extracting screen #$num (`getDisplayTime $FRAME`, using ffmpeg)..."
         echo "[`getTime`] $FFMPEG -y -ss $FRAME -vframes 1 -an -i \"$FILE\" -f image2 -s ${THUMB_W}x${THUMB_H} $TMP_DIR/00%06d.$FRAME_EXT" >>"$CMD_LOG"
         $FFMPEG -y -ss $FRAME -vframes 1 -an -i "$FILE" -f image2 -s ${THUMB_W}x${THUMB_H} $TMP_DIR/00%06d.$FRAME_EXT >>"$DEBUG_LOG" 2>&1
         numStr="$num"
         [ "$num" -gt "9" ] || numStr="0$numStr"
         [ "$num" -gt "99" ] || numStr="0$numStr"
         echo "[`getTime`] $CONVERT \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 \"`getDisplayTime $FRAME`\" -stroke none -fill White -annotate 0 \"`getDisplayTime $FRAME`\" -bordercolor Black -border 1x1 -background White -gravity center -extent `echo "${THUMB_W} + 6" | bc`x`echo "${THUMB_H} + 6" | bc` \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
         $CONVERT "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -gravity southeast -geometry +3+3 -stroke '#0008' -strokewidth 2 -annotate 0 "`getDisplayTime $FRAME`" -stroke none -fill '#FFFB' -annotate 0 "`getDisplayTime $FRAME`" -bordercolor Black -border 1x1 -background White -gravity center -extent `echo "${THUMB_W} + 6" | bc`x`echo "${THUMB_H} + 6" | bc` "${TMP_DIR}/ig_${numStr}.$IM_EXT"
         screens="$screens ${TMP_DIR}/ig_${numStr}.$IM_EXT"
      done
   else
      echo "Extracting ${NUM_PIC} frames, using ffmpeg ..."
      x="`echo "($NUM_PIC + 1) / $framecount" | bc -l | xargs printf "%1.9f"`"
      echo "[`getTime`] $FFMPEG -y -an -r $x -s ${THUMB_W}x${THUMB_H} -i \"$FILE\" -f image2 $TMP_DIR/00%06d.$FRAME_EXT" >>"$CMD_LOG"
      $FFMPEG -y -an -r $x -s ${THUMB_W}x${THUMB_H} -i "$FILE" -f image2 $TMP_DIR/00%06d.$FRAME_EXT >>"$DEBUG_LOG" 2>&1
      while [ "$num" -lt "$NUM_PIC" ] ; do
         num=`echo "$num + 1" | bc`
         FRAME=`echo "$ds * $num/($NUM_PIC + 1)" | bc`
         numStr="`echo "$num + 1" | bc`"
         [ "$num" -gt "8" ] || numStr="0$numStr"
         [ "$num" -gt "98" ] || numStr="0$numStr"
         echo "[`getTime`] $CONVERT -comment \"`getDisplayTime $FRAME`\" \"${TMP_DIR}/00000${numStr}.$FRAME_EXT\" ${NORMALIZE} \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
         $CONVERT -comment "`getDisplayTime $FRAME`" "${TMP_DIR}/00000${numStr}.$FRAME_EXT" ${NORMALIZE} "${TMP_DIR}/ig_${numStr}.$IM_EXT"
         screens="$screens ${TMP_DIR}/ig_${numStr}.$IM_EXT"
      done
   fi
elif [ -n "$USE_ALTERNATIVE" ]; then
   echo "Extracting ${NUM_PIC} frames ..."
   x=`echo "$framecount / ($NUM_PIC + 1)" | bc`
   echo "[`getTime`] $MPLAYER -nolirc -noconfig all -vo png:outdir=$TMP_DIR -nosound -vf scale=${THUMB_W}:-2,framestep=$x -benchmark \"$FILE\"" >>"$CMD_LOG"
   $MPLAYER -nolirc -noconfig all $IDX -vo png:z=1:outdir=$TMP_DIR -nosound -vf scale=${THUMB_W}:-2,framestep=$x -benchmark "$FILE" >>"$DEBUG_LOG"
   while [ "$num" -lt "$NUM_PIC" ] ; do
      num=`echo "$num + 1" | bc`
      FRAME=`echo "$ds * $num/($NUM_PIC + 1)" | bc`
      numStr="`echo "$num + 1" | bc`"
      [ "$num" -gt "8" ] || numStr="0$numStr"
      [ "$num" -gt "98" ] || numStr="0$numStr"
      echo "[`getTime`] $CONVERT -comment \"`getDisplayTime $FRAME`\" \"${TMP_DIR}/00000${numStr}.$FRAME_EXT\" ${NORMALIZE} \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
      $CONVERT -comment "`getDisplayTime $FRAME`" "${TMP_DIR}/00000${numStr}.$FRAME_EXT" ${NORMALIZE} "${TMP_DIR}/ig_${numStr}.$IM_EXT"
      screens="$screens ${TMP_DIR}/ig_${numStr}.$IM_EXT"
   done
else
   while [ "$num" -lt "$NUM_PIC" ] ; do
      num=`echo "$num + 1" | bc`
      FRAME=`echo "$ds * $num/($NUM_PIC + 1)" | bc`
      timeStr="`getDisplayTime $FRAME`"
      echo "Extracting screen #$num ($timeStr)..."
      echo "[`getTime`] $MPLAYER -nolirc -noconfig all -vo png:outdir=$TMP_DIR -nosound -ss $FRAME -frames 1 -vf scale=${THUMB_W}:-2 \"$FILE\"" >>"$CMD_LOG"
      $MPLAYER -nolirc -noconfig all $IDX -vo png:z=1:outdir=$TMP_DIR -nosound -ss $FRAME -frames 1 -vf scale=${THUMB_W}:-2 "$FILE" >>"$DEBUG_LOG" 2>&1
      numStr="$num"
      [ "$num" -gt "9" ] || numStr="0$numStr"
      [ "$num" -gt "99" ] || numStr="0$numStr"
      if [ -z "$FAST" ]; then
         if [ -n "$LABEL_TIME" ]; then
            echo "[`getTime`] $CONVERT -comment \"$timeStr\" \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 \"$timeStr\" -stroke none -fill White -annotate 0 \"$timeStr\" \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
            $CONVERT -comment "$timeStr" "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -gravity southeast -stroke '#0006' -strokewidth 2 -annotate 0 "$timeStr" -stroke none -fill '#FFFA' -annotate 0 "$timeStr" "${TMP_DIR}/ig_${numStr}.$IM_EXT"
         else
            echo "[`getTime`] $CONVERT -comment \"$timeStr\" \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
            $CONVERT -comment "$timeStr" "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} "${TMP_DIR}/ig_${numStr}.$IM_EXT"
         fi
      else
         if [ -n "$LABEL_TIME" ]; then
            if [ -n "$SHADOW" ]; then
               if [ -f "${TMP_DIR}/ig_shadow.$IM_EXT" ]; then
                  echo "[`getTime`] $CONVERT \"${TMP_DIR}/ig_shadow.$IM_EXT\" \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -geometry +9+9 -composite -gravity southeast -stroke '#0006' -strokewidth 2 -annotate +11+11 "$timeStr" -stroke none -fill '#FFFD' -annotate +11+11 "$timeStr" \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
                  $CONVERT "${TMP_DIR}/ig_shadow.$IM_EXT" "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -geometry +9+9 -composite -gravity southeast -stroke '#0006' -strokewidth 2 -annotate +11+11 "$timeStr" -stroke none -fill '#FFFD' -annotate +11+11 "$timeStr" "${TMP_DIR}/ig_${numStr}.$IM_EXT"
               else
                  echo "[`getTime`] $CONVERT \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -gravity southeast -stroke '#0006' -strokewidth 2 -annotate +2+2 \"$timeStr\" -stroke none -fill '#FFFD' -annotate +2+2 \"$timeStr\" -page +4+4 -bordercolor Black -border 1x1 -matte '(' +clone -background Black -shadow 65x2+4+4 ')' +swap -background White -mosaic \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
                  $CONVERT "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -gravity southeast -stroke '#0006' -strokewidth 2 -annotate +2+2 "$timeStr" -stroke none -fill '#FFFD' -annotate +2+2 "$timeStr" -page +4+4 -bordercolor Black -border 1x1 -matte '(' +clone -background Black -shadow 65x2+4+4 ')' +swap -background White -mosaic "${TMP_DIR}/ig_${numStr}.$IM_EXT"
                  cp "${TMP_DIR}/ig_${numStr}.$IM_EXT" "${TMP_DIR}/ig_shadow.$IM_EXT"
                  if [ "$IM_EXT" = "mpc" ]; then
                     cp "${TMP_DIR}/ig_${numStr}.cache" "${TMP_DIR}/ig_shadow.cache"
                  fi
               fi
            else
               echo "[`getTime`] $CONVERT \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -gravity southeast -stroke '#0006' -strokewidth 2 -annotate 0 \"$timeStr\" -stroke none -fill '#FFFD' -annotate 0 \"$timeStr\" -bordercolor Black -border 1x1 -bordercolor White -border 2x2 \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
               $CONVERT "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -gravity southeast -stroke '#0006' -strokewidth 2 -annotate +2+2 "$timeStr" -stroke none -fill '#FFFD' -annotate +2+2 "$timeStr" -bordercolor Black -border 1x1 -bordercolor White -border 2x2 "${TMP_DIR}/ig_${numStr}.$IM_EXT"
            fi
         else
            if [ -n "$SHADOW" ]; then
               if [ -f "${TMP_DIR}/ig_shadow.$IM_EXT" ]; then
                  echo "[`getTime`] $CONVERT \"${TMP_DIR}/ig_shadow.$IM_EXT\" \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -geometry +5+5 -composite \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
                  $CONVERT "${TMP_DIR}/ig_shadow.$IM_EXT" "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -geometry +5+5 -composite "${TMP_DIR}/ig_${numStr}.$IM_EXT"
               else
                  echo "[`getTime`] $CONVERT \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -page +4+4 -bordercolor Black -border 1x1 -matte '(' +clone -background Black -shadow 65x2+4+4 ')' +swap -background White -mosaic \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
                  $CONVERT "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -page +4+4 -bordercolor Black -border 1x1 -matte '(' +clone -background Black -shadow 65x2+4+4 ')' +swap -background White -mosaic "${TMP_DIR}/ig_${numStr}.$IM_EXT"
                  cp "${TMP_DIR}/ig_${numStr}.$IM_EXT" "${TMP_DIR}/ig_shadow.$IM_EXT"
                  if [ "$IM_EXT" = "mpc" ]; then
                     cp "${TMP_DIR}/ig_${numStr}.cache" "${TMP_DIR}/ig_shadow.cache"
                  fi
               fi
            else
               echo "[`getTime`] $CONVERT \"${TMP_DIR}/00000001.$FRAME_EXT\" ${NORMALIZE} -bordercolor Black -border 1x1 -bordercolor White -border 2x2 \"${TMP_DIR}/ig_${numStr}.$IM_EXT\"" >>"$CMD_LOG"
               $CONVERT "${TMP_DIR}/00000001.$FRAME_EXT" ${NORMALIZE} -bordercolor Black -border 1x1 -bordercolor White -border 2x2 "${TMP_DIR}/ig_${numStr}.$IM_EXT"
            fi
         fi
      fi
      screens="$screens ${TMP_DIR}/ig_${numStr}.$IM_EXT"
   done
fi

if [ -n "$FAST" ]; then
   echo "Building final overview image (using +/-append) ..."
   COLS=`echo "$COLS" | sed -e 's/^\-tile \([1-9]\)x$/\1/g'`
   [ -n "$COLS" ] || COLS=4
   cn=0
   while [ "$cn" -lt "$COLS" ]; do
      # temporary file names 'ig_%03d.png' ...
      num=0
      imgcol=""
      for img in ${TMP_DIR}/ig_[0-9][0-9][0-9].$IM_EXT; do
         if [ "`echo "$num % $COLS" | bc`" -eq "$cn" ]; then
            # the right image for the column...
            imgcol="$imgcol $img"
         fi
         num=`echo "$num + 1" | bc`
      done
      echo "[`getTime`] $CONVERT $imgcol -append \"${TMP_DIR}/ig_col_${cn}.$IM_EXT\"" >>"$CMD_LOG"
      $CONVERT $imgcol -append "${TMP_DIR}/ig_col_${cn}.$IM_EXT"
      cn=`echo "$cn + 1" | bc`
   done
   echo "[`getTime`] $CONVERT ${TMP_DIR}/ig_info.$IM_EXT '(' ${TMP_DIR}/ig_col_[0-9].$IM_EXT +append ')' -append \"$OUTPUT\"" >>"$CMD_LOG"
   $CONVERT ${TMP_DIR}/ig_info.$IM_EXT -gravity west '(' ${TMP_DIR}/ig_col_[0-9].$IM_EXT +append ')' -append "$OUTPUT"
else
   echo "Building final overview image..."

   echo "[`getTime`] $MONTAGE -title '' -label '' $screens $COLS -geometry ${THUMB_W}x+${SPACING} -bordercolor black -border 1x1 -background none $SHADOW \"${TMP_DIR}/ig_screens.$IM_EXT\"" >>"$CMD_LOG"
   $MONTAGE -title '' -label '' $screens $COLS -geometry ${THUMB_W}x+${SPACING} -bordercolor black -border 1x1 -background none $SHADOW "${TMP_DIR}/ig_screens.$IM_EXT"

   echo "[`getTime`] $MONTAGE -title '' -label '' ${TMP_DIR}/ig_info.$IM_EXT ${TMP_DIR}/ig_screens.$IM_EXT -tile 1x -mode Concatenate -background white \"$OUTPUT\"" >>"$CMD_LOG"
   $MONTAGE -title '' -label '' ${TMP_DIR}/ig_info.$IM_EXT ${TMP_DIR}/ig_screens.$IM_EXT -tile 1x -mode Concatenate -background white "$OUTPUT"
fi

[ -n "$DEBUG" ] || rm -rf ${TMP_DIR}
Ancoron
Beginner
Beginner
 
Posts: 22
Joined: Wed Jul 15, 2009 9:52 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby netripper » Fri Sep 03, 2010 6:29 pm

Thanks!
netripper
I'm New!
I'm New!
 
Posts: 1
Joined: Thu Sep 17, 2009 7:20 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby mszymcza » Thu May 26, 2011 5:45 pm

Impressive. Is there any chance Mencoder could be compiled since it seems to be the sister product of mplayer?
Netgear N600 WNDR3700 --- FW V1.0.7.98NA
Synology DS211j --- FW DSM 3.1-1613
Qty(2) 3TB WD30EZRS-00J99B0 --- FW 80.00A80
mszymcza
Trainee
Trainee
 
Posts: 16
Joined: Sat May 21, 2011 5:30 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby gurpal2000 » Thu Dec 01, 2011 3:15 pm

Hi where did you get 'ldd' from? i have a RS2211 and can't find ldd anywhere. Shell says not found. it's not in /root like yours or in the the syno bins.
gurpal2000
Beginner
Beginner
 
Posts: 23
Joined: Tue Aug 30, 2011 10:53 am

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby gurpal2000 » Fri Dec 02, 2011 1:56 am

@anacron, i tried to cross compile very similarly for the RS2211+ (has an intel 64) ob ubuntu 64. the toolchains i used was the bromolow one (gcc420_glibc236_x64_bromolow-GPL). All seems well, no errors. When i try to run mediainfo (after copying the binary from ubuntu to synology) i get:

/mediainfo: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

any ideas?

EDIT - managed to compile :) will separately post
gurpal2000
Beginner
Beginner
 
Posts: 23
Joined: Tue Aug 30, 2011 10:53 am

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby biopob » Sun Feb 26, 2012 5:39 pm

I have a DS-1010 which has an Intel CPU, could anyone give me some guidance how to get Mplayer (with Mencoder) to build please?

I really don't know what options I should put in and I am quite intimidated by what I see was needed for other CPUs. Equally, I don't really want to cross compile because I should be able to compile on the NAS?

If anyone could give me a pointer, I would be extremely grateful...This is one of the final components I need in order to get PS3 media server working
biopob
I'm New!
I'm New!
 
Posts: 3
Joined: Sat Jul 17, 2010 12:49 pm

Re: mplayer / ffmpeg / mediainfo on the DS-409+

Postby patters » Fri Oct 12, 2012 1:33 am

gurpal2000 wrote:Hi where did you get 'ldd' from? i have a RS2211 and can't find ldd anywhere. Shell says not found. it's not in /root like yours or in the the syno bins.


ldd is included in the toolchain, but I could never figure out how to launch it, because it fails if you just run ldd.
How on earth did Ancoron figure out that you need to run sh ldd - I have tried looking this up and found nothing, so thanks for sharing. I had been using /opt/bin/objdump -x instead.

I have decided to slip ldd into my Java package since it's also including locale and localedef from the toolchains. Uninstall and reinstall my Java, and you'll find it at /bin/ldd. There doesn't seem to be an ldd for Intel though. For some reason it's missing from that particular toolchain...
For my packages (Java, Serviio, CrashPlan, CrashPlan PRO, CrashPlan PROe, Minecraft, Craftbukkit, OpenRemote, and Bliss), add my repo URL to Package Center: http://packages.pcloadletter.co.uk
patters
Experienced
Experienced
 
Posts: 115
Joined: Mon Feb 07, 2011 3:41 am


Return to Media Streaming Mods

Who is online

Users browsing this forum: No registered users and 2 guests