(Translated) Hello! I have the following problem. I concatenate multiple ts files and convert to mp4 with ffmpeg. I do this operation multiple times in an automated way, so I don't always check the results, but whenever I do, on the computer, the result obtained is as expected. However, some videos, when played on an Android device, are seen incorrectly in any application: Chrome, Firefox, Vlc, etc. The version of ffmpeg I use is the latest. This is the command I use:
ffmpeg.exe -hwaccel dxva2 -y -f concat -i list.txt -acodec copy -vcodec copy output.mp4 -preset normal
Results:
PC
Android
This is the output of ffmpeg:
ffmpeg version n4.3.1-26-gca55240b8c Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3-win32 (GCC) 20200320
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Trailing option(s) found in the command: may be ignored.
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, 29.50 fps, 29.50 tbr, 90k tbn, 180k tbc
Stream #0:2: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 64 kb/s
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, q=2-31, 29.50 fps, 29.50 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 9504 fps=8330 q=-1.0 Lsize= 24561kB time=00:07:42.26 bitrate= 435.3kbits/s speed= 405x
video:21200kB audio:3100kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.073735%
Not all videos are "yuv420p (tv, unknown / bt470bg / unknown, progressive)", but this should not be the problem, since other videos with this information are seen correctly on Android.
To correct this type of video I do the following:
ffmpeg -y -f concat -i list.txt -c:v libx264 -preset slow -crf 22 -pix_fmt yuv420p -c:a aac -b:a 128k output.mp4
So I get the video to play correctly both on pc and Android. Unfortunately, automating the process by always using this last line occasionally causes problems (starting file 40MB, ending file> 1GB, more than 2 hours)
I would like, if possible, help me identify which videos will be viewed incorrectly on Android. Thank you very much in advance. Finally, this is the answer that ffmpeg gives when executing the line with which I fix the file:
ffmpeg version n4.3.1-26-gca55240b8c Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3-win32 (GCC) 20200320
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, 29.50 fps, 29.50 tbr, 90k tbn, 180k tbc
Stream #0:2: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:2 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001efdbaee540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001efdbaee540] profile High, level 3.0, 4:2:0, 8-bit
[libx264 # 000001efdbaee540] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'd.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x568, q=-1--1, 29.50 fps, 15104 tbn, 29.50 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s
Metadata:
encoder : Lavc58.91.100 aac
More than 1000 frames duplicated 8960kB time=00:02:06.74 bitrate= 579.1kbits/s dup=999 drop=0 speed=15.7x
frame=13638 fps=468 q=-1.0 Lsize= 32033kB time=00:07:42.20 bitrate= 567.8kbits/s dup=4134 drop=0 speed=15.9x
video:25547kB audio:5995kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.557852%
[libx264 # 000001efdbaee540] frame I:87 Avg QP:19.17 size: 12750
[libx264 # 000001efdbaee540] frame P:4630 Avg QP:21.89 size: 4286
[libx264 # 000001efdbaee540] frame B:8921 Avg QP:23.89 size: 583
[libx264 # 000001efdbaee540] consecutive B-frames: 8.9% 8.6% 9.1% 73.4%
[libx264 # 000001efdbaee540] mb I I16..4: 12.2% 76.2% 11.6%
[libx264 # 000001efdbaee540] mb P I16..4: 3.7% 11.0% 0.8% P16..4: 37.1% 16.2% 5.7% 0.0% 0.0% skip:25.4%
[libx264 # 000001efdbaee540] mb B I16..4: 0.3% 0.9% 0.1% B16..8: 30.4% 3.1% 0.3% direct: 0.8% skip:64.2% L0:51.4% L1:44.3% BI: 4.3%
[libx264 # 000001efdbaee540] 8x8 transform intra:71.2% inter:66.8%
[libx264 # 000001efdbaee540] direct mvs spatial:99.9% temporal:0.1%
[libx264 # 000001efdbaee540] coded y,uvDC,uvAC intra: 52.5% 42.1% 5.5% inter: 9.7% 9.0% 0.3%
[libx264 # 000001efdbaee540] i16 v,h,dc,p: 19% 21% 9% 50%
[libx264 # 000001efdbaee540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 11% 13% 6% 9% 11% 9% 11% 8%
[libx264 # 000001efdbaee540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 9% 8% 6% 14% 14% 11% 9% 6%
[libx264 # 000001efdbaee540] i8c dc,h,v,p: 46% 20% 23% 12%
[libx264 # 000001efdbaee540] Weighted P-Frames: Y:2.9% UV:0.8%
[libx264 # 000001efdbaee540] ref P L0: 72.3% 12.2% 11.3% 2.1% 1.9% 0.2% 0.0%
[libx264 # 000001efdbaee540] ref B L0: 93.1% 5.5% 1.1% 0.3%
[libx264 # 000001efdbaee540] ref B L1: 97.6% 2.4%
[libx264 # 000001efdbaee540] kb/s:452.67
[aac # 000001efdbaee9c0] Qavg: 10682.834
Related
Summary
My goal is to take a webcam stream from the browser and feed it into a program called Restreamer that takes in an RTMP stream.
I've deduced that the browser Recording API produces Blobs that can be saved as WEBM.
In order to stream the WEBM content to Restreamer I am attempting to use FFmpeg. I've read that forcing FLV format is required but otherwise all of the arguments are Greek to me. I've been unable to find a comparable topic where someone has tried to go from WEBM to RTMP. I have found examples of going the other direction, but reversing the FFmpeg command proved unfruitful.
Saving to FLV works fine. Using the following command, I am able to transcode a WEBM file to FLV and play it on VLC:
ffmpeg -i ~/big-buck-bunny_trailer.webm -f flv out.flv
However, if instead of outputting to a file I pass it to RTMP I get the following output:
ffmpeg -i ~/Downloads/big-buck-bunny_trailer.webm -f flv "rtmp://example.com/live"
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, matroska,webm, from '/home/kyjus25/big-buck-bunny_trailer.webm':
Metadata:
encoder : http://sourceforge.net/projects/yamka
creation_time : 2010-05-20T08:21:12.000000Z
Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)
Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
HandShake: client signature does not match!
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> flv1 (flv))
Stream #0:1 -> #0:1 (vorbis (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://example.com/live':
Metadata:
encoder : Lavf59.16.100
Stream #0:0(eng): Video: flv1 ([2][0][0][0] / 0x0002), yuv420p(tv, bt470bg/unknown/unknown, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 1k tbn (default)
Metadata:
encoder : Lavc59.18.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, mono, fltp (default)
Metadata:
encoder : Lavc59.18.100 libmp3lame
WriteN, RTMP send error 32 (136 bytes)7kB time=00:00:00.39 bitrate= 136.7kbits/s speed=71.2x
WriteN, RTMP send error 32 (35 bytes)
WriteN, RTMP send error 9 (42 bytes)
av_interleaved_write_frame(): Operation not permitted
Last message repeated 1 times
[flv # 0x55d0dd0af700] Failed to update header with correct duration.
[flv # 0x55d0dd0af700] Failed to update header with correct filesize.
Error writing trailer of rtmp://example.com/live: Operation not permitted
frame= 53 fps=0.0 q=4.3 Lsize= 146kB time=00:00:02.45 bitrate= 486.8kbits/s speed=42.8x
video:128kB audio:19kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Error closing file rtmp://example.com/live: Operation not permitted
Conversion failed!
There are several interesting rabbit holes to follow here, but after following all of them I've come up with nothing.
• HandShake: client signature does not match!:
More of a warning than an error, I assumed because I was going from "WEBM -> FLV" instead of the more traditional "MP4 -> FLV".
• av_interleaved_write_frame(): Operation not permitted:
I found several issues on this. One of them calling it a storage issue, the other calling it a file permissions issue. I have plenty of disk space and have tried setting the input file to 777 permissions. However, the examples I've found on it being a file permissions issue all deal with outputting to a file rather than to an an RTMP IP.
• Failed to update header with correct duration:
Advice I found was to add -flvflags no_duration_filesize to the command, which does suppress both "Failed to update..." errors, but does not fix the over-arching issue.
What I've Tried
• Multi-format transcoding
MP4 to RTMP does work correctly:
ffmpeg -i ~/Downloads/big-buck-bunny_trailer.mp4 -f flv "rtmp://example.com/live"
Theoretically, I could stream the WEBM to a file, transcode that to an MP4 file, and then transcode that to FLV/RTMP. Sounds awful.
• Pay for a service (Wowza, Flashphoner, api.video, etc)
Unfortunately precisely what I am trying to avoid.
• WebRTC to RTMP?
WebRTC seems to be a peer-to-peer connection and doesn't play nicely with a server/client scenario.
• WebRTC to other ingest formats
Restreamer also supports incoming streams of HLS, DASH, RTP, RTSP, RTMP, and SRT. However, these all seem to be examples of network sources that would be exposed via an IP URL. I am not sure that FFmpeg can do that.
• Utilizing ffmpeg-wasm instead of CLI
Available here, I thought that maybe by using a browser implementation I may get different results. But no. Not even an error to the console.
• Streaming from OBS
For the record, yes, I have tried streaming from OBS instead of going through FFmpeg and the Restreamer platform itself does work for normal use. I use it often.
Post Script
I've not been able to find any relevant solutions online. I am shocked that streaming from a browser webcam has not been solved 1000 times prior. This is related to a question made 7 years ago but it was not resolved and Flash is no longer an option.
Recommendations
• Adding -c:v libx264 -flags:v +global_header -c:a aac -ac 2:
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, matroska,webm, from '/home/kyjus25/big-buck-bunny_trailer.webm':
Metadata:
encoder : http://sourceforge.net/projects/yamka
creation_time : 2010-05-20T08:21:12.000000Z
Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)
Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
HandShake: client signature does not match!
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (vorbis (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x561564271fc0] using SAR=1/1
[libx264 # 0x561564271fc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x561564271fc0] profile High, level 3.0, 4:2:0, 8-bit
[libx264 # 0x561564271fc0] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=11 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, flv, to 'rtmp://example.com/live':
Metadata:
encoder : Lavf59.16.100
Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p(tv, bt470bg/unknown/unknown, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 1k tbn (default)
Metadata:
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc59.18.100 aac
Larger timestamp than 24-bit: 0xffffff77kB time=00:00:30.18 bitrate= 460.0kbits/s speed=19.7x
[flv # 0x56156425e440] Failed to update header with correct duration.
[flv # 0x56156425e440] Failed to update header with correct filesize.
frame= 812 fps=475 q=-1.0 Lsize= 1901kB time=00:00:32.52 bitrate= 479.0kbits/s speed= 19x
video:1354kB audio:508kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.123872%
[libx264 # 0x561564271fc0] frame I:21 Avg QP:15.05 size: 8839
[libx264 # 0x561564271fc0] frame P:293 Avg QP:20.78 size: 3087
[libx264 # 0x561564271fc0] frame B:498 Avg QP:22.20 size: 593
[libx264 # 0x561564271fc0] consecutive B-frames: 14.7% 7.6% 9.2% 68.5%
[libx264 # 0x561564271fc0] mb I I16..4: 42.6% 41.9% 15.5%
[libx264 # 0x561564271fc0] mb P I16..4: 4.0% 8.0% 0.9% P16..4: 22.7% 8.0% 4.0% 0.0% 0.0% skip:52.4%
[libx264 # 0x561564271fc0] mb B I16..4: 1.4% 1.5% 0.2% B16..8: 12.0% 1.0% 0.2% direct: 3.3% skip:80.5% L0:44.1% L1:47.1% BI: 8.8%
[libx264 # 0x561564271fc0] 8x8 transform intra:53.6% inter:57.0%
[libx264 # 0x561564271fc0] coded y,uvDC,uvAC intra: 35.1% 37.7% 11.2% inter: 7.8% 9.5% 2.4%
[libx264 # 0x561564271fc0] i16 v,h,dc,p: 56% 21% 14% 9%
[libx264 # 0x561564271fc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 26% 21% 3% 3% 4% 4% 3% 4%
[libx264 # 0x561564271fc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 18% 4% 7% 7% 6% 5% 4%
[libx264 # 0x561564271fc0] i8c dc,h,v,p: 62% 21% 15% 2%
[libx264 # 0x561564271fc0] Weighted P-Frames: Y:20.8% UV:19.5%
[libx264 # 0x561564271fc0] ref P L0: 70.3% 17.7% 9.0% 2.9% 0.0%
[libx264 # 0x561564271fc0] ref B L0: 89.3% 8.9% 1.9%
[libx264 # 0x561564271fc0] ref B L1: 96.4% 3.6%
[libx264 # 0x561564271fc0] kb/s:341.30
[aac # 0x561564223140] Qavg: 952.636
Seems to complete successfully, but does so rather quickly. Log outputs a new Larger timestamp than 24-bit: 0xffffff77kB
Was able to get it to work by using:
ffmpeg -re -i sample.webm -c:v h264 -c:a aac -f flv "rtmp://example.com/live"
The -re was essential to make it stream in real time, otherwise #Gyan's suggestion would have also worked!
I am trying to use ffmpeg to overlay a video on a backgroud image. But the output video has different framerate(25) and length compared to the source video, I guess this is causing the tiny out-of-sync between video and audio in the output. How can I tune the command to keep the framerate same as source?
ffmpeg -i crop.mp4
ffmpeg version 4.3.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'crop.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:02:26.10, start: 0.000000, bitrate: 1378 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1080x810, 1240 kb/s, 31.25 fps, 31.25 tbr, 16k tbn, 62.50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Here is the command
/data/ffmpeg-4.4-amd64-static/ffmpeg -i background_image_crop.png -i crop.mp4 -filter_complex "[0:v][1:v]overlay=x=0:y=H/2-h/2" -c:a copy output.mp4
ffmpeg version 4.4-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, png_pipe, from 'background_image_crop.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgb24(pc), 1080x1920, 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'crop.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:02:26.10, start: 0.000000, bitrate: 1378 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1080x810, 1240 kb/s, 31.25 fps, 31.25 tbr, 16k tbn, 62.50 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 (png) -> overlay:main
Stream #1:0 (h264) -> overlay:overlay
overlay -> Stream #0:0 (libx264)
Stream #1:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 # 0x57da140] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x57da140] profile High, level 4.0, 4:2:0, 8-bit
[libx264 # 0x57da140] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=60 lookahead_threads=10 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 'output.mp4':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 1080x1920, q=2-31, 25 fps, 12800 tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
frame= 3653 fps= 96 q=-1.0 Lsize= 24563kB time=00:02:26.07 bitrate=1377.5kbits/s dup=0 drop=911 speed=3.85x
video:22143kB audio:2299kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.492343%
[libx264 # 0x57da140] frame I:16 Avg QP:14.36 size:125240
[libx264 # 0x57da140] frame P:989 Avg QP:17.65 size: 13266
[libx264 # 0x57da140] frame B:2648 Avg QP:25.21 size: 2851
[libx264 # 0x57da140] consecutive B-frames: 1.1% 4.3% 7.6% 87.1%
[libx264 # 0x57da140] mb I I16..4: 11.1% 72.4% 16.4%
[libx264 # 0x57da140] mb P I16..4: 2.6% 7.4% 0.6% P16..4: 14.9% 4.4% 2.3% 0.0% 0.0% skip:67.9%
[libx264 # 0x57da140] mb B I16..4: 0.3% 0.6% 0.0% B16..8: 13.8% 1.0% 0.1% direct: 0.4% skip:83.8% L0:43.9% L1:53.9% BI: 2.2%
[libx264 # 0x57da140] 8x8 transform intra:69.0% inter:87.7%
[libx264 # 0x57da140] coded y,uvDC,uvAC intra: 39.2% 62.5% 18.5% inter: 2.7% 4.8% 0.0%
[libx264 # 0x57da140] i16 v,h,dc,p: 33% 27% 8% 32%
[libx264 # 0x57da140] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 19% 21% 4% 5% 5% 4% 5% 3%
[libx264 # 0x57da140] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 20% 10% 5% 8% 8% 6% 6% 3%
[libx264 # 0x57da140] i8c dc,h,v,p: 49% 19% 25% 7%
[libx264 # 0x57da140] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x57da140] ref P L0: 66.6% 10.3% 18.0% 5.1%
[libx264 # 0x57da140] ref B L0: 91.4% 7.2% 1.4%
[libx264 # 0x57da140] ref B L1: 96.8% 3.2%
[libx264 # 0x57da140] kb/s:1241.39
For your example is 31.25 fps, Richard use parameter -r for fps value in the start of code, like this
ffmpeg -r 31.25 -i background_image_crop.png -i crop.mp4 -filter_complex "[0:v][1:v]overlay=x=0:y=H/2-h/2" -c:a copy -preset ultrafast -movflags -faststart output.mp4
(I add -movflags -faststart for the video charge fast, and preset ultrafast to do all fast, only for this example)
I has probed this example getting the next data:
ffmpeg -i output.mp4
Duration: 00:06:33.39, start: 0.000000, bitrate: 1523 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1421 kb/s, 31.25 fps, 31.25 tbr, 16k tbn, 62.50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)
Metadata:
handler_name : SoundHandler
I'm currently using the command
ffmpeg -i mainvideo.mp4 -vcodec libvpx -i myoverlay.webm -filter_complex "overlay = 5:5" done.mp4
To overlay a transparent webm on top of my main mp4. But for some reason the output video is frozen for the first 1~ second but the audio is completely fine.
I've tried this command with other videos and it works sometimes but most of the time the first few frames seem frozen
Edit.
I have two main mp4 files, broken_source.mp4 and working_source.mp4. Putting the overlay on broken_source results in the output having the first 1~ second of video frozen (audio completely fine) but putting the same overlay on working_source.mp4 is perfect and has no issues
Logs for putting the overlay on working_source:
ffmpeg -i working_source.mp4 -vcodec libvpx -i chat.webm -filter_complex "overlay = 0:0" working_complete.mp4
ffmpeg version 4.3.1-2021-01-01-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'working_source.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.51.101
Duration: 00:00:31.02, start: 0.000000, bitrate: 6176 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 6035 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[libvpx # 0000016fb5074a80] v1.9.0-128-g3a38edea2
Last message repeated 1 times
Input #1, matroska,webm, from 'chat.webm':
Metadata:
ENCODER : Lavf58.51.101
Duration: 00:00:31.00, start: 0.000000, bitrate: 449 kb/s
Stream #1:0: Video: vp8, yuva420p(tv, progressive), 500x300, SAR 1:1 DAR 5:3, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
ENCODER : Lavc58.101.101 libvpx
DURATION : 00:00:31.000000000
[libvpx # 0000016fb50761c0] v1.9.0-128-g3a38edea2
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #1:0 (libvpx) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libvpx # 0000016fb50761c0] v1.9.0-128-g3a38edea2
[libx264 # 0000016fb5072040] using SAR=1/1
[libx264 # 0000016fb5072040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000016fb5072040] profile High, level 4.2, 4:2:0, 8-bit
[libx264 # 0000016fb5072040] 264 - core 161 r3027 4121277 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=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.00
Output #0, mp4, to 'working_complete.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.91.100 aac
frame= 1861 fps= 44 q=-1.0 Lsize= 20013kB time=00:00:31.01 bitrate=5285.3kbits/s speed=0.729x
video:19477kB audio:486kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.244893%
[libx264 # 0000016fb5072040] frame I:8 Avg QP:19.04 size:240534
[libx264 # 0000016fb5072040] frame P:538 Avg QP:23.76 size: 23836
[libx264 # 0000016fb5072040] frame B:1315 Avg QP:31.66 size: 3951
[libx264 # 0000016fb5072040] consecutive B-frames: 3.0% 3.5% 14.8% 78.7%
[libx264 # 0000016fb5072040] mb I I16..4: 6.4% 47.4% 46.2%
[libx264 # 0000016fb5072040] mb P I16..4: 1.2% 4.2% 1.9% P16..4: 21.4% 5.3% 2.9% 0.0% 0.0% skip:63.1%
[libx264 # 0000016fb5072040] mb B I16..4: 0.1% 0.2% 0.1% B16..8: 12.6% 1.5% 0.5% direct: 0.4% skip:84.6% L0:35.9% L1:60.0% BI: 4.1%
[libx264 # 0000016fb5072040] 8x8 transform intra:55.5% inter:60.0%
[libx264 # 0000016fb5072040] coded y,uvDC,uvAC intra: 63.5% 77.4% 40.4% inter: 3.7% 4.6% 0.7%
[libx264 # 0000016fb5072040] i16 v,h,dc,p: 19% 37% 15% 29%
[libx264 # 0000016fb5072040] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 18% 23% 7% 7% 7% 7% 6% 8%
[libx264 # 0000016fb5072040] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 22% 17% 7% 8% 7% 7% 6% 6%
[libx264 # 0000016fb5072040] i8c dc,h,v,p: 45% 27% 18% 11%
[libx264 # 0000016fb5072040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0000016fb5072040] ref P L0: 74.5% 13.9% 9.1% 2.5%
[libx264 # 0000016fb5072040] ref B L0: 91.9% 7.4% 0.7%
[libx264 # 0000016fb5072040] ref B L1: 96.6% 3.4%
[libx264 # 0000016fb5072040] kb/s:5144.05
[aac # 0000016fb5026a80] Qavg: 193.230
Logs for putting the overlay on broken_source:
ffmpeg -i broken_source.mp4 -vcodec libvpx -i chat.webm -filter_complex "overlay = 0:0" broken_complete.mp4
ffmpeg version 4.3.1-2021-01-01-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'broken_source.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.26.101
Duration: 00:00:45.02, start: 0.000000, bitrate: 5962 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5952 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[libvpx # 0000021071f90280] v1.9.0-128-g3a38edea2
Last message repeated 1 times
Input #1, matroska,webm, from 'chat.webm':
Metadata:
ENCODER : Lavf58.51.101
Duration: 00:00:31.00, start: 0.000000, bitrate: 449 kb/s
Stream #1:0: Video: vp8, yuva420p(tv, progressive), 500x300, SAR 1:1 DAR 5:3, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
ENCODER : Lavc58.101.101 libvpx
DURATION : 00:00:31.000000000
[libvpx # 0000021072020dc0] v1.9.0-128-g3a38edea2
Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #1:0 (libvpx) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libvpx # 0000021072020dc0] v1.9.0-128-g3a38edea2
[libx264 # 0000021072022980] using SAR=1/1
[libx264 # 0000021072022980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000021072022980] profile High, level 4.2, 4:2:0, 8-bit
[libx264 # 0000021072022980] 264 - core 161 r3027 4121277 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=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.00
Output #0, mp4, to 'broken_complete.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.91.100 aac
frame= 2701 fps= 47 q=-1.0 Lsize= 23020kB time=00:00:45.01 bitrate=4189.5kbits/s dup=60 drop=0 speed=0.789x
video:22242kB audio:708kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.309473%
[libx264 # 0000021072022980] frame I:11 Avg QP:18.82 size:210832
[libx264 # 0000021072022980] frame P:742 Avg QP:23.14 size: 18106
[libx264 # 0000021072022980] frame B:1948 Avg QP:31.16 size: 3604
[libx264 # 0000021072022980] consecutive B-frames: 1.7% 4.2% 6.2% 87.8%
[libx264 # 0000021072022980] mb I I16..4: 10.0% 46.2% 43.7%
[libx264 # 0000021072022980] mb P I16..4: 1.6% 4.5% 1.5% P16..4: 16.5% 4.2% 2.4% 0.0% 0.0% skip:69.3%
[libx264 # 0000021072022980] mb B I16..4: 0.1% 0.3% 0.1% B16..8: 11.3% 1.4% 0.4% direct: 0.4% skip:86.0% L0:36.5% L1:59.3% BI: 4.3%
[libx264 # 0000021072022980] 8x8 transform intra:57.4% inter:64.8%
[libx264 # 0000021072022980] coded y,uvDC,uvAC intra: 55.4% 42.1% 14.8% inter: 3.3% 2.1% 0.3%
[libx264 # 0000021072022980] i16 v,h,dc,p: 21% 37% 15% 27%
[libx264 # 0000021072022980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 18% 24% 6% 7% 6% 7% 6% 7%
[libx264 # 0000021072022980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 22% 16% 7% 7% 7% 7% 6% 6%
[libx264 # 0000021072022980] i8c dc,h,v,p: 58% 22% 15% 5%
[libx264 # 0000021072022980] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0000021072022980] ref P L0: 68.9% 16.6% 10.8% 3.6%
[libx264 # 0000021072022980] ref B L0: 91.6% 7.2% 1.2%
[libx264 # 0000021072022980] ref B L1: 95.9% 4.1%
[libx264 # 0000021072022980] kb/s:4047.35
[aac # 0000021072024840] Qavg: 189.405
I try to stream on my own rtmp nginx server an single static jpeg image with an mp3 which have about an hour, and from my nginx rtmp to YouTube, but audio is not constant and without image...
This is what I used...
#! /bin/bash
VBR="1500k"
FPS="30"
QUAL="ultrafast"
YOUTUBE_URL="rtmp://localhost:1935/live"
YOUTUBE_KEY="test"
VIDEO_SOURCE="image.jpg"
AUDIO_SOURCE="music.mp3"
AUDIO_ENCODER="libmp3lame"
ffmpeg \
-loop 1 \
-re \
-framerate $FPS \
-i "$VIDEO_SOURCE" \
-thread_queue_size 512 \
-i "$AUDIO_SOURCE" \
-c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR \
-c:a $AUDIO_ENCODER -threads "$(nproc)" -ar 44100 -b:a 128k -bufsize 512k -pix_fmt yuv420p \
-vf scale=1280x720,setsar=1:1 \
-f flv $YOUTUBE_URL/$YOUTUBE_KEY
Output:
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, image2, from 'unsplash.jpg':
Duration: 00:00:00.03, start: 0.000000, bitrate: 1976946 kb/s
Stream #0:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 7952x4472 [SAR 72:72 DAR 994:559], 30 tbr, 30 tbn, 30 tbc
Input #1, mp3, from 'ArtOfTrippyCode.mp3':
Metadata:
encoder : Lavf58.29.100
Duration: 01:07:25.34, start: 0.023021, bitrate: 141 kb/s
Stream #1:0: Audio: mp3, 48000 Hz, stereo, fltp, 141 kb/s
Metadata:
encoder : Lavc58.54
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[swscaler # 0x564a7bd3ed80] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x564a7b3e9680] VBV maxrate unspecified, assuming CBR
[libx264 # 0x564a7b3e9680] using SAR=1/1
[libx264 # 0x564a7b3e9680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x564a7b3e9680] profile Constrained Baseline, level 3.1
[libx264 # 0x564a7b3e9680] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=2 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=60 keyint_min=6 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=cbr mbtree=0 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1500 vbv_bufsize=512 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
Output #0, flv, to 'rtmp://localhost:1935/live/test':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1500 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 512000 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54.100 libmp3lame
[flv # 0x564a7b3e8340] Failed to update header with correct duration.863.7kbits/s speed=0.0424x
[flv # 0x564a7b3e8340] Failed to update header with correct filesize.
frame= 15 fps=1.6 q=-1.0 Lsize= 97kB time=00:00:00.47 bitrate=1686.4kbits/s speed=0.0511x
video:88kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.021540%
[libx264 # 0x564a7b3e9680] frame I:1 Avg QP:34.00 size: 25690
[libx264 # 0x564a7b3e9680] frame P:14 Avg QP:29.21 size: 4569
[libx264 # 0x564a7b3e9680] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 # 0x564a7b3e9680] mb P I16..4: 0.5% 0.0% 0.0% P16..4: 16.0% 0.0% 0.0% 0.0% 0.0% skip:83.5%
[libx264 # 0x564a7b3e9680] coded y,uvDC,uvAC intra: 51.0% 11.4% 1.2% inter: 8.2% 3.3% 0.1%
[libx264 # 0x564a7b3e9680] i16 v,h,dc,p: 32% 25% 31% 13%
[libx264 # 0x564a7b3e9680] i8c dc,h,v,p: 82% 11% 7% 0%
[libx264 # 0x564a7b3e9680] kb/s:1434.54
I want to create a slideshow with a background music by ffmpeg, and use the command
ffmpeg -f concat -safe 0 -i map.txt -i audio.flac -vsync vfr -pix_fmt yuv420p -strict -2 video.mp4
and map.txt is like
file '1.jpg'
duration 15
file '2.jpg'
duration 60
The result is a video with the audio and blank background. If I run the above command without audio as
ffmpeg -f concat -safe 0 -i map.txt -pix_fmt yuv420p -strict -2 video.mp4
a perfect video of the images (the intended slideshow) is generated (but obviously without audio).
I reckon the problem is related to synchronising the audio and images.
This is the terminal output for the first command
ffmpeg -f concat -safe 0 -i map.txt -i audio.flac -vsync vfr -pix_fmt yuv420p -strict -2 video.mp4
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 # 0x1cc8d40] Changeing bps to 8
Input #0, concat, from 'map.txt':
Duration: 00:05:48.00, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: mjpeg, gray(bt470bg/unknown/unknown), 1920x1080 [SAR 72:72 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #1, flac, from 'audio.flac':
Metadata:
TITLE : Speak to Me
ARTIST : Creator
ALBUM : Acoustic Hits
track : 14
GENRE : Pop
DATE : 2011
Duration: 00:03:31.02, start: 0.000000, bitrate: 1026 kb/s
Stream #1:0: Audio: flac, 44100 Hz, stereo, s16
[libx264 # 0x1ccdf80] using SAR=1/1
[libx264 # 0x1ccdf80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x1ccdf80] profile High, level 4.0
[libx264 # 0x1ccdf80] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=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.00
Output #0, mp4, to 'video.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp (16 bit), 128 kb/s
Metadata:
encoder : Lavc56.60.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (flac (native) -> aac (native))
Press [q] to stop, [?] for help
[mjpeg # 0x7fe688001ba0] Changeing bps to 8
frame= 2 fps=0.7 q=-1.0 Lsize= 3593kB time=00:03:31.02 bitrate= 139.5kbits/s
video:147kB audio:3410kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.036417%
[libx264 # 0x1ccdf80] frame I:1 Avg QP: 2.55 size: 33683
[libx264 # 0x1ccdf80] frame P:1 Avg QP:19.33 size:116022
[libx264 # 0x1ccdf80] mb I I16..4: 89.7% 1.1% 9.3%
[libx264 # 0x1ccdf80] mb P I16..4: 0.9% 1.8% 30.1% P16..4: 1.4% 1.5% 0.9% 0.0% 0.0% skip:63.4%
[libx264 # 0x1ccdf80] 8x8 transform intra:2.1% inter:15.2%
[libx264 # 0x1ccdf80] coded y,uvDC,uvAC intra: 19.7% 0.0% 0.0% inter: 2.8% 0.0% 0.0%
[libx264 # 0x1ccdf80] i16 v,h,dc,p: 97% 2% 2% 0%
[libx264 # 0x1ccdf80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 12% 39% 1% 1% 2% 1% 2% 4%
[libx264 # 0x1ccdf80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 16% 16% 3% 4% 6% 5% 5% 4%
[libx264 # 0x1ccdf80] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x1ccdf80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1ccdf80] kb/s:20.65
UPDATE (following the comment suggestion)
ffmpeg -f concat -safe 0 -i map.txt -i audio.flac -vsync vfr -r 5 -pix_fmt yuv420p -strict -2 video.mp4
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 # 0x1fe9d80] Changeing bps to 8
Input #0, concat, from 'map.txt':
Duration: 00:02:28.00, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: mjpeg, gray(bt470bg/unknown/unknown), 1920x1080 [SAR 72:72 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #1, flac, from 'audio.flac':
Metadata:
TITLE : Speak to Me
ARTIST : Creator
ALBUM : Acoustic Hits
track : 14
GENRE : Pop
DATE : 2011
Duration: 00:03:31.02, start: 0.000000, bitrate: 1026 kb/s
Stream #1:0: Audio: flac, 44100 Hz, stereo, s16
[libx264 # 0x1feefc0] using SAR=1/1
[libx264 # 0x1feefc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x1feefc0] profile High, level 4.0
[libx264 # 0x1feefc0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=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=5 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 'video.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 5 fps, 10240 tbn, 5 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp (16 bit), 128 kb/s
Metadata:
encoder : Lavc56.60.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (flac (native) -> aac (native))
Press [q] to stop, [?] for help
[mjpeg # 0x7f74cc001ba0] Changeing bps to 8
frame= 2 fps=0.7 q=-1.0 Lsize= 3593kB time=00:03:31.02 bitrate= 139.5kbits/s
video:147kB audio:3410kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.036417%
[libx264 # 0x1feefc0] frame I:1 Avg QP: 2.55 size: 33683
[libx264 # 0x1feefc0] frame P:1 Avg QP:19.33 size:116022
[libx264 # 0x1feefc0] mb I I16..4: 89.7% 1.1% 9.3%
[libx264 # 0x1feefc0] mb P I16..4: 0.9% 1.8% 30.1% P16..4: 1.4% 1.5% 0.9% 0.0% 0.0% skip:63.4%
[libx264 # 0x1feefc0] 8x8 transform intra:2.1% inter:15.2%
[libx264 # 0x1feefc0] coded y,uvDC,uvAC intra: 19.7% 0.0% 0.0% inter: 2.8% 0.0% 0.0%
[libx264 # 0x1feefc0] i16 v,h,dc,p: 97% 2% 2% 0%
[libx264 # 0x1feefc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 12% 39% 1% 1% 2% 1% 2% 4%
[libx264 # 0x1feefc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 16% 16% 3% 4% 6% 5% 5% 4%
[libx264 # 0x1feefc0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x1feefc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1feefc0] kb/s:20.65