office在线预览、音视频转码(一)

211 阅读2分钟

主要解决:office转码、音视频转码截图、pdf制作电子书等

注意:推荐系统使用环境 Ubuntu 16.04 -18.04 -20.04,以下命令均在ubuntu系统环境下操作。

1、切换阿里云镜像

参考地址: developer.aliyun.com/mirror/ubun…

cp /etc/apt/sources.list   /etc/apt/sources.list.bak
vi /etc/apt/sources.list
sudo apt-get update

2、安装unoconv,并查看版本

apt-get install -y unoconv
unoconv  --version

3、安装libreoffice 并验证版本

apt-get install  -y  libreoffice
soffice --version

注意:为解决转码后出现乱码等,需要将特殊字体拷贝到服务器中

cd /usr/share/fonts
mkdir win
chmod a+x win/
mkfontscale
mkfontdir
fc-cache -fv

4、安装convert PDF切图并验证版本

apt-get -y install imagemagick
apt-get -y install libjpeg* libpng* libtiff* libungif* 
apt-get -y install ghostscript
convert -version

5、安装ffmpeg 并按照相关依赖,验证版本

#编译基础依赖
apt-get -y install autoconf automake bzip2 cmake  gcc   libtool make mercurial
mkdir /opt/ffmpeg_sources
cd /opt/ffmpeg_sources
vi /etc/profile
# 添加一行安装环境
export FFMPEG_HOME=/opt/ffmpeg_sources
export PATH=${FFMPEG_HOME}/bin:$PATH;
source /etc/profile
tar xjvf  /opt/soft/nasm-2.15.02.tar.bz2
# 编译汇编语言NASM
cd nasm-2.15.02
./autogen.sh
./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --bindir="$FFMPEG_HOME/bin"
make
make install
#编译安装汇编语言Yasm
cd ..  && tar xzvf /opt/soft/yasm-1.3.0.tar.gz 
cd yasm-1.3.0 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --bindir="$FFMPEG_HOME/bin"
make
make install
#编译安装libx264编码器
cd .. && tar xjvf /opt/soft/x264-master.tar.bz2 
cd x264-master
PKG_CONFIG_PATH="$FFMPEG_HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --bindir="$FFMPEG_HOME/bin" --enable-static --disable-asm
make
make install

#编译安装libfdk_aac编码器(shiy)


#编译安装libmp3lame编码器
cd .. && tar xzvf /opt/soft/lame-3.100.tar.gz 
cd lame-3.100 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --bindir="$FFMPEG_HOME/bin" --disable-shared --enable-nasm
make
make install

#编译安装libopus编码器
cd .. && tar xzvf /opt/soft/opus-1.2.1.tar.gz
cd opus-1.2.1 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --disable-shared
make
make install

# 编译安装libogg编码器
cd .. && tar xzvf /opt/soft/libogg-1.3.4.tar.gz
cd libogg-1.3.4 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build" --disable-shared
make
make install


#编译安装libvorbis编码器
cd .. && tar xzvf /opt/soft/libvorbis-1.3.7.tar.gz
cd libvorbis-1.3.7 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build"   --with-ogg="$FFMPEG_HOME/ffmpeg_build"     --disable-shared
make
make install

#编译安装libtheora编码器
cd .. && tar xzvf /opt/soft/libtheora-1.1.1.tar.gz 
cd libtheora-1.1.1 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build"  --with-ogg="$FFMPEG_HOME/ffmpeg_build" --disable-shared 
make
make install

#编译安装libvpx编码器
cd .. && tar xzvf /opt/soft/libvpx-1.8.2.tar.gz
cd libvpx-1.8.2 && ./configure --prefix="$FFMPEG_HOME/ffmpeg_build"  --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install



#编译安装libfreetype

cd .. && tar xf /opt/soft/freetype-2.10.0.tar.bz2
cd freetype-2.10.0/
./configure --prefix=/usr/local --disable-static
make
make install

#编译安装fribidi, 安装之前需要安装uuid 、gperf
apt-get -y  install uuid-dev
apt-get -y install gperf*
cd .. && tar xf /opt/soft/fribidi-1.0.4.tar.bz2
cd fribidi-1.0.4
./configure --prefix=/usr/local/ --enable-shared
make
make install


#编译安装fontconfig
vi /etc/profile
export PKG_CONFIG_PATH=/opt/ffmpeg_sources/ffmpeg_build/lib/pkgconfig
source /etc/profile
apt-get -y install libxml2*
cd .. && tar xf /opt/soft/fontconfig-2.13.0.tar.gz
cd fontconfig-2.13.0
./configure --prefix=/usr/local/ --enable-shared --enable-libxml2

make
make install

#编译安装libass

cd .. && tar xvf /opt/soft/libass-0.14.0.tar
cd libass-0.14.0
./configure --prefix=/usr/local/ --disable-static
make
make install

#安装ffmpeg
cd .. && tar xjvf /opt/soft/ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$FFMPEG_HOME/bin:$PATH" PKG_CONFIG_PATH="$FFMPEG_HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$FFMPEG_HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$FFMPEG_HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$FFMPEG_HOME/ffmpeg_build/lib" \
  --extra-libs=-lpthread \
  --extra-libs=-lm \
  --bindir="$FFMPEG_HOME/bin" \
  --enable-gpl \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libvorbis \
  --enable-libtheora \
  --enable-libvpx \
  --enable-libx264 \
  --enable-nonfree 
make
make install
hash -r

验证ffmpeg 安装版本及相关依赖库

  ffmpeg -version

特殊说明

在Ubuntu 18.04/Ubuntu 16.04系统中卸载LibreOffice 通过在终端中运行以下命令,在Ubuntu 18.04、Ubuntu 16.04系统中卸载LibreOffice:

sudo apt-get remove --purge libreoffice*

这将删除LibreOffice及其依赖项,接下来是清除LibreOffice包的本地存储库,运行以下命令:

sudo apt clean

清除孤立的所有LibreOffice依赖项:

sudo apt-get autoremove

至此,LibreOffice彻底的从Ubuntu 18.04/Ubuntu 16.04系统中删除掉了