I can't get an ffmpeg
encoded libx264 video in a .mp4 container to work with media9 and beamer. The pdf is created using pdfLaTeX. It seems to be some kind of ffmpeg issue since the following work fine:
- The random.mp4 from the media9 package works
-
So is the .flv default in
ffmpeg
though the video quality is naturally not as goodffmpeg -i Test.mp4 -sameq Test.flv
Any video I encode in ffmpeg using
ffmpeg -i EB_%03d.png -c:v libx264 -x264opts keyint=30 -r 30 -b:v 1000k -s 640x512 Test.mp4
plays flawless in e.g. VLC (and I see the duration bar in the pdf though not the video). ffmpeg -i Test.mp4
yields for the video stream
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 640x512, 1021 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc
which is slightly different from ffmpeg -i random.mp4
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 170 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc
Output from ffmpeg
ffmpeg version 2.0.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 19 2013 08:34:03 with gcc 4.7 (SUSE Linux)
configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man
--libdir=/usr/lib --enable-shared --disable-static --enable-debug --disable-stripping
--extra-cflags='-fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2
-fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gsm' --enable-gpl --enable-x11grab --enable-version3
--enable-pthreads --enable-avfilter --enable-libpulse --enable-libvpx --enable-libopus
--enable-libass --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex
--enable-libxvid --enable-libx264 --enable-libschroedinger --enable-libgsm --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-postproc --enable-libdc1394 --enable-librtmp --enable-libfreetype
--enable-avresample --enable-libtwolame --enable-libvo-aacenc
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
The code snippet for media9
\begin{frame}
\frametitle{Here should be a .mp4 video}
\framesubtitle{Apparently, something is wrong with my x264 codec}
\includemedia[
width=3.5in,height=2.8in,
activate=pageopen,
addresource=Figures/Test.mp4,
transparent,
flashvars={
source=Figures/Test.mp4&
autoPlay=true&
loop=true&
scaleMode=letterbox
}
]{\includegraphics{Figures/EB_001}}{VPlayer.swf}
\end{frame}
Ideas anybody?
Best Answer
UPDATE
Choosing the right
libx264
options withffmpeg
/avconv
is a bit tricky.The following
ffmpeg
command line should produce usable video files (adjust frame-r ...
and keyframe-g ...
rates to your needs):<input>
to be replaced by a video file to be transcoded, or a PNG/JPEG/... file sequence with wildcards, e.g.frame-%d.png
for numbered filesframe-0.png
,frame-1.png
etc.Replace
ffmpeg
withavconv
, if the latter is installed. Both share the same options.