summaryrefslogtreecommitdiff
path: root/utilities/ffmpeg/utilitie.sh
blob: 22bda89ef465d60848ff7679a9187e7f72949c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh

# x-vdr (Installations-Skript fuer einen VDR mit Debian als Basis)
# von Marc Wernecke - www.zulu-entertainment.de
# 30.03.2009

# ffmpeg-svn

source ./../../x-vdr.conf
source ./../../setup.conf
source ./../../functions

#WEB="ffmpeg-svn"
VERSION="ffmpeg-svn"
LINK="ffmpeg"

#VAR=`basename $WEB`
DIR=`pwd`

DATE=`date +%Y%m%d`
DUMMY_LIBS="libavcodec51 libavcodec52 libavdevice52 libavfilter0 libavformat52 libavutil49 libpostproc51 libswscale0"

LIBS="$(apt-cache search "libavcodec"  | grep "libavcodec"  | cut -d" " -f1) \
      $(apt-cache search "libavdevice" | grep "libavdevice" | cut -d" " -f1) \
      $(apt-cache search "libavfilter" | grep "libavfilter" | cut -d" " -f1) \
      $(apt-cache search "libavformat" | grep "libavformat" | cut -d" " -f1) \
      $(apt-cache search "libavutil"   | grep "libavutil"   | cut -d" " -f1) \
      $(apt-cache search "libpostproc" | grep "libpostproc" | cut -d" " -f1) \
      $(apt-cache search "libswscale"  | grep "libswscale"  | cut -d" " -f1)"

# install
function make_util() {
  # pre install
  status=`status_util`
  if [ "$status" != "0" ]; then
    apt_remove "ffmpeg $LIBS"
    [ -d /usr/include/ffmpeg ] && rm -rf /usr/include/ffmpeg
  fi

  apt_install "libgsm1-dev"
  if [ "$LINUXVERSION" = "ubuntu" ]; then
    apt_install "libvorbis-perl libogg-vorbis-decoder-perl"
  else
    apt_install "libogg-vorbis-perl"
  fi

  # x264
  if [ "`apt_installed x264`" != "xvdr" ]; then
    cd $DIR/../x264
    chmod 744 utilitie-x264.sh
    ./utilitie-x264.sh || {
      log "ERROR - ffmpeg konnte x264 nicht finden"
      return 1
      }
  fi

  # download_util
  cd $SOURCEDIR
  [ -d $VERSION ] || svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk $VERSION
  [ ! -d $VERSION ] && echo "1" && exit 1

  # setzen des symlinks
  cd $SOURCEDIR
  rm -f $LINK
  ln -vfs $VERSION $LINK

  cd $SOURCEDIR/$LINK

  # check options
  all_options=$(./configure --help)
  checked_options=""
  my_options="--enable-shared --enable-pthreads --enable-postproc --enable-avfilter --enable-avfilter-lavf \
              --enable-gpl --enable-x11grab --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame \
              --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid"

  for option in $my_options; do
    echo "$all_options" | grep "\\$option" >null && checked_options="$checked_options $option"
  done

  # install
  ./configure --prefix=$PREFIX $checked_options &&
  make && checkinstall --fstrans=no --install=yes --pkgname=ffmpeg --pkgversion "4:0.5.svn${DATE}-xvdr" --default && TEST=ok

  # test
  if [ "$TEST" != "ok" ]; then
    log "ERROR - $VERSION konnte nicht erstellt werden"
    return 1
  fi

  # save deb file
  [ -d "$DIR/packages" ] || mkdir -p $DIR/packages
  cp -f ffmpeg*.deb $DIR/packages

  # dummys
  cd $DIR/packages

  for package in $DUMMY_LIBS; do
    echo "Section: misc
Priority: optional
Standards-Version: 3.6.2

Package: $package
Version: 4:0.5.svn${DATE}-xvdr-1
Maintainer: Musterman <Musterman@musterman.de>
Depends: ffmpeg
Provides: ffmpeg
Architecture: all
Description: Dummy-$package
" > ./$package

    equivs-build $package
    dpkg -i ${package}_0.5.svn${DATE}-xvdr-1_all.deb

  done
  # we need libavcodec51 for vlc
  cd $PREFIX/lib
  ln -vfs libavcodec.so libavcodec.so.51

  log "SUCCESS - $VERSION erstellt"
  ldconfig
}

# uninstall
function clean_util() {
  for package in ffmpeg $DUMMY_LIBS; do
    apt_remove "$package"
  done

  [ -d "$PREFIX/include/ffmpeg" ] && rm -rf "$PREFIX/include/ffmpeg"

  # remove source
  cd $SOURCEDIR
  [ -L "$LINK" ] && rm -rf "$LINK"
  [ -d "$VERSION" ] && rm -rf "$VERSION"

  ldconfig
}

# test
function status_util() {
  LIBTEST=""
  for package in ffmpeg $LIBS; do
    TEST=`apt_installed $package`
    [ "$TEST" = "debian" ] && LIBTEST="debian"
    [ "$TEST" = "xvdr" ] && LIBTEST="xvdr" && break
  done

  if [ "$LIBTEST" = "xvdr" ]; then
    [ -d $SOURCEDIR/$LINK ] && echo "2" && return 0
    echo "1"
  elif [ "$LIBTEST" = "debian" ]; then
    echo "3"
  else
    echo "0"
  fi
}

# start

# plugin commands
if [ $# \> 0 ]; then
  cmd=$1
  cmd_util
else
  make_util
  status_util
fi

exit 0