
Recherche avancée
Autres articles (35)
-
MediaSPIP Init et Diogène : types de publications de MediaSPIP
11 novembre 2010, parÀ l’installation d’un site MediaSPIP, le plugin MediaSPIP Init réalise certaines opérations dont la principale consiste à créer quatre rubriques principales dans le site et de créer cinq templates de formulaire pour Diogène.
Ces quatre rubriques principales (aussi appelées secteurs) sont : Medias ; Sites ; Editos ; Actualités ;
Pour chacune de ces rubriques est créé un template de formulaire spécifique éponyme. Pour la rubrique "Medias" un second template "catégorie" est créé permettant d’ajouter (...) -
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...) -
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)
Sur d’autres sites (2951)
-
Using ffmpeg for streaming video composition from Python : why the sound is cut only when streaming into a mp4 file ?
4 décembre 2017, par redantlabsI am using ffmpeg within Python for automatizing some video compositions. To do so, I am using the subprocess module of Python and run a ffmpeg command with a pipe input. This allows me to stream frame by frame the video composition from my array of raw images (numpy matrices) into ffmpeg. In the following example, I reduced the video composition to a simple video of a duration of 12 seconds. The produced ffmpeg command is :
ffmpeg -i stream_audio.mp3 -re -f rawvideo -vcodec rawvideo -s 1280x720 -pix_fmt rgb24 -r 25 -i - -map 0:a -map 1:v -y -strict -2 -f mp4 -pix_fmt yuv420p out.mp4
The file stream_audio.mp3 is a well formed mp3 file corresponding to the audio output of the output mp4 file. However, the sound in the output file out.mp4 is cut 3 seconds before the end.
If I am trying to output any other format (for example avi), I do not observe this problem. The following command produces a well formed avi file.
ffmpeg -i ./stream_audio.mp3 -re -f rawvideo -vcodec rawvideo -s 1280x720 -pix_fmt rgb24 -r 25 -i - -map 0:a -map 1:v -y -b 4096k -f avi -pix_fmt yuv420p out.avi
I tried to reproduce the bug with the most simple ffmpeg command without passing by Python, but did not succeed.The closest I have done is the following :
Building a raw video file with the correct specifications
ffmpeg -i samplevideo.mp4 -f rawvideo -vcodec rawvideo -acodec none -s 1280x720 -pix_fmt rgb24 -r 25 samplevideo.raw
Streaming the raw video file into the ffmpeg command
cat samplevideo.raw | ffmpeg -i /tmp/stream_audio.mp3 -re -f rawvideo -vcodec rawvideo -s 1280x720 -pix_fmt rgb24 -r 25 -i - -map 0:a -map 1:v
-y -strict -2 -f mp4 -pix_fmt yuv420p -ss 00:00:00 -t 00:00:12 out.mp4Here is the version of ffmpeg I am using :
ffmpeg version 3.1.9 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20161221 (Red Hat 6.3.1-1)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Hyper fast Audio and Video encoderThe file samplevideo.mp4 can be found here : sample videos, the stream_audio.mp3 file is a simple extraction of the audio track of the samplevideo.mp4 file :
ffmpeg -i samplevideo.mp4 stream_audio.mp3
Thanks for your help.
p.s : Here are the different logs of the ffmpeg commands :
Command generated by my Python script with mp4 :
Input #0, mp3, from './stream_audio.mp3':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:29.59, start: 0.023021, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
encoder : Lavc57.48
Input #1, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 552960 kb/s
Stream #1:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720, 552960 kb/s, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0xf5cb748ac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0xf5cb748ac0] profile High, level 3.1
[libx264 @ 0xf5cb748ac0] 264 - core 148 r2708 86b7198 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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
[mp4 @ 0xf5cb7462a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.48.101 aac
Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.48.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> aac (native))
Stream #1:0 -> #0:1 (rawvideo (native) -> h264 (libx264))
[rawvideo @ 0xf5cb722860] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 14 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 27 fps= 27 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 40 fps= 26 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 52 fps= 26 q=28.0 size= 113kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 65 fps= 26 q=28.0 size= 188kB time=00:00:00.49 bitrate=3145.8kbits/s speed=0.194x
frame= 77 fps= 25 q=28.0 size= 320kB time=00:00:01.00 bitrate=2615.3kbits/s speed=0.331x
frame= 90 fps= 25 q=28.0 size= 450kB time=00:00:01.51 bitrate=2431.3kbits/s speed=0.428x
frame= 103 fps= 25 q=28.0 size= 592kB time=00:00:02.00 bitrate=2418.9kbits/s speed=0.496x
frame= 116 fps= 25 q=28.0 size= 731kB time=00:00:02.52 bitrate=2376.1kbits/s speed=0.554x
frame= 128 fps= 25 q=28.0 size= 849kB time=00:00:03.02 bitrate=2295.6kbits/s speed=0.599x
frame= 141 fps= 25 q=28.0 size= 931kB time=00:00:03.54 bitrate=2153.0kbits/s speed=0.637x
frame= 153 fps= 25 q=28.0 size= 983kB time=00:00:04.03 bitrate=1996.7kbits/s speed=0.665x
frame= 166 fps= 25 q=28.0 size= 1067kB time=00:00:04.56 bitrate=1914.5kbits/s speed=0.695x
frame= 179 fps= 25 q=28.0 size= 1123kB time=00:00:05.04 bitrate=1824.8kbits/s speed=0.712x
frame= 191 fps= 25 q=28.0 size= 1213kB time=00:00:05.54 bitrate=1791.0kbits/s speed=0.732x
frame= 204 fps= 25 q=28.0 size= 1271kB time=00:00:06.05 bitrate=1718.5kbits/s speed=0.749x
frame= 217 fps= 25 q=28.0 size= 1346kB time=00:00:06.57 bitrate=1678.1kbits/s speed=0.764x
frame= 230 fps= 25 q=28.0 size= 1452kB time=00:00:07.08 bitrate=1678.9kbits/s speed=0.778x
frame= 242 fps= 25 q=28.0 size= 1567kB time=00:00:07.59 bitrate=1690.3kbits/s speed=0.79x
frame= 255 fps= 25 q=28.0 size= 1660kB time=00:00:08.08 bitrate=1682.4kbits/s speed=0.799x
frame= 267 fps= 25 q=28.0 size= 1739kB time=00:00:08.59 bitrate=1657.1kbits/s speed=0.81x
frame= 280 fps= 25 q=28.0 size= 1751kB time=00:00:09.08 bitrate=1578.1kbits/s speed=0.817x
frame= 291 fps= 24 q=-1.0 Lsize= 1864kB time=00:00:11.52 bitrate=1325.7kbits/s speed=0.954x
video:1707kB audio:149kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.437266%
[aac @ 0xf5cb747540] Qavg: 202.422
[libx264 @ 0xf5cb748ac0] frame I:2 Avg QP:15.83 size: 78710
[libx264 @ 0xf5cb748ac0] frame P:183 Avg QP:21.13 size: 7293
[libx264 @ 0xf5cb748ac0] frame B:106 Avg QP:26.82 size: 2406
[libx264 @ 0xf5cb748ac0] consecutive B-frames: 47.8% 10.3% 2.1% 39.9%
[libx264 @ 0xf5cb748ac0] mb I I16..4: 22.1% 32.5% 45.4%
[libx264 @ 0xf5cb748ac0] mb P I16..4: 0.8% 1.4% 0.2% P16..4: 25.3% 6.3% 3.1% 0.0% 0.0% skip:62.9%
[libx264 @ 0xf5cb748ac0] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 39.0% 1.7% 0.2% direct: 0.4% skip:58.5% L0:47.3% L1:49.6% BI: 3.1%
[libx264 @ 0xf5cb748ac0] 8x8 transform intra:50.3% inter:57.9%
[libx264 @ 0xf5cb748ac0] coded y,uvDC,uvAC intra: 49.5% 65.3% 23.0% inter: 7.8% 10.2% 0.5%
[libx264 @ 0xf5cb748ac0] i16 v,h,dc,p: 30% 32% 11% 27%
[libx264 @ 0xf5cb748ac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 21% 23% 4% 5% 7% 5% 5% 5%
[libx264 @ 0xf5cb748ac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 15% 11% 8% 8% 9% 7% 12% 7%
[libx264 @ 0xf5cb748ac0] i8c dc,h,v,p: 51% 20% 21% 8%
[libx264 @ 0xf5cb748ac0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0xf5cb748ac0] ref P L0: 79.8% 11.4% 7.6% 1.2%
[libx264 @ 0xf5cb748ac0] ref B L0: 96.9% 2.8% 0.4%
[libx264 @ 0xf5cb748ac0] ref B L1: 97.7% 2.3%
[libx264 @ 0xf5cb748ac0] kb/s:1200.72
Exiting normally, received signal 15.Command generated by my Python script with avi :
Input #0, mp3, from './stream_audio.mp3':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:29.59, start: 0.023021, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
encoder : Lavc57.48
Input #1, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 552960 kb/s
Stream #1:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720, 552960 kb/s, 25 tbr, 25 tbn, 25 tbc
Please use -b:a or -b:v, -b is ambiguous
[avi @ 0x82147c30e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'out.avi':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
ISFT : Lavf57.41.100
Stream #0:0: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p
Metadata:
encoder : Lavc57.48.101 libmp3lame
Stream #0:1: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720, q=2-31, 4096 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.48.101 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/4096000 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame))
Stream #1:0 -> #0:1 (rawvideo (native) -> mpeg4 (native))
[rawvideo @ 0x821479f820] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 14 fps=0.0 q=2.6 size= 553kB time=00:00:00.56 bitrate=8082.6kbits/s speed= 1.1x
frame= 27 fps= 27 q=5.4 size= 858kB time=00:00:01.08 bitrate=6507.5kbits/s speed=1.06x
frame= 40 fps= 26 q=5.9 size= 1089kB time=00:00:01.60 bitrate=5574.9kbits/s speed=1.05x
frame= 52 fps= 26 q=5.5 size= 1332kB time=00:00:02.08 bitrate=5225.6kbits/s speed=1.03x
frame= 65 fps= 26 q=4.9 size= 1582kB time=00:00:02.60 bitrate=4985.6kbits/s speed=1.03x
frame= 78 fps= 26 q=4.3 size= 1816kB time=00:00:03.12 bitrate=4768.1kbits/s speed=1.03x
frame= 90 fps= 25 q=2.8 size= 2035kB time=00:00:03.60 bitrate=4631.7kbits/s speed=1.02x
frame= 103 fps= 25 q=2.3 size= 2288kB time=00:00:04.12 bitrate=4549.8kbits/s speed=1.02x
frame= 116 fps= 25 q=2.4 size= 2558kB time=00:00:04.64 bitrate=4516.3kbits/s speed=1.02x
frame= 128 fps= 25 q=2.3 size= 2835kB time=00:00:05.12 bitrate=4535.4kbits/s speed=1.01x
frame= 141 fps= 25 q=3.1 size= 3103kB time=00:00:05.64 bitrate=4506.6kbits/s speed=1.01x
frame= 154 fps= 25 q=2.8 size= 3381kB time=00:00:06.16 bitrate=4495.9kbits/s speed=1.01x
frame= 166 fps= 25 q=3.4 size= 3648kB time=00:00:06.64 bitrate=4494.9kbits/s speed=1.01x
frame= 179 fps= 25 q=3.3 size= 3894kB time=00:00:07.16 bitrate=4455.7kbits/s speed=1.01x
frame= 192 fps= 25 q=3.2 size= 4128kB time=00:00:07.68 bitrate=4402.9kbits/s speed=1.01x
frame= 204 fps= 25 q=3.4 size= 4404kB time=00:00:08.16 bitrate=4420.9kbits/s speed=1.01x
frame= 217 fps= 25 q=2.0 size= 4592kB time=00:00:08.68 bitrate=4334.0kbits/s speed=1.01x
frame= 230 fps= 25 q=2.0 size= 4657kB time=00:00:09.20 bitrate=4147.2kbits/s speed=1.01x
frame= 242 fps= 25 q=2.0 size= 4736kB time=00:00:09.68 bitrate=4007.9kbits/s speed=1.01x
frame= 255 fps= 25 q=2.0 size= 4830kB time=00:00:10.20 bitrate=3879.0kbits/s speed=1.01x
frame= 267 fps= 25 q=2.0 size= 4953kB time=00:00:10.68 bitrate=3799.5kbits/s speed=1.01x
frame= 280 fps= 25 q=2.0 size= 5093kB time=00:00:11.20 bitrate=3722.3kbits/s speed=1.01x
frame= 291 fps= 25 q=2.0 Lsize= 5209kB time=00:00:11.68 bitrate=3650.9kbits/s speed=1.01x
video:4998kB audio:183kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.542552%
Exiting normally, received signal 15.Pure command line for mp4 format :
Input #0, mp3, from './stream_audio.mp3':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:29.59, start: 0.023021, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
Metadata:
encoder : Lavc57.48
Input #1, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 552960 kb/s
Stream #1:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720, 552960 kb/s, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x75fc583aa0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x75fc583aa0] profile High, level 3.1
[libx264 @ 0x75fc583aa0] 264 - core 148 r2708 86b7198 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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
[mp4 @ 0x75fc581280] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.48.101 aac
Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.48.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> aac (native))
Stream #1:0 -> #0:1 (rawvideo (native) -> h264 (libx264))
[rawvideo @ 0x75fc55d840] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 14 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 27 fps= 27 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 39 fps= 26 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 52 fps= 26 q=28.0 size= 113kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 65 fps= 26 q=28.0 size= 188kB time=00:00:00.48 bitrate=3209.4kbits/s speed=0.191x
frame= 77 fps= 26 q=28.0 size= 320kB time=00:00:01.00 bitrate=2615.3kbits/s speed=0.332x
frame= 90 fps= 26 q=28.0 size= 450kB time=00:00:01.51 bitrate=2431.3kbits/s speed=0.43x
frame= 102 fps= 25 q=28.0 size= 591kB time=00:00:01.98 bitrate=2442.1kbits/s speed=0.493x
frame= 115 fps= 25 q=28.0 size= 731kB time=00:00:02.51 bitrate=2377.6kbits/s speed=0.556x
frame= 128 fps= 25 q=28.0 size= 845kB time=00:00:03.00 bitrate=2307.7kbits/s speed=0.596x
frame= 140 fps= 25 q=28.0 size= 930kB time=00:00:03.52 bitrate=2164.6kbits/s speed=0.636x
frame= 153 fps= 25 q=28.0 size= 983kB time=00:00:04.03 bitrate=1996.7kbits/s speed=0.668x
frame= 165 fps= 25 q=28.0 size= 1063kB time=00:00:04.52 bitrate=1925.2kbits/s speed=0.691x
frame= 178 fps= 25 q=28.0 size= 1122kB time=00:00:05.03 bitrate=1826.2kbits/s speed=0.714x
frame= 191 fps= 25 q=28.0 size= 1203kB time=00:00:05.52 bitrate=1783.6kbits/s speed=0.732x
frame= 203 fps= 25 q=28.0 size= 1270kB time=00:00:06.03 bitrate=1723.7kbits/s speed=0.749x
frame= 216 fps= 25 q=28.0 size= 1339kB time=00:00:06.52 bitrate=1680.5kbits/s speed=0.763x
frame= 228 fps= 25 q=28.0 size= 1443kB time=00:00:07.06 bitrate=1674.1kbits/s speed=0.779x
frame= 241 fps= 25 q=28.0 size= 1558kB time=00:00:07.55 bitrate=1690.0kbits/s speed=0.789x
frame= 254 fps= 25 q=28.0 size= 1654kB time=00:00:08.04 bitrate=1685.0kbits/s speed=0.799x
frame= 266 fps= 25 q=28.0 size= 1738kB time=00:00:08.55 bitrate=1664.6kbits/s speed=0.809x
frame= 279 fps= 25 q=28.0 size= 1750kB time=00:00:09.06 bitrate=1581.2kbits/s speed=0.818x
frame= 291 fps= 25 q=28.0 size= 1765kB time=00:00:09.55 bitrate=1512.7kbits/s speed=0.825x
frame= 300 fps= 25 q=28.0 size= 1779kB time=00:00:11.73 bitrate=1242.1kbits/s speed=0.971x
frame= 300 fps= 24 q=-1.0 Lsize= 1917kB time=00:00:12.01 bitrate=1307.2kbits/s speed=0.955x
video:1720kB audio:188kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.488004%
[aac @ 0x75fc582520] Qavg: 221.585
[libx264 @ 0x75fc583aa0] frame I:2 Avg QP:15.83 size: 78710
[libx264 @ 0x75fc583aa0] frame P:185 Avg QP:21.02 size: 7259
[libx264 @ 0x75fc583aa0] frame B:113 Avg QP:26.59 size: 2298
[libx264 @ 0x75fc583aa0] consecutive B-frames: 46.3% 10.0% 1.0% 42.7%
[libx264 @ 0x75fc583aa0] mb I I16..4: 22.1% 32.5% 45.4%
[libx264 @ 0x75fc583aa0] mb P I16..4: 0.8% 1.4% 0.2% P16..4: 25.2% 6.3% 3.1% 0.0% 0.0% skip:63.0%
[libx264 @ 0x75fc583aa0] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 37.3% 1.6% 0.2% direct: 0.4% skip:60.2% L0:47.3% L1:49.6% BI: 3.0%
[libx264 @ 0x75fc583aa0] 8x8 transform intra:50.5% inter:58.1%
[libx264 @ 0x75fc583aa0] coded y,uvDC,uvAC intra: 49.4% 65.2% 22.9% inter: 7.7% 10.0% 0.5%
[libx264 @ 0x75fc583aa0] i16 v,h,dc,p: 29% 32% 11% 28%
[libx264 @ 0x75fc583aa0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 21% 23% 4% 5% 6% 5% 5% 5%
[libx264 @ 0x75fc583aa0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 15% 11% 8% 8% 9% 7% 12% 7%
[libx264 @ 0x75fc583aa0] i8c dc,h,v,p: 51% 20% 21% 8%
[libx264 @ 0x75fc583aa0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x75fc583aa0] ref P L0: 79.7% 11.4% 7.7% 1.2%
[libx264 @ 0x75fc583aa0] ref B L0: 96.8% 2.9% 0.4%
[libx264 @ 0x75fc583aa0] ref B L1: 97.7% 2.3%
[libx264 @ 0x75fc583aa0] kb/s:1173.39 -
FFmpeg skipping time after concat
19 septembre 2017, par Manul HüttingerI am trying to concatenate videos and in my resulting Videos I have the issue that at the concat edges my video is skipping/glitching.
General Workflow
in general my workflow looks like this
- Stream via ffmpeg
- capture stream and segment all 2 mins in to TS files
- concat TS file to MP4 video
- cut MP4 video at the desired Timestamps
Detailed Look at Step 4
as I am handling 2-hours+ videos I don’t want to re-encode the whole video. So I am looking for the closest I Frames to my In and Outpoint and cut 1 Frame before/after. As my result I get 3 Videos (front/middle/back). Now it is only needed to re-encode front and back and concat all three Videos.
So far the theoryGeneral Observations
As I look at my resulting video, I obeservated the following.
frontpart duration is e.g. 3.2 secs. I skip framewise through the Video and get nice and clean timestamps ( 00:00:02.620, 00:00:02:660 )
As soon as I get to my cutting edge the timestamps are skipping some frames and changing (00:00:03.200, 00:00:03.408 ,00:00:03.409). When I look only at the single frame images, their are no missing/dropped frameswhen I concat my TS files, the results contains a messed up frame rate e.g from constant 25 F/s to 25.0096 F/s
FFMPEG instructions
FRONT Video
ffmpeg -ss 232.52 -i src.mp4 -t 3.24 -filter_complex "setpts=PTS-STARTPTS" -vcodec libx264 -profile:v baseline -level 31 -bf 0 -f mp4 -y front.mp4
ffmpeg version n3.3 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-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-libssh --enable-openssl
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
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.33.100
Duration: 01:06:00.33, start: 0.000000, bitrate: 610 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], 537 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> setpts (graph 0)
setpts (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x31ea160] using SAR=1/1
[libx264 @ 0x31ea160] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
[libx264 @ 0x31ea160] profile Constrained Baseline, level 3.1
[libx264 @ 0x31ea160] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 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 'front.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], q=-1--1, 25 fps, 12800 tbn, 25 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(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.89.100 aac
frame= 81 fps= 31 q=-1.0 Lsize= 151kB time=00:00:03.25 bitrate= 379.5kbits/s speed=1.23x
video:119kB audio:28kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.531915%
[libx264 @ 0x31ea160] frame I:1 Avg QP:17.43 size: 38268
[libx264 @ 0x31ea160] frame P:80 Avg QP:21.05 size: 1038
[libx264 @ 0x31ea160] mb I I16..4: 71.4% 0.0% 28.6%
[libx264 @ 0x31ea160] mb P I16..4: 0.2% 0.0% 0.0% P16..4: 7.8% 1.8% 0.6% 0.0% 0.0% skip:89.6%
[libx264 @ 0x31ea160] coded y,uvDC,uvAC intra: 21.8% 40.8% 23.1% inter: 1.6% 4.2% 0.2%
[libx264 @ 0x31ea160] i16 v,h,dc,p: 66% 25% 5% 4%
[libx264 @ 0x31ea160] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 28% 15% 4% 4% 5% 4% 5% 4%
[libx264 @ 0x31ea160] i8c dc,h,v,p: 51% 24% 21% 4%
[libx264 @ 0x31ea160] ref P L0: 74.3% 15.2% 10.5%
[libx264 @ 0x31ea160] kb/s:299.56
[aac @ 0x31edfa0] Qavg: 123.323MIDDLE Video
ffmpeg -ss 235.88 -i src.mp4 -c copy -t 1492.96 -f mp4 -y middle.mp4
ffmpeg version n3.3 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-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-libssh --enable-openssl
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
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.33.100
Duration: 01:06:00.33, start: 0.000000, bitrate: 610 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], 537 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, mp4, to 'middle.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Stream #0:0(und): Video: h264 (Main) ([33][0][0][0] / 0x0021), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], q=2-31, 537 kb/s, 25 fps, 25 tbr, 90k tbn, 90k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=37329 fps=16333 q=-1.0 Lsize= 113774kB time=00:24:52.95 bitrate= 624.3kbits/s speed= 653x
video:100359kB audio:12095kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.173957%BACK Video
ffmpeg -ss 1728.88 -i 'src.mp4' -t 3.9199999999998 -filter_complex "setpts=PTS-STARTPTS" -vcodec libx264 -profile:v baseline -level 31 -bf 0 -f mp4 -y back.mp4
ffmpeg version n3.3 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-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-libssh --enable-openssl
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
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'src.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.33.100
Duration: 01:06:00.33, start: 0.000000, bitrate: 610 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], 537 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 65 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> setpts (graph 0)
setpts (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x2672160] using SAR=1/1
[libx264 @ 0x2672160] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
[libx264 @ 0x2672160] profile Constrained Baseline, level 3.1
[libx264 @ 0x2672160] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 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 'back.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x464 [SAR 1:1 DAR 80:29], q=-1--1, 25 fps, 12800 tbn, 25 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(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.89.100 aac
frame= 98 fps= 27 q=-1.0 Lsize= 268kB time=00:00:03.92 bitrate= 559.2kbits/s speed=1.07x
video:230kB audio:33kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.538479%
[libx264 @ 0x2672160] frame I:1 Avg QP:19.57 size:112129
[libx264 @ 0x2672160] frame P:97 Avg QP:21.68 size: 1270
[libx264 @ 0x2672160] mb I I16..4: 35.4% 0.0% 64.6%
[libx264 @ 0x2672160] mb P I16..4: 0.2% 0.0% 0.1% P16..4: 6.9% 2.0% 0.8% 0.0% 0.0% skip:90.1%
[libx264 @ 0x2672160] coded y,uvDC,uvAC intra: 54.4% 69.1% 54.2% inter: 2.0% 3.6% 0.3%
[libx264 @ 0x2672160] i16 v,h,dc,p: 63% 23% 8% 6%
[libx264 @ 0x2672160] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 17% 11% 6% 8% 9% 7% 8% 8%
[libx264 @ 0x2672160] i8c dc,h,v,p: 50% 18% 24% 7%
[libx264 @ 0x2672160] ref P L0: 81.8% 11.5% 6.7%
[libx264 @ 0x2672160] kb/s:480.15
[aac @ 0x2675fa0] Qavg: 119.994CONCAT Videos
ffmpeg -f concat -safe 0 -i concat.txt -c copy -r 25 -y /concat.mp4
ffmpeg version n3.3 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-cflags=-I/usr/include --extra-ldflags=-L/usr/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-libssh --enable-openssl
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
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, concat, from 'concat.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x464 [SAR 1:1 DAR 80:29], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1(und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 74 kb/s
Output #0, mp4, to 'concat.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (Constrained Baseline) ([33][0][0][0] / 0x0021), yuv420p(progressive), 1280x464 [SAR 1:1 DAR 80:29], q=2-31, 25 fps, 25 tbr, 12800 tbn, 25 tbc
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 74 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=37508 fps=7256 q=-1.0 Lsize= 114285kB time=00:25:00.59 bitrate= 623.9kbits/s speed= 290x
video:100672kB audio:12598kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 0.896435%
If needed I can provide samples.
-
How to combine multiple images and multiple audio files into one video with ffmpeg ?
14 mars, par nachocabI have two images
image1.png
andimage2.png
, they both have the same dimensions. I also have two audio filesaudio1.wav
andaudio2.wav
they each have different lengths. I want to make a video that showsimage1.png
duringaudio1.wav
and thenimage2.png
overaudio2.wav
.


I've tried two methods, but they don't work. The images show correctly, but the durations are not synced with the audio.



Method 1 : create videos separately and combine them :



image1 => video1



ffmpeg -loop 1 \
 -y \
 -i "image1.png" \
 -i "audio1.wav" \
 -c:v libx264 -tune stillimage -pix_fmt yuv420p \
 -c:a aac -b:a 192k \
 -shortest \
 "video1.mp4"

ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
 built with Apple LLVM version 8.0.0 (clang-800.0.38)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.2.0/include/openjpeg-2.2 --enable-nonfree --enable-vda
 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
Input #0, png_pipe, from 'image1.png':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: png, rgba(pc), 800x800, 25 fps, 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'audio1.wav':
 Metadata:
 title : untitled
 track : 1
 Duration: 00:00:03.70, bitrate: 1411 kb/s
 Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
 Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fead980bc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fead980bc00] profile High, level 3.1
