Im trying to make a small movie file from a folder with webcam images.
They are named like this:
00-00-38.jpg
00-05-37.jpg
00-10-37.jpg
00-15-37.jpg
H-M-S.jpg format
Although i tried patterntype glob and simpler commands i cannot get it to work.
This is what i tried:
ffmpeg -r 1 -pattern_type glob -i '*.jpg' -scale=720:-1 -c:v libx264 out.mp4
(got only one image)
ffmpeg -r 25 -i *.jpg -vf "scale=720:-1" output.mp4
(same size as a jpg file but no video)
Console output:
ffmpeg -framerate 1 -pattern_type glob -i "*.jpg" -vf scale=720:-1 -c:v libx264 -pix_fmt yuv420p out.mp4
ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security '
--extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis
--enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-li
bopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --
enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --
enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64
-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enabl
e-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[image2 # 0x1d53f00] max_analyze_duration 5000000 reached at 5000000
Input #0, image2, from '*.jpg':
Duration: 00:04:48.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p, 800x593 [SAR 96:96 DAR 800:593], 1 fps, 1 tbr, 1 tbn, 1 tbc
[libx264 # 0x1d35bc0] using SAR=1780/1779
[libx264 # 0x1d35bc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA4 FMA3 SSEMisalign LZCNT BMI1
[libx264 # 0x1d35bc0] profile High, level 2.2
[libx264 # 0x1d35bc0] 264 - core 132 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: ca
bac=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 8x8dc
t=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 key
int_min=1 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 'out.mp4':
Metadata:
encoder : Lavf54.29.104
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x534 [SAR 1780:1779 DAR 800:593], q=-1--1, 1 tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libx264)
Press [q] to stop, [?] for help
frame= 288 fps=145 q=32763.0 Lsize= 349kB time=00:04:46.00 bitrate= 10.0kbits/s
video:345kB audio:0kB subtitle:0 global headers:0kB muxing overhead 1.208469%
[libx264 # 0x1d35bc0] frame I:2 Avg QP: 2.80 size:130328
[libx264 # 0x1d35bc0] frame P:73 Avg QP: 4.70 size: 1167
[libx264 # 0x1d35bc0] frame B:213 Avg QP:17.33 size: 30
[libx264 # 0x1d35bc0] consecutive B-frames: 1.4% 0.0% 0.0% 98.6%
[libx264 # 0x1d35bc0] mb I I16..4: 20.2% 24.9% 55.0%
[libx264 # 0x1d35bc0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 4.3% 0.1% 0.2% 0.0% 0.0% skip:95.5%
[libx264 # 0x1d35bc0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.8% 0.0% 0.0% direct: 0.0% skip:99.2% L0: 5.4% L1:94.5% BI: 0.0
%
[libx264 # 0x1d35bc0] 8x8 transform intra:24.9% inter:51.5%
[libx264 # 0x1d35bc0] coded y,uvDC,uvAC intra: 99.4% 0.0% 0.0% inter: 0.6% 0.0% 0.0%
[libx264 # 0x1d35bc0] i16 v,h,dc,p: 5% 19% 52% 25%
[libx264 # 0x1d35bc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 28% 21% 4% 6% 4% 8% 5% 15%
[libx264 # 0x1d35bc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 27% 13% 6% 8% 5% 9% 6% 12%
[libx264 # 0x1d35bc0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x1d35bc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1d35bc0] ref P L0: 98.1% 0.0% 1.7% 0.2%
[libx264 # 0x1d35bc0] ref B L0: 52.0% 48.0%
[libx264 # 0x1d35bc0] ref B L1: 73.0% 27.0%
[libx264 # 0x1d35bc0] kb/s:9.78
The video is 364KB without any video.
Try this:
ffmpeg -framerate 1 -pattern_type glob -i "*.jpg" -vf scale=720:-1 -c:v libx264 -pix_fmt yuv420p out.mp4
If that doesn't work for you, include the exact command you used and the full console output indicating what is wrong.
I've always done something along the lines of:
a=0
for i in *.jpg; do
new=$(printf "/home/Movies/jpgs/%04d.jpg" "$a")
cp -f "$i" "$new"
let a=a+1
done
to get the files in the right order, anything else breaks the encoding as soon as the input numbers are non-monotonic.
Related
I'm writing a script that creates a video from images during their creation. A simulation software is writing out images with an unknown time interval (seconds to minutes). I'm doing this because mp4 is taking up much less space. Also, the images will end up in a video anyhow.
Here is my code. I commented the most important parts (as far as I understand). I gathered this from other posts I can't find the link to anymore.
#!/usr/bin/bash
# Create pipe and start piping it to ffmpeg process
mkfifo pipe
cat pipe | ffmpeg -y -f image2pipe -i pipe:0 -c:v libx264 -pix_fmt yuv420p ../output_video.mp4 &
# Open pipe for writing.
exec 3>pipe
while true; do # loop endlessly
sleep .05; # is there a new image? get the oldest of them
if ls -A *.png 1> /dev/null 2>$1; then
NEWFILE=$( ls -At *.png | tail -n 1 );
echo "$NEWFILE"
cat "$NEWFILE" >&3 # add the png to the pipe
# rm out.png; # remove or backup the image
mv "$NEWFILE" "./backup/$NEWFILE";
fi
done
My script is actually quite far already. It works fine for images in a folder and when the pictures are delivered quickly. When the images come one by one with longer intervals ffmpeg just seems to stop listening to the pipe input.
Here is the log from an example - not sure if this is helpful. Files 465 to 540 are already present in the folder, the others are added with ~15s intervals. As we can see ffmpeg first waits for 8-10 images to arrive before starting to compile. Afterwards ffmpeg continues to wait for images and compiling them. At the end I abort the script, now ffmpeg completes the mp4.
But when I write out the frames of the mp4 it includes every frame until image 610. Why did ffmpeg stop to listen to the pipe? The 'chunk too big' error could be a hint, but how do I fix it?
scene_image_00465.png
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
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 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --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-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
scene_image_00470.png
scene_image_00475.png
scene_image_00480.png
scene_image_00485.png
scene_image_00490.png
scene_image_00495.png
scene_image_00500.png
scene_image_00505.png
scene_image_00510.png
Input #0, image2pipe, from 'pipe:0':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgb24, 1920x1200, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 # 0x19c0980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 # 0x19c0980] profile High, level 5.0
[libx264 # 0x19c0980] 264 - core 142 r2495 6a301b6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=18 lookahead_threads=3 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_video.mp4':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1200, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc56.26.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
scene_image_00515.png
scene_image_00520.png
scene_image_00525.png
scene_image_00530.png
scene_image_00535.png
scene_image_00540.png
scene_image_00545.png
scene_image_00550.png
scene_image_00555.png=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
scene_image_00560.png
scene_image_00565.png
scene_image_00570.png
scene_image_00575.png
scene_image_00580.png
scene_image_00585.png
scene_image_00590.png=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
scene_image_00595.png
scene_image_00600.png
scene_image_00605.png
scene_image_00610.png
scene_image_00615.png
scene_image_00620.png
scene_image_00625.png
scene_image_00630.png
scene_image_00635.png
scene_image_00640.png
scene_image_00645.png
scene_image_00650.png
scene_image_00655.png
scene_image_00660.png
scene_image_00665.png
scene_image_00670.png
scene_image_00675.png
scene_image_00680.png
scene_image_00685.png
scene_image_00690.png
scene_image_00695.png
scene_image_00700.png
scene_image_00705.png
scene_image_00710.png
scene_image_00715.png
[png # 0x35d0660] chunk too big=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
frame= 30 fps=0.1 q=-1.0 Lsize= 754kB time=00:00:01.12 bitrate=5517.3kbits/s
video:753kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.155077%
[libx264 # 0x19c0980] frame I:1 Avg QP:18.39 size:107795
[libx264 # 0x19c0980] frame P:8 Avg QP:24.90 size: 36026
[libx264 # 0x19c0980] frame B:21 Avg QP:28.37 size: 17835
[libx264 # 0x19c0980] consecutive B-frames: 3.3% 6.7% 10.0% 80.0%
[libx264 # 0x19c0980] mb I I16..4: 32.2% 41.7% 26.0%
[libx264 # 0x19c0980] mb P I16..4: 0.4% 1.2% 1.3% P16..4: 4.9% 6.8% 7.6% 0.0% 0.0% skip:77.8%
[libx264 # 0x19c0980] mb B I16..4: 0.1% 0.4% 0.6% B16..8: 10.1% 5.6% 3.3% direct: 2.0% skip:77.9% L0:42.0% L1:44.5% BI:13.5%
[libx264 # 0x19c0980] 8x8 transform intra:40.7% inter:24.0%
[libx264 # 0x19c0980] coded y,uvDC,uvAC intra: 29.6% 31.1% 29.7% inter: 6.0% 11.0% 3.9%
[libx264 # 0x19c0980] i16 v,h,dc,p: 56% 38% 5% 0%
[libx264 # 0x19c0980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 19% 31% 1% 1% 1% 1% 0% 1%
[libx264 # 0x19c0980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 20% 17% 5% 9% 7% 8% 5% 6%
[libx264 # 0x19c0980] i8c dc,h,v,p: 76% 12% 8% 4%
[libx264 # 0x19c0980] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x19c0980] ref P L0: 57.4% 13.9% 18.1% 10.7%
[libx264 # 0x19c0980] ref B L0: 78.3% 18.6% 3.1%
[libx264 # 0x19c0980] ref B L1: 93.4% 6.6%
[libx264 # 0x19c0980] kb/s:5136.93
I'm simply trying to put some images together into a video with specific durations. I'm using the command
ffmpeg -f concat -i concat.txt -r 30 video.mp4
# concat.txt
file capture12.png
duration 1
file capture57.png
duration 3
file capture156.png
duration 7
file capture234.png
duration 5
file capture272.png
duration 3
The output of my console is
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
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
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, concat, from 'concat.txt':
Duration: 00:00:19.00, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: png, rgba(pc), 983x553, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 000001b3e55c5c80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001b3e55c5c80] profile High 4:4:4 Predictive, level 3.1, 4:4:4, 8-bit
[libx264 # 000001b3e55c5c80] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'video.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 983x553, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 629 fps=400 q=-1.0 Lsize= 124kB time=00:00:20.86 bitrate= 48.8kbits/s dup=624 drop=0 speed=13.3x
video:116kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.050883%
[libx264 # 000001b3e55c5c80] frame I:3 Avg QP:13.09 size: 20222
[libx264 # 000001b3e55c5c80] frame P:158 Avg QP:10.80 size: 207
[libx264 # 000001b3e55c5c80] frame B:468 Avg QP:13.75 size: 53
[libx264 # 000001b3e55c5c80] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 # 000001b3e55c5c80] mb I I16..4: 23.0% 58.6% 18.4%
[libx264 # 000001b3e55c5c80] mb P I16..4: 0.0% 0.0% 0.2% P16..4: 0.1% 0.0% 0.0% 0.0% 0.0% skip:99.7%
[libx264 # 000001b3e55c5c80] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 1.3% 0.0% 0.0% direct: 0.0% skip:98.7% L0:66.5% L1:33.5% BI: 0.0%
[libx264 # 000001b3e55c5c80] 8x8 transform intra:54.0% inter:7.4%
[libx264 # 000001b3e55c5c80] coded y,u,v intra: 15.3% 0.7% 0.7% inter: 0.0% 0.0% 0.0%
[libx264 # 000001b3e55c5c80] i16 v,h,dc,p: 86% 14% 0% 0%
[libx264 # 000001b3e55c5c80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 65% 7% 28% 0% 0% 0% 0% 0% 0%
[libx264 # 000001b3e55c5c80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 50% 14% 14% 3% 4% 5% 4% 4% 3%
[libx264 # 000001b3e55c5c80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001b3e55c5c80] ref P L0: 87.3% 6.3% 5.6% 0.8%
[libx264 # 000001b3e55c5c80] ref B L0: 45.3% 54.3% 0.4%
[libx264 # 000001b3e55c5c80] ref B L1: 99.6% 0.4%
[libx264 # 000001b3e55c5c80] kb/s:45.07
I can see it clearly saying Duration 00:00:19.00 (as it should be) and then later saying that the final video is 00:00:20.86. How do I get these numbers to match?
When forming a video from a list of images, -r is not reliable.
You'll have to make two changes:
duplicate the last image entry in the concat list,
# concat.txt
file capture12.png
duration 1
file capture57.png
duration 3
file capture156.png
duration 7
file capture234.png
duration 5
file capture272.png
duration 3
file capture272.png
and use the fps filter to change framerate.
ffmpeg -f concat -i concat.txt -vf fps=30 video.mp4
I am trying to make a short video in FFMPEG, where a word stays on screen for the duration of the video (0.5s). My FFMPEG code looks like this:
ffmpeg -f lavfi -i color=c=white:s=320x240:d=0.5 -vf "drawtext=fontfile= ‘c\:\Windows\fonts\calibri.ttf':fontsize=18: fontcolor=black:x=(w-text_w)/2:y=(h-text_h)/2:text='word'" output.mp4
However, I keep getting the following error (see below for full output):
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 # 000001c2918cef00] Using "C:/Windows/fonts/mingliub.ttc"
I figured it had something to do with the path to the font file. I also tried copying the font file to my FFMPEG map and map the font path to the FFMPEG directory:
ffmpeg -f lavfi -i color=c=white:s=320x240:d=0.5 -vf
"drawtext=fontfile=‘C:\FFMPEG\bin\calibri.ttf':fontsize=18:
fontcolor=black:x=(w-text_w)/2:y=(h-text_h)/2:text='word'" output.mp4'
This doesn't work either. I do get an output video.mp4 video, but the font is wrong. Here is the full output I get. It is the same for both code examples above:
c:\FFMPEG\bin>ffmpeg -f lavfi -i color=c=white:s=320x240:d=0.5 -vf "drawtext=fontfile= ‘c\\:\\\Windows\\\fonts\\\calibri.ttf':fontsize=18: fontcolor=black:x=(w-text_w)/2:y=(h-text_h)/2:text='word'" output.mp4
ffmpeg version N-93234-g2e67f751b5 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.102 / 58. 47.102
libavformat 58. 26.101 / 58. 26.101
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, lavfi, from 'color=c=white:s=320x240:d=0.5':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 # 00000291ad7def00] Using "C:/Windows/fonts/mingliub.ttc"
[libx264 # 00000291af0ef180] using SAR=1/1
[libx264 # 00000291af0ef180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 00000291af0ef180] profile High, level 1.3, 4:2:0, 8-bit
[libx264 # 00000291af0ef180] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf58.26.101
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.47.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[Parsed_color_0 # 00000291af0aa840] EOF timestamp not reliable
frame= 13 fps=0.0 q=-1.0 Lsize= 2kB time=00:00:00.40 bitrate= 43.9kbits/s speed=4.27x
video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 84.991570%
[libx264 # 00000291af0ef180] frame I:1 Avg QP: 9.22 size: 306
[libx264 # 00000291af0ef180] frame P:3 Avg QP:11.33 size: 20
[libx264 # 00000291af0ef180] frame B:9 Avg QP:12.67 size: 14
[libx264 # 00000291af0ef180] consecutive B-frames: 7.7% 0.0% 0.0% 92.3%
[libx264 # 00000291af0ef180] mb I I16..4: 98.7% 0.0% 1.3%
[libx264 # 00000291af0ef180] 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 # 00000291af0ef180] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 # 00000291af0ef180] 8x8 transform intra:0.0%
[libx264 # 00000291af0ef180] coded y,uvDC,uvAC intra: 1.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 # 00000291af0ef180] i16 v,h,dc,p: 92% 1% 7% 0%
[libx264 # 00000291af0ef180] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 3% 42% 2% 5% 5% 2% 2% 2%
[libx264 # 00000291af0ef180] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 00000291af0ef180] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 00000291af0ef180] kb/s:7.65
2019 Windows builds seem to have changed syntax or something again; here's what works for me today:
-vf "drawtext=fontfile=C\\:/Windows/fonts/consola.ttf:fontsize=72:fontcolor='white':timecode='00\:00\:00\:00':rate=25:text='TCR\:':boxcolor=0x000000AA:box=1:x=860-text_w/2:y=960"
In my case, I'm running FFmpeg from PWD not C: so I have to specify font path C:\ with escaped colon and forward-slash for path.
SOLVED! Apparently the problem was that the path to the font cannot contain a semicolon (i.e., "C:/". The code that worked is:
ffmpeg -f lavfi -i color=c=white:s=320x240:d=0.5 -vf “drawtext=fontfile= /Windows/fonts/calibri.ttf:fontsize=18: fontcolor=black:x=(w-text_w)/2:y=(h-text_h)/2:text=word” output.mp4
If you are trying to get the font using script/program, you should additionally escape backslashes.This path worked for me:
const FONT_FILE = 'C\\\\:/Windows/Fonts/arial.ttf';
I wanted to create an .mp4 video with a framerate of 1 fps out of 10 images. I followed https://trac.ffmpeg.org/wiki/Slideshow and got to (my images are in the folder I am running the command from and are name img000.png, img001.png, etc.)
path_to_ffmpeg\ffmpeg.exe -framerate 1 -i img%03d.png output.mp4
However only the first image is taken to the video and it only shows one image!
After trying multiple permutations of -framerate and -r options and positions of the options, I did not recieve any better results.
Does anyone know what might have gone wrong even in this simple case? Thanks.
Full log:
C:\Users\foo\Documents\path>C:\bar\ffmpeg-4.0.2-win64-static\bin\ffmpeg.ex
e -framerate 1 -i img%03d.png output.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.1 (GCC) 20180722
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, image2, from 'img%03d.png':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 959x550 [SAR 2834:2834 DAR 959:550], 1 fp
s, 1 tbr, 1 tbn, 1 tbc
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0000000000611040] using SAR=1/1
[libx264 # 0000000000611040] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 # 0000000000611040] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-b
it
[libx264 # 0000000000611040] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=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_pski
p=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 deci
mate=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=1
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.12.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 959x550 [SA
R 1:1 DAR 959:550], q=-1--1, 1 fps, 16384 tbn, 1 tbc
Metadata:
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 10 fps=0.0 q=-1.0 Lsize= 20kB time=00:00:07.00 bitrate= 23.1kbits
/s speed=68.6x
video:19kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing ov
erhead: 5.046419%
[libx264 # 0000000000611040] frame I:1 Avg QP: 4.41 size: 14084
[libx264 # 0000000000611040] frame P:3 Avg QP:12.31 size: 632
[libx264 # 0000000000611040] frame B:6 Avg QP:19.11 size: 436
[libx264 # 0000000000611040] consecutive B-frames: 20.0% 0.0% 0.0% 80.0%
[libx264 # 0000000000611040] mb I I16..4: 89.7% 0.0% 10.3%
[libx264 # 0000000000611040] mb P I16..4: 0.2% 0.0% 0.1% P16..4: 0.5% 0.1
% 0.1% 0.0% 0.0% skip:98.9%
[libx264 # 0000000000611040] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.6% 0.1
% 0.1% direct: 0.0% skip:99.1% L0:22.0% L1:73.7% BI: 4.3%
[libx264 # 0000000000611040] coded y,u,v intra: 6.1% 2.5% 2.6% inter: 0.2% 0.1%
0.1%
[libx264 # 0000000000611040] i16 v,h,dc,p: 72% 25% 3% 0%
[libx264 # 0000000000611040] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 31% 20% 2% 2%
2% 3% 5% 2%
[libx264 # 0000000000611040] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0000000000611040] ref P L0: 65.8% 1.5% 26.5% 6.1%
[libx264 # 0000000000611040] ref B L0: 77.0% 12.7% 10.3%
[libx264 # 0000000000611040] ref B L1: 88.6% 11.4%
[libx264 # 0000000000611040] kb/s:14.87
Older versions of VLC couldn't play videos with framerates 5 or lower. Add -r 6 to correct for that. Also, you may want to add -pix_fmt yuv420p for wide playback compatibility.
I have a whole bunch of png's which I would like to convert into a mp4 video.
I am using the following command to stich them together:
ffmpeg -i _2016-04-20_14-51-00-500_%06d.png -pix_fmt yuv420p movie.mp4
I am getting a file, which has a size so it isn't empty. But when I play it in VLC or Quicktime it shows the time going by, but it has no video in it. Any idea what I'm doing wrong?
I also tried:
ffmpeg -framerate 1/5 -i _2016-04-20_14-51-00-500_%06d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
and
ffmpeg -r 45 -f image2 -s 1920x1080 -i _2016-04-20_14-51-00-500_%06d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
But still no video.
This is the commandline output:
>ffmpeg -i _2016-04-20_14-51-00-500_%06d.png -pix_fmt yuv420p movie.mp4
ffmpeg version N-79546-g13406b6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 22.100 / 55. 22.100
libavcodec 57. 35.100 / 57. 35.100
libavformat 57. 34.102 / 57. 34.102
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 44.100 / 6. 44.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, image2, from '_2016-04-20_14-51-00-500_%06d.png':
Duration: 00:00:02.60, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 8192x4096 [SAR 3779:3779 DAR 2:1], 25 tbr, 25 tbn
[libx264 # 00000000025851e0] using SAR=1/1
[libx264 # 00000000025851e0] frame MB size (512x256) > level limit (36864)
[libx264 # 00000000025851e0] DPB size (4 frames, 524288 mbs) > level limit (1 frames, 184320 mbs)
[libx264 # 00000000025851e0] MB rate (3276800) > level limit (2073600)
[libx264 # 00000000025851e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 00000000025851e0] profile High, level 5.2
[libx264 # 00000000025851e0] 264 - core 148 r2665 a01e339 - 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=18 lookahead_threads=3 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 # 0000000002583fc0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to 'movie.mp4':
Metadata:
encoder : Lavf57.34.102
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 8192x4096 [SAR 1:1 DAR 2:1], q=2-31, 25 fps, 12800 tbn
Metadata:
encoder : Lavc57.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 65 fps=3.2 q=-1.0 Lsize= 13498kB time=00:00:02.48 bitrate=44585.2kbits/s speed=0.123x 6x
video:13497kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.009971%
[libx264 # 00000000025851e0] frame I:1 Avg QP:16.71 size:1373751
[libx264 # 00000000025851e0] frame P:52 Avg QP:23.59 size:234822
[libx264 # 00000000025851e0] frame B:12 Avg QP:21.17 size: 19609
[libx264 # 00000000025851e0] consecutive B-frames: 73.8% 3.1% 4.6% 18.5%
[libx264 # 00000000025851e0] mb I I16..4: 14.7% 73.8% 11.5%
[libx264 # 00000000025851e0] mb P I16..4: 3.1% 5.9% 0.5% P16..4: 23.2% 7.7% 2.0% 0.0% 0.0% skip:57.5%
[libx264 # 00000000025851e0] mb B I16..4: 0.1% 0.1% 0.0% B16..8: 9.0% 0.2% 0.0% direct: 0.2% skip:90.3% L0:33.0% L1:66.6% BI: 0.4%
[libx264 # 00000000025851e0] 8x8 transform intra:63.5% inter:78.5%
[libx264 # 00000000025851e0] coded y,uvDC,uvAC intra: 33.7% 3.1% 1.0% inter: 10.1% 0.4% 0.0%
[libx264 # 00000000025851e0] i16 v,h,dc,p: 24% 57% 3% 17%
[libx264 # 00000000025851e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 31% 38% 2% 3% 2% 5% 2% 4%
[libx264 # 00000000025851e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 63% 10% 2% 2% 1% 5% 1% 4%
[libx264 # 00000000025851e0] i8c dc,h,v,p: 94% 2% 3% 0%
[libx264 # 00000000025851e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 00000000025851e0] ref P L0: 71.6% 13.1% 10.8% 4.4%
[libx264 # 00000000025851e0] ref B L0: 69.0% 30.6% 0.4%
[libx264 # 00000000025851e0] ref B L1: 89.7% 10.3%
[libx264 # 00000000025851e0] kb/s:42522.38
I tried with the following command and it works. The command is
ffmpeg -framerate 1 -f image2 -i img%06d.png -r 25 -vcodec libx264 -crf 25 -pix_fmt yuv420p output.mp4
-framerate 1: An image have 1s in the resultant video
-r 25: The framerate of the resultant video
-crf 25: quality of the resultant video (if you want it to get better, take a less value - but it is advice not to go under 18)
An ensure that your images are well numbered (img000001.png, ... img000009.png, img000010.png -> img%06d.png)