ffmpeg
链接
ffmpeg-converted-mp4-file-does-not-play-in-firefox-and-chrome
编译
sudo apt-get update -qq && sudo apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
pkg-config \
texinfo \
wget \
zlib1g-dev
sudo apt-get install nasm
sudo apt-get install yasm
sudo apt-get install libx264-dev
sudo apt-get install libx265-dev libnuma-dev
sudo apt-get install libvpx-dev
sudo apt-get install libfdk-aac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libopus-dev
./configure \
--prefix="/home/huangjian/local/ffmpeg" \
--pkg-config-flags="--static" \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
把 avi 格式的视频转换为 mp4 格式的视频
ffmpeg -y -i "input.avi" -c:v libx264 -preset slow -crf 22 -pix_fmt yuv420p -c:a libvo_aacenc -b:a 128k -movflags +faststart "output.mp4"
-y: overwrite output files
-i "input.avi" 输入文件
-pix_fmt yuv420p
-movflags +faststart
I'm guessing you are making videos for display on the web. If yes, then add
-movflags +faststart as an output option to allow the client to begin playback
before the file is completely downloaded.
用来显示 mp4 的 HTML
<!DOCTYPE html>
<html>
<head>
</head>
<!-- cdnjs : use a specific version of Video.js (change the version numbers as necessary) -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/video.js/6.7.3/video-js.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/6.7.3/video.min.js"></script>
<body>
<!-- <video controls="controls"> -->
<!-- <source src="1.mp4" type="video/mp4"> -->
<!-- </video> -->
<video id="my-player" class="video-js" controls preload="auto" data-setup='{}'>
<source src="output.mp4" type="video/mp4">
</source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
</body>
</html>