[libx264 @ 0x7fead980bc00] 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:-3:-3 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=2.00:0.70 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-4 threads=12 lookahead_threads=2 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.20
Output #0, mp4, to 'video1.mp4':
 Metadata:
 encoder : Lavf57.71.100
 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p(progressive), 800x800, q=-1--1, 25 fps, 12800 tbn, 25 tbc
 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, 192 kb/s
 Metadata:
 encoder : Lavc57.89.100 aac
frame= 151 fps=0.0 q=-1.0 Lsize= 106kB time=00:00:05.92 bitrate= 146.6kbits/s speed=6.73x
video:13kB audio:87kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.016360%
[libx264 @ 0x7fead980bc00] frame I:1 Avg QP:14.87 size: 5746
[libx264 @ 0x7fead980bc00] frame P:38 Avg QP:12.15 size: 51
[libx264 @ 0x7fead980bc00] frame B:112 Avg QP:16.81 size: 48
[libx264 @ 0x7fead980bc00] consecutive B-frames: 0.7% 1.3% 0.0% 98.0%
[libx264 @ 0x7fead980bc00] mb I I16..4: 46.9% 44.7% 8.4%
[libx264 @ 0x7fead980bc00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:99.9%
[libx264 @ 0x7fead980bc00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.7% L0:63.5% L1:36.5% BI: 0.0%
[libx264 @ 0x7fead980bc00] 8x8 transform intra:40.7% inter:20.0%
[libx264 @ 0x7fead980bc00] coded y,uvDC,uvAC intra: 4.9% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7fead980bc00] i16 v,h,dc,p: 82% 13% 4% 0%
[libx264 @ 0x7fead980bc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 74% 2% 24% 0% 0% 0% 0% 0% 0%
[libx264 @ 0x7fead980bc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 24% 32% 2% 2% 2% 2% 1% 2%
[libx264 @ 0x7fead980bc00] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x7fead980bc00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fead980bc00] ref B L0: 48.0% 52.0%
[libx264 @ 0x7fead980bc00] ref B L1: 99.5% 0.5%
[libx264 @ 0x7fead980bc00] kb/s:17.36
[aac @ 0x7fead981b400] Qavg: 535.938




image2 => video2



ffmpeg -loop 1 \
 -y \
 -i "image2.png" \
 -i "audio2.wav" \
 -c:v libx264 -tune stillimage -pix_fmt yuv420p \
 -c:a aac -b:a 192k \
 -shortest \
 "video2.mp4"

ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
 built with Apple LLVM version 8.0.0 (clang-800.0.38)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.2.0/include/openjpeg-2.2 --enable-nonfree --enable-vda
 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
Input #0, png_pipe, from 'image2.png':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: png, rgba(pc), 800x800, 25 fps, 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'audio2.wav':
 Metadata:
 title : untitled
 track : 2
 Duration: 00:00:05.49, bitrate: 1411 kb/s
 Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
 Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fa0e201ce00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fa0e201ce00] profile High, level 3.1
[libx264 @ 0x7fa0e201ce00] 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:-3:-3 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=2.00:0.70 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-4 threads=12 lookahead_threads=2 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.20
Output #0, mp4, to 'video2.mp4':
 Metadata:
 encoder : Lavf57.71.100
 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p(progressive), 800x800, q=-1--1, 25 fps, 12800 tbn, 25 tbc
 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, 192 kb/s
 Metadata:
 encoder : Lavc57.89.100 aac
frame= 195 fps=177 q=-1.0 Lsize= 150kB time=00:00:07.68 bitrate= 160.2kbits/s speed=6.96x
video:14kB audio:129kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.516541%
[libx264 @ 0x7fa0e201ce00] frame I:1 Avg QP: 9.03 size: 6402
[libx264 @ 0x7fa0e201ce00] frame P:49 Avg QP: 6.59 size: 41
[libx264 @ 0x7fa0e201ce00] frame B:145 Avg QP: 9.67 size: 39
[libx264 @ 0x7fa0e201ce00] consecutive B-frames: 0.5% 1.0% 0.0% 98.5%
[libx264 @ 0x7fa0e201ce00] mb I I16..4: 54.7% 36.0% 9.3%
[libx264 @ 0x7fa0e201ce00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x7fa0e201ce00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.8% L0:70.1% L1:29.9% BI: 0.0%
[libx264 @ 0x7fa0e201ce00] 8x8 transform intra:36.0% inter:14.3%
[libx264 @ 0x7fa0e201ce00] coded y,uvDC,uvAC intra: 4.3% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7fa0e201ce00] i16 v,h,dc,p: 91% 5% 4% 0%
[libx264 @ 0x7fa0e201ce00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 72% 8% 20% 0% 0% 0% 0% 0% 0%
[libx264 @ 0x7fa0e201ce00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 23% 25% 4% 3% 3% 3% 2% 2%
[libx264 @ 0x7fa0e201ce00] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x7fa0e201ce00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fa0e201ce00] ref P L0: 83.3% 8.3% 8.3%
[libx264 @ 0x7fa0e201ce00] ref B L0: 40.1% 59.9%
[libx264 @ 0x7fa0e201ce00] kb/s:14.38
[aac @ 0x7fa0e201e600] Qavg: 595.040




When I import these into Final Cut I can see that both videos get around 2:30 seconds of added silence (not present in the audio) :






concatenating video1 and video2



ffmpeg -i "video1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i "video2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc "video_combined.mp4"

ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
 built with Apple LLVM version 8.0.0 (clang-800.0.38)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.2.0/include/openjpeg-2.2 --enable-nonfree --enable-vda
 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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf57.71.100
 Duration: 00:00:06.04, start: 0.000000, bitrate: 143 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x800, 18 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
 Metadata:
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
 Metadata:
 handler_name : SoundHandler
Output #0, mpegts, to 'intermediate1.ts':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf57.71.100
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x800, q=2-31, 18 kb/s, 25 fps, 25 tbr, 90k tbn, 12800 tbc (default)
 Metadata:
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
 Metadata:
 handler_name : SoundHandler
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 151 fps=0.0 q=-1.0 Lsize= 135kB time=00:00:05.92 bitrate= 187.5kbits/s speed=2.43e+03x
video:14kB audio:87kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 34.259724%
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
 built with Apple LLVM version 8.0.0 (clang-800.0.38)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.2.0/include/openjpeg-2.2 --enable-nonfree --enable-vda
 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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video2.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf57.71.100
 Duration: 00:00:07.80, start: 0.000000, bitrate: 157 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x800, 15 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
 Metadata:
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
 Metadata:
 handler_name : SoundHandler
Output #0, mpegts, to 'intermediate2.ts':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf57.71.100
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x800, q=2-31, 15 kb/s, 25 fps, 25 tbr, 90k tbn, 12800 tbc (default)
 Metadata:
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
 Metadata:
 handler_name : SoundHandler
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 195 fps=0.0 q=-1.0 Lsize= 192kB time=00:00:07.68 bitrate= 204.8kbits/s speed=2.6e+03x
video:14kB audio:129kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 33.605099%
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
 built with Apple LLVM version 8.0.0 (clang-800.0.38)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-frei0r --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.2.0/include/openjpeg-2.2 --enable-nonfree --enable-vda
 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
Input #0, mpegts, from 'concat:intermediate1.ts|intermediate2.ts':
 Duration: 00:00:07.82, start: 1.456778, bitrate: 342 kb/s
 Program 1
 Metadata:
 service_name : Service01
 service_provider: FFmpeg
 Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 800x800, 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 169 kb/s
Output #0, mp4, to 'video_combined.mp4':
 Metadata:
 encoder : Lavf57.71.100
 Stream #0:0: Video: h264 (High) ([33][0][0][0] / 0x0021), yuv420p(progressive), 800x800, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
 Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 169 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 346 fps=0.0 q=-1.0 Lsize= 257kB time=00:00:13.74 bitrate= 153.3kbits/s speed=1.54e+03x
video:30kB audio:217kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 4.243830%




The output of the combined video contains the extra silences, but the second audio doesn't combine properly :






Method 2 : Create combined video directly



ffmpeg -f concat -i input.txt -map 0 \
 -vcodec libx264 \
 -aprofile aac_low -acodec aac -strict experimental -cutoff 15000 -b:a 32k 
 "video_combined.mp4"




Any ideas ?