2

I have been trying for weeks to embed some videos (created with python-Matplotlib) in my Latex/Beamer presentation according to examples like this one, which use a package called media9. Document compilation shows no errors, but still it doesn't work.

Basically it uses a Flash player in the PDF to play things, and as such, the videos it plays are very limited (in terms of supported codecs, extensions, etc.). If I follow the documentation and convert an old video I had to the right specs, then it works. However, I can't make it work for videos that I am creating currently and I can't tell what's causing this difference.

According to the documentation:

Flash Player supports the efficient H.264 codec for video compression. MP4/H.264 video files can be encoded from existing video files and from numbered bitmap sequences using the ffmpeg (http://ffmpeg.org.) or avconv (http://libav.org.) command line tools. In order to allow for precise seeking within video files it is necessary to encode them with a sufficient number of key frames. The command line for recoding an existing video file video.avi into video.mp4 reads

ffmpeg -i video.avi -vf scale="trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -profile:v high -pix_fmt yuv420p -g 30 -r 30 video.mp4

Things I've tried:

I have tried creating the video from Matplotlib using ffmpeg with the correct characteristics already (-pix_fmt yuv420p -g 30 -r 30, codec=libx264 and .mp4 extension). This didn't work.

Second, I tried creating videos with different encodings and extensions and then used the above line (given by the author of the package) to convert them. But that also doesn't work.

At this point I have no idea what else to do. As far as I know I am following every necessary point posed by the docs, but apparently that's not true and I can't figure out what's missing.

Here's an example of one of my old videos that work taken with ffmpeg -i (after using the command above):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'convB_C250_txy0.mp4.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:20.83, start: 0.000000, bitrate: 11867 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x840, 11864 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler

And now an example of a video that I created recently, passed through the same command, but that doesn't work:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'convC1_old.mp4.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:04.13, start: 0.000000, bitrate: 226 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x840, 222 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler

The only difference I see in both is the bitrate,which shouldn't make a difference. But even so I can't match the bitrate of the new video with the old one.

Is there something I'm missing here?

2
  • Does media9 show any error messages? Add -movflags +faststart and -bf 0 and check.
    – Gyan
    Jan 30, 2018 at 6:06
  • @Mulvya No, doesn't show any warnings or error messages. I compiled an output that I had done already in .mp4 with ffmpeg -i convC1_old.mp4 -vf scale="trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -profile:v high -pix_fmt yuv420p -g 30 -r 30 -movflags +faststart -bf 0 convC1_old.mp4.mp4, according to your suggestion, but the result was the same.
    – TomCho
    Jan 30, 2018 at 16:36

0

You must log in to answer this question.

Browse other questions tagged .