Recherche avancée

Médias (91)

Autres articles (85)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (8831)

  • recording from webcam using ffmpeg at high framerate

    14 novembre 2017, par Zorglub29

    I have a webcam (model Brio 4K stream edition from Logitech) that is able to record at resolution 1280x720 and 60 fps in guvcview on Ubuntu 16.04. I then use a video codec ’raw camera input’. This is working fine and as expected, and the result is well a 60 fps video at the desired resolution.

    However, I need to record using command line and not GUI. The guvcview GUI crashes on my machine (segmentation fault, this has been reported by other users before), so I want to use ffmpeg instead.

    Unfortunately, when I use the command (in terminal) :

    ffmpeg -i /dev/video1 -framerate 60 -video_size 1280x720 out.mkv

    I only get around 30 fps out. This is of course not due to the camera by itself (it works at 60 fps in guvcview), but I cannot understand why I get 30 fps when I ask for 60 fps explicitely. It also looks in the output of ffmpeg as it records at 30 fps :

    Metadata:
       encoder         : Lavf56.40.101
       Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv422p, 1280x720, q=-1--1, 30 fps, 1k tbn, 30 tbc

    Any suggestion how I can solve this and record at 60 fps using ffmpeg ?

    Note : I also tried something like this, with the same result (only 30 fps) :

    ffmpeg -f video4linux2 -i /dev/video1 -framerate 60.0 -video_size 1280x720 out.mkv

    Edit 1 thank you for the help in comment : order of arguments matters. Now using :

    ffmpeg -framerate 60 -video_size 1280x720 -i /dev/video1 out.mkv

    I get still around 30 fps, and a new (probably more understandable) warning message :

    [video4linux2,v4l2 @ 0x1ddc4e0] The driver changed the time per frame from 1/60 to 1/30
    Input #0, video4linux2,v4l2, from '/dev/video1':
     Duration: N/A, start: 256338.694616, bitrate: 442368 kb/s
       Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 442368 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc

    I find several entries for this problem (video4linux2 + The driver changed the time per frame), but no clear solution.

    Edit 2 + 3 :

    v4l2-ctl -d 1 --list-formats-ext
    ioctl: VIDIOC_ENUM_FMT
       Index       : 0
       Type        : Video Capture
       Pixel Format: 'YUYV'
       Name        : YUYV 4:2:2
           Size: Discrete 640x480
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 160x120
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 176x144
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 320x180
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 320x240
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 352x288
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 340x340
               Interval: Discrete 0.033s (30.000 fps)
           Size: Discrete 424x240
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 440x440
               Interval: Discrete 0.033s (30.000 fps)
           Size: Discrete 480x270
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 640x360
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 800x448
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 800x600
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 848x480
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 960x540
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1024x576
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1280x720
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1600x896
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1920x1080
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)

       Index       : 1
       Type        : Video Capture
       Pixel Format: 'MJPG' (compressed)
       Name        : Motion-JPEG
           Size: Discrete 640x480
               Interval: Discrete 0.008s (120.000 fps)
               Interval: Discrete 0.011s (90.000 fps)
               Interval: Discrete 0.017s (60.000 fps)
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 160x120
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 176x144
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 320x180
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 320x240
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 352x288
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 424x240
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 480x270
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 640x360
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 800x448
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 800x600
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 848x480
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 960x540
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1024x576
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1280x720
               Interval: Discrete 0.011s (90.000 fps)
               Interval: Discrete 0.017s (60.000 fps)
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1600x896
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1920x1080
               Interval: Discrete 0.017s (60.000 fps)
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 2560x1440
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 3840x2160
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 4096x2160
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)

       Index       : 2
       Type        : Video Capture
       Pixel Format: 'NV12'
       Name        : Y/CbCr 4:2:0
           Size: Discrete 640x480
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 640x360
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1280x720
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)
           Size: Discrete 1920x1080
               Interval: Discrete 0.033s (30.000 fps)
               Interval: Discrete 0.042s (24.000 fps)
               Interval: Discrete 0.050s (20.000 fps)
               Interval: Discrete 0.067s (15.000 fps)
               Interval: Discrete 0.100s (10.000 fps)
               Interval: Discrete 0.133s (7.500 fps)
               Interval: Discrete 0.200s (5.000 fps)

    Edit 4 :

    It looks like there may still be a problem using :

    ffmpeg -f v4l2 -framerate 60 -video_size 1280x720 -input_format mjpeg -i /dev/video1 out.mkv

    As the output of ffmpeg looks like :

    Output #0, matroska, to 'out.mkv':
     Metadata:
     encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj422p(pc), 1280x720, q=-1--1, 60 fps, 1k tbn, 60 tbc
     Metadata:
     encoder         : Lavc56.60.100 libx264
    Stream mapping:
    Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    frame=  198 fps= 37 q=-1.0 Lsize=    1043kB time=00:00:05.38 bitrate=1587.4kbits/s

    Is the fps indicated in the last line (37 instead of 60) reliable ? It was working at 60 fps with guvcview, so I do not think the laptop write speeed or CPU is the problem.

    Edit 5 :

    Thank you for the great help @LordNeckbeard , now it looks like everything works using your additional output argument command ffmpeg -f v4l2 -framerate 60 -video_size 1280x720 -input_format mjpeg -i /dev/video1 -preset faster -pix_fmt yuv420p out.mkv :

    $ ffmpeg -f v4l2 -framerate 60 -video_size 1280x720 -input_format mjpeg -i /dev/video1 -preset faster -pix_fmt yuv420p out.mkv
    ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
     configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
     libavutil      54. 31.100 / 54. 31.100
     libavcodec     56. 60.100 / 56. 60.100
     libavformat    56. 40.101 / 56. 40.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 40.101 /  5. 40.101
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  2.101 /  1.  2.101
     libpostproc    53.  3.100 / 53.  3.100
    [mjpeg @ 0x1d6f320] Changeing bps to 8
    Input #0, video4linux2,v4l2, from '/dev/video1':
     Duration: N/A, start: 259410.922692, bitrate: N/A
       Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, -10 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
    [swscaler @ 0x1d7e480] deprecated pixel format used, make sure you did set range correctly
    [libx264 @ 0x1d72620] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
    [libx264 @ 0x1d72620] profile High, level 3.2
    [libx264 @ 0x1d72620] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=4 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=20 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, matroska, to 'out.mkv':
     Metadata:
       encoder         : Lavf56.40.101
       Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x720, q=-1--1, 60 fps, 1k tbn, 60 tbc
       Metadata:
         encoder         : Lavc56.60.100 libx264
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    frame=  467 fps= 59 q=-1.0 Lsize=     914kB time=00:00:07.83 bitrate= 955.8kbits/s    
    video:910kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.434447%
    [libx264 @ 0x1d72620] frame I:2     Avg QP:21.96  size: 61186
    [libx264 @ 0x1d72620] frame P:118   Avg QP:26.01  size:  4695
    [libx264 @ 0x1d72620] frame B:347   Avg QP:27.54  size:   734
    [libx264 @ 0x1d72620] consecutive B-frames:  0.4%  1.3%  0.6% 97.6%
    [libx264 @ 0x1d72620] mb I  I16..4: 14.7% 45.2% 40.0%
    [libx264 @ 0x1d72620] mb P  I16..4:  1.4%  3.7%  0.0%  P16..4: 29.9%  4.1%  0.5%  0.0%  0.0%    skip:60.4%
    [libx264 @ 0x1d72620] mb B  I16..4:  0.2%  0.4%  0.0%  B16..8:  5.4%  0.2%  0.0%  direct: 4.3%  skip:89.6%  L0:53.4% L1:42.7% BI: 3.9%
    [libx264 @ 0x1d72620] 8x8 transform intra:66.4% inter:71.8%
    [libx264 @ 0x1d72620] coded y,uvDC,uvAC intra: 38.1% 50.7% 12.7% inter: 2.8% 7.6% 0.1%
    [libx264 @ 0x1d72620] i16 v,h,dc,p: 36% 36% 16% 11%
    [libx264 @ 0x1d72620] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 32% 37%  2%  2%  2%  4%  1%  5%
    [libx264 @ 0x1d72620] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 46%  8%  2%  3%  3%  4%  3% 12%
    [libx264 @ 0x1d72620] i8c dc,h,v,p: 56% 26% 16%  3%
    [libx264 @ 0x1d72620] Weighted P-Frames: Y:9.3% UV:7.6%
    [libx264 @ 0x1d72620] ref P L0: 58.6% 41.4%
    [libx264 @ 0x1d72620] ref B L0: 56.9% 43.1%
    [libx264 @ 0x1d72620] ref B L1: 85.5% 14.5%
    [libx264 @ 0x1d72620] kb/s:946.85
  • An FFMpeg function on azure is not handling simultaneous calls (more than 5)

    9 novembre 2017, par The Lemon

    I created a c# httptrigger function on azure which uses FFMpeg to add subtitles to a video, and then just output the video locally (nothing fancy, all the files are in the local resources for the function, and the output is there as well). The process runs perfectly fine when I test it, I made a C# app to call the function and when I test the app it works fine as well. The only problem is when I tell the app to call the function several times at once it will only work for three or four simultaneous calls, any more than that will cause all of the calls to fail.
    Below is included the function code, the C# app code, and the partial output for successful calls and for failed calls. Any help or advice would be greatly appreciated as always. Regards Cuan

    note - the ffmpeg output from the azure function is largely omitted, as it produces output every few frames. I’ve included the start and the end of the output

    This is the C# method which is being run multiple times at once.

       public static async void callHTTP(string url, int num)
       {
           using (var client = new HttpClient())
           {
               client.Timeout = TimeSpan.FromMinutes(10);
               var content = new StringContent(JsonConvert.SerializeObject(" {\"name\": \"Azure\"}"), Encoding.UTF8, "application/json");
               System.TimeSpan tmp = DateTime.Now - time1;
               Console.WriteLine("Process {0} has started after time {1}", num + 1, tmp.ToString());
               var response = await client.PostAsync(url, content);
               tmp = DateTime.Now - time1;
               Console.WriteLine("Process {0} has finished after time {1}", num + 1, tmp.ToString());
               if (response.IsSuccessStatusCode)
               {
                   Console.WriteLine("this is a reply");
                   finished += 1;
                   tmp = DateTime.Now - time1;
                   Console.WriteLine("Runningtime for process {0} was {1}", num + 1, tmp.ToString());
               }

           }
       }

    This is the function being called

    using System.Net;
    using System;
    using System.Diagnostics;
    using System.ComponentModel;


    public static async Task<httpresponsemessage> Run(HttpRequestMessage req, TraceWriter log)
    {

    log.Info("C# HTTP trigger function processed a request.");
    //Basic Parameters
       string ffmpegFile = @"D:\home\site\wwwroot\CommonResources\ffmpeg.exe";
       string outputpath = @"D:\home\site\wwwroot\ffmpeg_generic_webhook\output\";
       string reloutputpath = "output/";
       string relinputpath = "input/";
       string outputfile = "video2.mp4";
       string dir =  @"D:\home\site\wwwroot\ffmpeg_generic_webhook\";

    //Special Parameters
       string videoFile = "1 minute basic.mp4";
       string sub = "1 minute sub.ass";
    //guid tmp files
       string f1 = videoFile;
       string f2 = sub;
    //guid output
       Guid g3 = Guid.NewGuid();
       string outputGuid = g3+".mp4";

    //argument
       string tmp = subArg(f1, f2, outputGuid );
    //String.Format("-i \"" + @"input/tmp.mp4" + "\" -vf \"ass = '" + sub + "'\" \"" + reloutputpath +outputfile + "\" ");
    log.Info("ffmpeg argument is: "+tmp);


    //startprocess parameters
    Process process = new Process();
    process.StartInfo.FileName = ffmpegFile;
    process.StartInfo.Arguments =  tmp;
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.WorkingDirectory = dir;
    //output handler

    process.OutputDataReceived += new DataReceivedEventHandler(
       (s, e) =>
       {
           log.Info("O: "+e.Data);
       }
    );
    process.ErrorDataReceived += new DataReceivedEventHandler(
       (s, e) =>
       {
           log.Info("E: "+e.Data);
       }
    );
    //start process
    process.Start();
    log.Info("process started");
    process.BeginOutputReadLine();
    process.BeginErrorReadLine();
    process.WaitForExit();
    log.Info("process has finished, deleting any tmp files and replying");
    return req.CreateResponse(HttpStatusCode.OK, outputGuid);
    }
    </httpresponsemessage>

    The output for the failed set of calls (they all run together, so the output is a bit jumbled)

    2017-11-08T05:49:48.821 Function started (Id=1b2cc785-086d-495a-a994-3ee9b86bb926)
    2017-11-08T05:49:48.834 Function started (Id=f0b9b383-b86b-4006-9e13-59861e2c0c35)
    2017-11-08T05:49:48.834 Function started (Id=80c2a433-728e-42d3-804d-87461e369bd8)
    2017-11-08T05:49:49.287 C# HTTP trigger function processed a request.
    2017-11-08T05:49:49.287 ffmpeg argument is: -i "input/1 minute basic.mp4" -vf "ass = 'input/1 minute sub.ass'" "output/8ab2a4fd-39df-4da9-b0c5-5b33e95d6403.mp4"
    2017-11-08T05:49:49.305 C# HTTP trigger function processed a request.
    2017-11-08T05:49:49.305 ffmpeg argument is: -i "input/1 minute basic.mp4" -vf "ass = 'input/1 minute sub.ass'" "output/5805f054-db13-4154-8fe8-545161d2eb83.mp4"
    2017-11-08T05:49:49.305 C# HTTP trigger function processed a request.
    2017-11-08T05:49:49.305 ffmpeg argument is: -i "input/1 minute basic.mp4" -vf "ass = 'input/1 minute sub.ass'" "output/4275f98d-7a31-484c-960b-1e133056e895.mp4"
    2017-11-08T05:49:49.381 process started
    2017-11-08T05:49:49.428 process started
    2017-11-08T05:49:49.491 E: ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
    2017-11-08T05:49:49.491 E:   built with gcc 7.1.0 (GCC)
    2017-11-08T05:49:49.491 E:   configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
    2017-11-08T05:49:49.491 E:   libavutil      55. 58.100 / 55. 58.100
    2017-11-08T05:49:49.491 E:   libavcodec     57. 89.100 / 57. 89.100
    2017-11-08T05:49:49.491 E:   libavformat    57. 71.100 / 57. 71.100
    2017-11-08T05:49:49.491 E:   libavdevice    57.  6.100 / 57.  6.100
    2017-11-08T05:49:49.491 E:   libavfilter     6. 82.100 /  6. 82.100
    2017-11-08T05:49:49.491 E:   libswscale      4.  6.100 /  4.  6.100
    2017-11-08T05:49:49.491 E:   libswresample   2.  7.100 /  2.  7.100
    2017-11-08T05:49:49.491 E:   libpostproc    54.  5.100 / 54.  5.100
    2017-11-08T05:49:49.522 process started
    2017-11-08T05:49:49.570 E: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input/1 minute basic.mp4':
    2017-11-08T05:49:49.570 E:   Metadata:
    2017-11-08T05:49:49.570 E:     major_brand     : mp42
    2017-11-08T05:49:49.570 E:     minor_version   : 0
    2017-11-08T05:49:49.570 E:     compatible_brands: mp41isom
    2017-11-08T05:49:49.570 E:     creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T05:49:49.570 E:   Duration: 00:01:00.03, start: 0.000000, bitrate: 824 kb/s
    2017-11-08T05:49:49.570 E:     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 823 kb/s, 30.30 fps, 30.30 tbr, 30k tbn, 60 tbc (default)
    2017-11-08T05:49:49.570 E:     Metadata:
    2017-11-08T05:49:49.570 E:       creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T05:49:49.570 E:       handler_name    : VideoHandler
    2017-11-08T05:49:49.570 E:       encoder         : AVC Coding
    2017-11-08T05:49:49.584 E: Stream mapping:
    2017-11-08T05:49:49.584 E:   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    2017-11-08T05:49:49.584 E: Press [q] to stop, [?] for help
    2017-11-08T05:49:49.615 E: [Parsed_ass_0 @ 000000000117ee60] Shaper: FriBidi 0.19.6 (SIMPLE)
    2017-11-08T05:49:49.631 process started
    2017-11-08T05:49:49.929 process started
    2017-11-08T05:49:50.069 process started
    2017-11-08T05:49:50.115 process started
    2017-11-08T05:49:54.990 E: [Parsed_ass_0 @ 000000000117ee60] Using font provider directwrite
    2017-11-08T05:49:54.990 E: [Parsed_ass_0 @ 000000000117ee60] Added subtitle file: 'input/1 minute sub.ass' (5 styles, 6 events)
    2017-11-08T05:49:55.006 E: [Parsed_ass_0 @ 000000000117ee60] fontselect: (Arial, 700, 0) -> Arial-BoldMT, 0, Arial-BoldMT
    2017-11-08T05:49:55.006 E: [libx264 @ 00000000004dd860] using SAR=1/1
    2017-11-08T05:49:55.006 E: [libx264 @ 00000000004dd860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    2017-11-08T05:49:55.022 E: [libx264 @ 00000000004dd860] profile High, level 3.2
    2017-11-08T05:49:55.022 E: [libx264 @ 00000000004dd860] 264 - core 152 r2851 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    2017-11-08T05:49:55.022 E: Output #0, mp4, to 'output/8ab2a4fd-39df-4da9-b0c5-5b33e95d6403.mp4':
    2017-11-08T05:49:55.022 E:   Metadata:
    2017-11-08T05:49:55.022 E:     major_brand     : mp42
    2017-11-08T05:49:55.022 E:     minor_version   : 0
    2017-11-08T05:49:55.022 E:     compatible_brands: mp41isom
    2017-11-08T05:49:55.022 E:     encoder         : Lavf57.71.100
    2017-11-08T05:49:55.022 E:     Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30.30 fps, 16k tbn, 30.30 tbc (default)
    2017-11-08T05:49:55.022 E:     Metadata:
    2017-11-08T05:49:55.022 E:       creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T05:49:55.022 E:       handler_name    : VideoHandler
    2017-11-08T05:49:55.022 E:       encoder         : Lavc57.89.100 libx264
    2017-11-08T05:49:55.022 E:     Side data:
    2017-11-08T05:49:55.022 E:       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    2017-11-08T05:49:56.787 E: frame=    2 fps=0.4 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T05:49:56.851 E: frame=    4 fps=0.6 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x

    lots of code omitted here, only showing one of the many calls failing due to character limit.

    2017-11-08T05:50:27.695 E: x264 [error]: malloc of size 3233984 failed
    2017-11-08T05:50:27.695 E: Video encoding failed
    2017-11-08T05:50:27.932 E: frame=  112 fps=3.0 q=29.0 size=      92kB time=00:00:02.24 bitrate= 335.9kbits/s speed=0.0598x
    2017-11-08T05:50:28.132 E: Conversion failed!
    2017-11-08T05:50:28.274 E: frame=  164 fps=4.3 q=29.0 size=      97kB time=00:00:03.96 bitrate= 201.0kbits/s speed=0.104x
    2017-11-08T05:50:28.304 E: Conversion failed!
    2017-11-08T05:50:28.304 E: Conversion failed!
    2017-11-08T05:50:28.336 E: frame=  253 fps=6.6 q=29.0 size=     159kB time=00:00:06.89 bitrate= 189.0kbits/s speed=0.179x
    2017-11-08T05:50:30.163 E: frame=   27 fps=0.7 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T05:50:30.227 E: frame=   28 fps=0.7 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T05:50:30.276 E:
    2017-11-08T05:50:30.305 O:
    2017-11-08T05:50:30.727 E: frame=   40 fps=1.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T05:50:30.867 E: frame=  129 fps=3.2 q=29.0 size=      93kB time=00:00:02.80 bitrate= 272.3kbits/s speed=0.0693x
    2017-11-08T05:50:30.929 E:
    2017-11-08T05:50:30.929 O:
    2017-11-08T05:50:30.929 E:
    2017-11-08T05:50:30.948 O:
    2017-11-08T05:50:31.290 E: frame=  178 fps=4.3 q=29.0 size=     116kB time=00:00:04.42 bitrate= 214.8kbits/s speed=0.108x
    2017-11-08T05:50:31.822 E: frame=  133 fps=3.2 q=29.0 size=      94kB time=00:00:02.93 bitrate= 261.0kbits/s speed=0.0715x

    working example (only one call)

    2017-11-08T07:07:08.633 Function started (Id=5416410c-a185-44bd-8c9c-fc24efb80780)
    2017-11-08T07:07:09.180 C# HTTP trigger function processed a request.
    2017-11-08T07:07:09.180 ffmpeg argument is: -i "input/1 minute basic.mp4" -vf "ass = 'input/1 minute sub.ass'" "output/9a7af992-7202-45c6-a275-f71a184fc89b.mp4"
    2017-11-08T07:07:09.508 process started
    2017-11-08T07:07:10.992 E: ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
    2017-11-08T07:07:10.992 E:   built with gcc 7.1.0 (GCC)
    2017-11-08T07:07:10.992 E:   configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
    2017-11-08T07:07:11.367 E:   libavutil      55. 58.100 / 55. 58.100
    2017-11-08T07:07:11.367 E:   libavcodec     57. 89.100 / 57. 89.100
    2017-11-08T07:07:11.367 E:   libavformat    57. 71.100 / 57. 71.100
    2017-11-08T07:07:11.367 E:   libavdevice    57.  6.100 / 57.  6.100
    2017-11-08T07:07:11.367 E:   libavfilter     6. 82.100 /  6. 82.100
    2017-11-08T07:07:11.367 E:   libswscale      4.  6.100 /  4.  6.100
    2017-11-08T07:07:11.367 E:   libswresample   2.  7.100 /  2.  7.100
    2017-11-08T07:07:11.367 E:   libpostproc    54.  5.100 / 54.  5.100
    2017-11-08T07:07:12.977 E: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input/1 minute basic.mp4':
    2017-11-08T07:07:12.977 E:   Metadata:
    2017-11-08T07:07:12.977 E:     major_brand     : mp42
    2017-11-08T07:07:12.977 E:     minor_version   : 0
    2017-11-08T07:07:12.977 E:     compatible_brands: mp41isom
    2017-11-08T07:07:12.977 E:     creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T07:07:12.977 E:   Duration: 00:01:00.03, start: 0.000000, bitrate: 824 kb/s
    2017-11-08T07:07:12.977 E:     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 823 kb/s, 30.30 fps, 30.30 tbr, 30k tbn, 60 tbc (default)
    2017-11-08T07:07:12.977 E:     Metadata:
    2017-11-08T07:07:12.977 E:       creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T07:07:12.977 E:       handler_name    : VideoHandler
    2017-11-08T07:07:12.977 E:       encoder         : AVC Coding
    2017-11-08T07:07:12.992 E: Stream mapping:
    2017-11-08T07:07:13.008 E:   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    2017-11-08T07:07:13.008 E: Press [q] to stop, [?] for help
    2017-11-08T07:07:13.320 E: [Parsed_ass_0 @ 000000000107ee60] Shaper: FriBidi 0.19.6 (SIMPLE)
    2017-11-08T07:07:14.987 E: [Parsed_ass_0 @ 000000000107ee60] Using font provider directwrite
    2017-11-08T07:07:15.143 E: [Parsed_ass_0 @ 000000000107ee60] Added subtitle file: 'input/1 minute sub.ass' (5 styles, 6 events)
    2017-11-08T07:07:15.455 E: [Parsed_ass_0 @ 000000000107ee60] fontselect: (Arial, 700, 0) -> Arial-BoldMT, 0, Arial-BoldMT
    2017-11-08T07:07:15.833 E: [libx264 @ 00000000004fd860] using SAR=1/1
    2017-11-08T07:07:15.911 E: [libx264 @ 00000000004fd860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    2017-11-08T07:07:15.973 E: [libx264 @ 00000000004fd860] profile High, level 3.2
    2017-11-08T07:07:15.973 E: [libx264 @ 00000000004fd860] 264 - core 152 r2851 ba24899 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    2017-11-08T07:07:15.973 E: Output #0, mp4, to 'output/9a7af992-7202-45c6-a275-f71a184fc89b.mp4':
    2017-11-08T07:07:15.973 E:   Metadata:
    2017-11-08T07:07:15.973 E:     major_brand     : mp42
    2017-11-08T07:07:15.973 E:     minor_version   : 0
    2017-11-08T07:07:15.973 E:     compatible_brands: mp41isom
    2017-11-08T07:07:15.973 E:     encoder         : Lavf57.71.100
    2017-11-08T07:07:15.973 E:     Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 30.30 fps, 16k tbn, 30.30 tbc (default)
    2017-11-08T07:07:15.973 E:     Metadata:
    2017-11-08T07:07:15.973 E:       creation_time   : 2017-11-03T23:42:35.000000Z
    2017-11-08T07:07:15.973 E:       handler_name    : VideoHandler
    2017-11-08T07:07:15.973 E:       encoder         : Lavc57.89.100 libx264
    2017-11-08T07:07:15.973 E:     Side data:
    2017-11-08T07:07:15.973 E:       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    2017-11-08T07:07:16.137 E: frame=    2 fps=0.7 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T07:07:16.528 E: frame=   21 fps=6.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
    2017-11-08T07:07:17.622 E: frame=   43 fps=9.5 q=29.0 size=      34kB time=-00:00:00.03 bitrate=N/A speed=N/A
    2017-11-08T07:07:18.122 E: frame=   46 fps=9.1 q=29.0 size=      35kB time=00:00:00.06 bitrate=4372.6kbits/s speed=0.013x

     omitted 

    2017-11-08T07:07:30.809 E: [Parsed_ass_0 @ 000000000107ee60] fontselect: (Arial, 400, 0) -> ArialMT, 0, ArialMT

    2017-11-08T07:08:43.186 E: frame= 1819 fps= 20 q=29.0 Lsize=     992kB time=00:00:59.92 bitrate= 135.6kbits/s speed=0.665x
    2017-11-08T07:08:43.186 E: video:971kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.171792%
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] frame I:8     Avg QP:12.19  size: 44849
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] frame P:532   Avg QP:16.00  size:   923
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] frame B:1279  Avg QP:20.61  size:   112
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] consecutive B-frames:  4.7%  0.8% 11.4% 83.1%
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] mb I  I16..4: 49.2% 24.2% 26.7%
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] mb P  I16..4:  0.2%  0.3%  0.1%  P16..4:  2.6%  0.3%  0.4%  0.0%  0.0%    skip:96.2%
    2017-11-08T07:08:43.217 E: [libx264 @ 00000000004fd860] mb B  I16..4:  0.0%  0.1%  0.0%  B16..8:  2.1%  0.0%  0.0%  direct: 0.0%  skip:97.7%  L0:40.0% L1:59.7% BI: 0.3%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] 8x8 transform intra:39.3% inter:39.5%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] coded y,uvDC,uvAC intra: 16.3% 15.7% 8.8% inter: 0.5% 0.0% 0.0%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] i16 v,h,dc,p: 56% 31%  4%  9%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24%  9% 65%  1%  0%  0%  0%  0%  0%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 21% 15%  6%  6%  6%  4%  6%  4%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] i8c dc,h,v,p: 71% 16% 11%  1%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] Weighted P-Frames: Y:0.0% UV:0.0%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] ref P L0: 71.3% 12.7% 14.6%  1.4%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] ref B L0: 69.3% 29.3%  1.4%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] ref B L1: 97.0%  3.0%
    2017-11-08T07:08:43.233 E: [libx264 @ 00000000004fd860] kb/s:132.38
    2017-11-08T07:08:43.295 O:
    2017-11-08T07:08:43.295 E:
    2017-11-08T07:08:43.342 Function completed (Success, Id=5416410c-a185-44bd-8c9c-fc24efb80780, Duration=94698ms)
  • ffmpeg command working from command line but not from python subprocess.Popen

    7 novembre 2017, par Stuart Clarke

    I’m trying to run the below command from within a Python script.

    ffmpeg -y -loglevel verbose -i /var/www/Intro30.mp4 -i /var/www/temp/videoHD.mp4 -i /var/www/Credits30.mp4 -filter_complex '[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] concat=n=3:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' /var/www/temp/merged.mp4

    But it results in a corrupted file. This is the output.

    ffmpeg version 3.3.4-2~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
     configuration: --prefix=/usr --extra-version='2~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
     libavutil      55. 58.100 / 55. 58.100
     libavcodec     57. 89.100 / 57. 89.100
     libavformat    57. 71.100 / 57. 71.100
     libavdevice    57.  6.100 / 57.  6.100
     libavfilter     6. 82.100 /  6. 82.100
     libavresample   3.  5.  0 /  3.  5.  0
     libswscale      4.  6.100 /  4.  6.100
     libswresample   2.  7.100 /  2.  7.100
     libpostproc    54.  5.100 / 54.  5.100
    [h264 @ 0x7f6d1ca0a7c0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/Intro30.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:02.93, start: 0.000000, bitrate: 3490 kb/s
       Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 3507 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    [h264 @ 0x7f6d1ca334e0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/temp/videoHD.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:57.23, start: 0.000000, bitrate: 3087 kb/s
       Stream #1:0(eng): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 2950 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    [h264 @ 0x7f6d1ca307a0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/Credits30.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:14.14, start: 0.000000, bitrate: 5706 kb/s
       Stream #2:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 5711 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    Stream mapping:
     Stream #0:0 (h264) -> concat:in0:v0
     Stream #0:1 (aac) -> concat:in0:a0
     Stream #1:0 (h264) -> concat:in1:v0
     Stream #1:1 (aac) -> concat:in1:a0
     Stream #2:0 (h264) -> concat:in2:v0
     Stream #2:1 (aac) -> concat:in2:a0
     concat:out:v0 -> Stream #0:0 (libx264)
     concat:out:a0 -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help
    [h264 @ 0x7f6d1d1210e0] Reinit context to 1920x1088, pix_fmt: yuv420p
    [h264 @ 0x7f6d1cc07420] Reinit context to 1920x1088, pix_fmt: yuv420p
    [h264 @ 0x7f6d1cd449a0] Reinit context to 1920x1088, pix_fmt: yuv420p
    [graph 0 input from stream 0:0 @ 0x7f6d1d8f9400] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_0_1 @ 0x7f6d1d8ef520] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [graph 0 input from stream 1:0 @ 0x7f6d1d1052a0] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_1_1 @ 0x7f6d1d105ac0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [graph 0 input from stream 2:0 @ 0x7f6d1d17fd20] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_2_1 @ 0x7f6d1d109d40] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [libx264 @ 0x7f6d1ca9aaa0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
    [libx264 @ 0x7f6d1ca9aaa0] profile High, level 4.0
    [libx264 @ 0x7f6d1ca9aaa0] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '/var/www/temp/merged.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
       Stream #0:0: Video: h264 (libx264), 1 reference frame ([33][0][0][0] / 0x0021), yuv420p(progressive), 1920x1080, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
       Metadata:
         encoder         : Lavc57.89.100 libx264
       Side data:
         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
       Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, delay 1024, 128 kb/s (default)
       Metadata:
         encoder         : Lavc57.89.100 aac
    frame=   46 fps=0.0 q=0.0 size=       0kB time=00:00:01.62 bitrate=   0.0kbits/s speed=2.78x

    But when I run it from the command line it executes perfectly.

    ffmpeg version 3.3.4-2~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
     configuration: --prefix=/usr --extra-version='2~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
     libavutil      55. 58.100 / 55. 58.100
     libavcodec     57. 89.100 / 57. 89.100
     libavformat    57. 71.100 / 57. 71.100
     libavdevice    57.  6.100 / 57.  6.100
     libavfilter     6. 82.100 /  6. 82.100
     libavresample   3.  5.  0 /  3.  5.  0
     libswscale      4.  6.100 /  4.  6.100
     libswresample   2.  7.100 /  2.  7.100
     libpostproc    54.  5.100 / 54.  5.100
    [h264 @ 0x7f6dc62417c0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/Intro30.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:02.93, start: 0.000000, bitrate: 3490 kb/s
       Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 3507 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    [h264 @ 0x7f6dc626a4e0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/temp/videoHD.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:57.23, start: 0.000000, bitrate: 3087 kb/s
       Stream #1:0(eng): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 2950 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    [h264 @ 0x7f6dc62677a0] Reinit context to 1920x1088, pix_fmt: yuv420p
    Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/Credits30.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
     Duration: 00:00:14.14, start: 0.000000, bitrate: 5706 kb/s
       Stream #2:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088), 5711 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler
       Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    Stream mapping:
     Stream #0:0 (h264) -> concat:in0:v0
     Stream #0:1 (aac) -> concat:in0:a0
     Stream #1:0 (h264) -> concat:in1:v0
     Stream #1:1 (aac) -> concat:in1:a0
     Stream #2:0 (h264) -> concat:in2:v0
     Stream #2:1 (aac) -> concat:in2:a0
     concat:out:v0 -> Stream #0:0 (libx264)
     concat:out:a0 -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help
    [h264 @ 0x7f6dc69580e0] Reinit context to 1920x1088, pix_fmt: yuv420p
    [h264 @ 0x7f6dc643e420] Reinit context to 1920x1088, pix_fmt: yuv420p
    [h264 @ 0x7f6dc657b9a0] Reinit context to 1920x1088, pix_fmt: yuv420p
    [graph 0 input from stream 0:0 @ 0x7f6dc712fda0] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_0_1 @ 0x7f6dc693c040] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [graph 0 input from stream 1:0 @ 0x7f6dc693cb60] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_1_1 @ 0x7f6dc69b68a0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [graph 0 input from stream 2:0 @ 0x7f6dc69b74a0] w:1920 h:1080 pixfmt:yuv420p tb:1/15360 fr:30/1 sar:0/1 sws_param:flags=2
    [graph_0_in_2_1 @ 0x7f6dc6941460] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
    [libx264 @ 0x7f6dc62d1aa0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
    [libx264 @ 0x7f6dc62d1aa0] profile High, level 4.0
    [libx264 @ 0x7f6dc62d1aa0] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '/var/www/temp/merged.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.71.100
       Stream #0:0: Video: h264 (libx264), 1 reference frame ([33][0][0][0] / 0x0021), yuv420p(progressive), 1920x1080, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
       Metadata:
         encoder         : Lavc57.89.100 libx264
       Side data:
         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
       Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, delay 1024, 128 kb/s (default)
       Metadata:
         encoder         : Lavc57.89.100 aac
    frame=   46 fps=0.0 q=0.0 size=       0kB time=00:00:01.62 bitrate=   0.0kbits/sframe=   64 fps= 59 q=29.0 size=     289kB time=00:00:02.22 bitrate=1062.4kbits/frame=   83 fps= 48 q=29.0 size=     762kB time=00:00:02.85 bitrate=2186.9kbits/[Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in0:v0, 1 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in0:a0, 0 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] Segment finished at pts=2902494
    frame=  104 fps= 46 q=29.0 size=     908kB time=00:00:03.55 bitrate=2094.5kbits/frame=  123 fps= 44 q=29.0 size=    1048kB time=00:00:04.17 bitrate=2053.3kbits/frame=  140 fps= 42 q=29.0 size=    1215kB time=00:00:04.76 bitrate=2091.1kbits/frame=  149 fps= 38 q=29.0 size=    1374kB time=00:00:05.06 bitrate=2223.4kbits/frame=  161 fps= 35 q=29.0 size=    1528kB time=00:00:05.45 bitrate=2293.6kbits/frame=  173 fps= 34 q=29.0 size=    1695kB time=00:00:05.82 bitrate=2382.5kbits/frame=  180 fps= 32 q=29.0 size=    1784kB time=00:00:06.08 bitrate=2402.4kbits/frame=  193 fps= 32 q=29.0 size=    1959kB time=00:00:06.50 bitrate=2468.6kbits/frame=  200 fps= 30 q=29.0 size=    2052kB time=00:00:06.75 bitrate=2487.8kbits/frame=  211 fps= 30 q=29.0 size=    2221kB time=00:00:07.12 bitrate=2552.6kbits/frame=  221 fps= 29 q=29.0 size=    2303kB time=00:00:07.45 bitrate=2530.9kbits/frame=  232 fps= 28 q=29.0 size=    2433kB time=00:00:07.82 bitrate=2547.0kbits/frame=  245 fps= 28 q=29.0 size=    2560kB time=00:00:08.26 bitrate=2536.7kbits/frame=  255 fps= 28 q=29.0 size=    2684kB time=00:00:08.59 bitrate=2558.9kbits/frame=  264 fps= 27 q=29.0 size=    2776kB time=00:00:08.89 bitrate=2557.5kbits/frame=  275 fps= 27 q=29.0 size=    2894kB time=00:00:09.26 bitrate=2559.0kbits/frame=  285 fps= 26 q=29.0 size=    3028kB time=00:00:09.58 bitrate=2586.3kbits/frame=  295 fps= 26 q=29.0 size=    3172kB time=00:00:09.91 bitrate=2621.2kbits/frame=  303 fps= 25 q=29.0 size=    3277kB time=00:00:10.19 bitrate=2633.9kbits/frame=  314 fps= 25 q=29.0 size=    3475kB time=00:00:10.56 bitrate=2694.1kbits/frame=  322 fps= 24 q=29.0 size=    3584kB time=00:00:10.82 bitrate=2713.7kbits/frame=  330 fps= 24 q=29.0 size=    3694kB time=00:00:11.09 bitrate=2726.3kbits/frame=  336 fps= 24 q=29.0 size=    3774kB time=00:00:11.30 bitrate=2733.9kbits/frame=  344 fps= 23 q=29.0 size=    3882kB time=00:00:11.56 bitrate=2750.3kbits/frame=  353 fps= 23 q=29.0 size=    4016kB time=00:00:11.86 bitrate=2772.5kbits/frame=  363 fps= 23 q=29.0 size=    4165kB time=00:00:12.19 bitrate=2798.7kbits/frame=  371 fps= 22 q=29.0 size=    4263kB time=00:00:12.46 bitrate=2800.6kbits/frame=  381 fps= 22 q=29.0 size=    4429kB time=00:00:12.79 bitrate=2835.7kbits/frame=  388 fps= 22 q=29.0 size=    4557kB time=00:00:13.02 bitrate=2865.6kbits/frame=  397 fps= 22 q=29.0 size=    4678kB time=00:00:13.32 bitrate=2875.5kbits/frame=  406 fps= 22 q=29.0 size=    4773kB time=00:00:13.63 bitrate=2868.5kbits/frame=  414 fps= 21 q=29.0 size=    4871kB time=00:00:13.88 bitrate=2873.6kbits/frame=  419 fps= 21 q=29.0 size=    4954kB time=00:00:14.04 bitrate=2888.6kbits/frame=  427 fps= 21 q=29.0 size=    5046kB time=00:00:14.32 bitrate=2885.1kbits/frame=  435 fps= 21 q=29.0 size=    5141kB time=00:00:14.58 bitrate=2888.2kbits/frame=  443 fps= 21 q=29.0 size=    5232kB time=00:00:14.86 bitrate=2884.1kbits/frame=  452 fps= 20 q=29.0 size=    5333kB time=00:00:15.16 bitrate=2881.5kbits/frame=  463 fps= 20 q=29.0 size=    5442kB time=00:00:15.53 bitrate=2869.9kbits/frame=  472 fps= 20 q=29.0 size=    5552kB time=00:00:15.81 bitrate=2876.5kbits/frame=  479 fps= 20 q=29.0 size=    5663kB time=00:00:16.06 bitrate=2887.2kbits/frame=  489 fps= 20 q=29.0 size=    5798kB time=00:00:16.39 bitrate=2897.4kbits/frame=  499 fps= 20 q=29.0 size=    5918kB time=00:00:16.71 bitrate=2899.9kbits/frame=  509 fps= 20 q=29.0 size=    6043kB time=00:00:17.06 bitrate=2900.5kbits/frame=  521 fps= 20 q=29.0 size=    6191kB time=00:00:17.46 bitrate=2904.7kbits/frame=  533 fps= 20 q=29.0 size=    6304kB time=00:00:17.85 bitrate=2892.0kbits/frame=  542 fps= 20 q=29.0 size=    6391kB time=00:00:18.15 bitrate=2883.5kbits/frame=  553 fps= 20 q=29.0 size=    6525kB time=00:00:18.52 bitrate=2884.9kbits/frame=  563 fps= 20 q=29.0 size=    6635kB time=00:00:18.85 bitrate=2882.8kbits/frame=  573 fps= 20 q=29.0 size=    6740kB time=00:00:19.17 bitrate=2878.9kbits/frame=  585 fps= 20 q=29.0 size=    6868kB time=00:00:19.59 bitrate=2870.8kbits/frame=  595 fps= 20 q=29.0 size=    6986kB time=00:00:19.92 bitrate=2872.6kbits/frame=  606 fps= 20 q=29.0 size=    7095kB time=00:00:20.29 bitrate=2864.1kbits/frame=  617 fps= 20 q=29.0 size=    7237kB time=00:00:20.66 bitrate=2868.8kbits/frame=  629 fps= 20 q=29.0 size=    7452kB time=00:00:21.06 bitrate=2898.8kbits/frame=  639 fps= 20 q=29.0 size=    7566kB time=00:00:21.38 bitrate=2898.1kbits/frame=  647 fps= 20 q=29.0 size=    7684kB time=00:00:21.66 bitrate=2905.7kbits/frame=  657 fps= 20 q=29.0 size=    7807kB time=00:00:21.98 bitrate=2908.3kbits/frame=  667 fps= 20 q=29.0 size=    7919kB time=00:00:22.31 bitrate=2907.3kbits/frame=  677 fps= 20 q=29.0 size=    8046kB time=00:00:22.66 bitrate=2908.3kbits/frame=  687 fps= 20 q=29.0 size=    8156kB time=00:00:22.98 bitrate=2906.7kbits/frame=  699 fps= 20 q=29.0 size=    8294kB time=00:00:23.38 bitrate=2905.9kbits/frame=  711 fps= 20 q=29.0 size=    8414kB time=00:00:23.80 bitrate=2896.2kbits/frame=  722 fps= 20 q=29.0 size=    8510kB time=00:00:24.14 bitrate=2887.0kbits/frame=  733 fps= 20 q=29.0 size=    8630kB time=00:00:24.52 bitrate=2883.1kbits/frame=  745 fps= 20 q=29.0 size=    8751kB time=00:00:24.91 bitrate=2877.3kbits/frame=  756 fps= 20 q=29.0 size=    8857kB time=00:00:25.28 bitrate=2869.5kbits/frame=  766 fps= 20 q=29.0 size=    8979kB time=00:00:25.63 bitrate=2869.5kbits/frame=  777 fps= 20 q=29.0 size=    9088kB time=00:00:25.98 bitrate=2865.3kbits/frame=  787 fps= 20 q=29.0 size=    9187kB time=00:00:26.33 bitrate=2858.1kbits/frame=  798 fps= 20 q=29.0 size=    9308kB time=00:00:26.67 bitrate=2858.0kbits/frame=  808 fps= 20 q=29.0 size=    9400kB time=00:00:27.02 bitrate=2849.1kbits/frame=  820 fps= 20 q=29.0 size=    9554kB time=00:00:27.42 bitrate=2854.2kbits/frame=  830 fps= 20 q=29.0 size=    9662kB time=00:00:27.74 bitrate=2852.4kbits/frame=  842 fps= 20 q=29.0 size=    9778kB time=00:00:28.16 bitrate=2843.9kbits/frame=  854 fps= 20 q=29.0 size=    9886kB time=00:00:28.56 bitrate=2835.6kbits/frame=  864 fps= 20 q=29.0 size=    9992kB time=00:00:28.88 bitrate=2833.9kbits/frame=  876 fps= 20 q=29.0 size=   10112kB time=00:00:29.28 bitrate=2829.2kbits/frame=  889 fps= 19 q=29.0 size=   21309kB time=00:00:58.00 bitrate=3009.5kbits/frame= 1750 fps= 19 q=29.0 size=   21427kB time=00:00:58.42 bitrate=3004.5kbits/frame= 1761 fps= 19 q=29.0 size=   21553kB time=00:00:58.79 bitrate=3003.1kbits/frame= 1771 fps= 19 q=29.0 size=   21669kB time=00:00:59.11 bitrate=3002.7kbits/frame= 1783 fps= 19 q=29.0 size=   21787kB time=00:00:59.51 bitrate=2999.0kbits/frame= 1793 fps= 19 q=29.0 size=   21902kB time=00:00:59.86 bitrate=2997.3kbits/[Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in1:v0, 1 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in1:a0, 0 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] Segment finished at pts=60135827
    frame= 1805 fps= 19 q=29.0 size=   21990kB time=00:01:00.23 bitrate=2990.7kbits/frame= 1816 fps= 19 q=29.0 size=   22117kB time=00:01:00.60 bitrate=2989.6kbits/frame= 1830 fps= 19 q=29.0 size=   bitrate=3521.1kbits/frame= 2194 fps= 19 q=29.0 size=   31450kB time=00:01:13.21 bitrate=3519.0kbits/frame= 2213 fps= 19 q=29.0 size=   31591kB time=00:01:13.83 bitrate=3504.9kbits/[Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in2:v0, 1 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] EOF on in2:a0, 0 streams left in segment.
    [Parsed_concat_0 @ 0x7f6dc69b5ca0] Segment finished at pts=74253559
    No more output streams to write to, finishing.
    frame= 2227 fps= 19 q=-1.0 Lsize=   32179kB time=00:01:14.25 bitrate=3549.9kbits/s speed=0.633x    
    video:31198kB audio:901kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.247438%
    Input file #0 (/var/www/Intro30.mp4):
     Input stream #0:0 (video): 87 packets read (1271526 bytes); 87 frames decoded;
     Input stream #0:1 (audio): 126 packets read (773 bytes); 125 frames decoded (128000 samples);
     Total: 213 packets (1272299 bytes) demuxed
    Input file #1 (/var/www/temp/videoHD.mp4):
     Input stream #1:0 (video): 1717 packets read (21108999 bytes); 1717 frames decoded;
     Input stream #1:1 (audio): 2464 packets read (918725 bytes); 2463 frames decoded (2522112 samples);
     Total: 4181 packets (22027724 bytes) demuxed
    Input file #2 (/var/www/Credits30.mp4):
     Input stream #2:0 (video): 423 packets read (10066322 bytes); 423 frames decoded;
     Input stream #2:1 (audio): 609 packets read (3705 bytes); 608 frames decoded (622592 samples);
     Total: 1032 packets (10070027 bytes) demuxed
    Output file #0 (/var/www/temp/merged.mp4):
     Output stream #0:0 (video): 2227 frames encoded; 2227 packets muxed (31946574 bytes);
     Output stream #0:1 (audio): 3198 frames encoded (3274582 samples); 3199 packets muxed (923102 bytes);
     Total: 5426 packets (32869676 bytes) muxed
    [libx264 @ 0x7f6dc62d1aa0] frame I:19    Avg QP:18.19  size:110490
    [libx264 @ 0x7f6dc62d1aa0] frame P:851   Avg QP:21.97  size: 23670
    [libx264 @ 0x7f6dc62d1aa0] frame B:1357  Avg QP:25.31  size:  7150
    [libx264 @ 0x7f6dc62d1aa0] consecutive B-frames:  3.1% 44.8%  6.1% 46.0%
    [libx264 @ 0x7f6dc62d1aa0] mb I  I16..4: 31.3% 59.2%  9.6%
    [libx264 @ 0x7f6dc62d1aa0] mb P  I16..4:  4.5% 11.6%  0.7%  P16..4: 40.9%  8.2%  2.5%  0.0%  0.0%    skip:31.6%
    [libx264 @ 0x7f6dc62d1aa0] mb B  I16..4:  0.5%  1.2%  0.2%  B16..8: 28.5%  2.0%  0.2%  direct: 1.0%  skip:66.3%  L0:42.2% L1:55.1% BI: 2.8%
    [libx264 @ 0x7f6dc62d1aa0] 8x8 transform intra:67.4% inter:89.6%
    [libx264 @ 0x7f6dc62d1aa0] coded y,uvDC,uvAC intra: 39.8% 43.5% 4.0% inter: 7.8% 12.4% 0.1%
    [libx264 @ 0x7f6dc62d1aa0] i16 v,h,dc,p: 25% 33% 18% 24%
    [libx264 @ 0x7f6dc62d1aa0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 24% 25%  3%  5%  5%  6%  4%  5%
    [libx264 @ 0x7f6dc62d1aa0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 30% 14%  5%  6%  5%  6%  4%  7%
    [libx264 @ 0x7f6dc62d1aa0] i8c dc,h,v,p: 58% 20% 17%  4%
    [libx264 @ 0x7f6dc62d1aa0] Weighted P-Frames: Y:0.8% UV:0.2%
    [libx264 @ 0x7f6dc62d1aa0] ref P L0: 73.9% 12.2% 11.3%  2.7%  0.0%
    [libx264 @ 0x7f6dc62d1aa0] ref B L0: 92.1%  6.8%  1.1%
    [libx264 @ 0x7f6dc62d1aa0] ref B L1: 98.4%  1.6%
    [libx264 @ 0x7f6dc62d1aa0] kb/s:3442.75
    [aac @ 0x7f6dc62dd100] Qavg: 18520.436

    Some lines removed to keep under the line limit.

    Here is the python method I use to execute the ffmpeg lines.

    def ffmpeg(args):
       err = None
       command = [
           ffmpegcmd, '-y',
           '-loglevel', loglevel
       ] + args
       ffmpeg = subprocess.Popen(command, stderr=subprocess.PIPE ,stdout=subprocess.PIPE, universal_newlines=True)
       while err == None:
           out, err = ffmpeg.communicate()
           time.sleep(1)
       if err:
           print(" ".join(command))
           raise Exception(err)

    *Edit

    When ever I need to use a command that requires single quotes around the arguments i.e. '[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] concat=n=3:v=1:a=1 [v] [a]' the above function wouldn’t work. So I made another function for those case which deals with the command as a string. Here is is.

    def ffmpegStr(args):
       err = None
       command = [
           ffmpegcmd, '-y',
           '-loglevel', loglevel
       ] + args
       commandStr = " ".join(command)
       print(commandStr)
       ffmpeg = subprocess.Popen(shlex.split(commandStr), stderr=subprocess.PIPE ,stdout=subprocess.PIPE, universal_newlines=True)
       while err == None:
           out, err = ffmpeg.communicate()
           time.sleep(1)
       if err:
           print(commandStr)
           raise Exception(err)

    As you can see I’ve added a print to see what is being handed to the subprocess.Popen function. This is the method that is being used when the ffmpeg command does not run as expected.

    I use ffmpegcmd as a variable so that I can change the ffmpeg version if needed in both functions with 1 change.

    The args is just the list of arguments specific to what I want ffmpeg to do.

    I also like to have the option of changing the loglevel in both functions with 1 line and so use a variable for this.

    *End Edit

    Why the difference in how it is handled ?

    Cheers,

    Stu