[FFmpeg-user] Create a video using images and audio with blend and zoom filters using FFmpeg
Nikhil M Ranka
nikhil.r at geazy.com
Wed Oct 12 13:36:30 EEST 2016
Note: I have a few days ( 3-4 ) of experience with using FFmpeg, and I do
not fully understand the commands I mention here ( most of them are from
stack overflow forums - I do not have those links bookmarked ).
I wanted to generate a 30-second video, with 16:9 aspect ratio, from a set
of images and an audio with blend + zoom and pan effect.
Started this by just generating slide show of images from the video
**Slideshow of images**
ffmpeg -framerate 1/4 -start_number 1 -i 164470_%d.jpg -c:v libx264 -r
> 30 -pix_fmt yuv420p -vf scale=16:9 out.mp4
Then, tried adding an audio to the video, and this is the command I used.
ffmpeg -framerate 1/4 -start_number 1 -i 164470_%d.jpg -i audio.wav
> -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k
> -pix_fmt yuv420p -shortest outWithAudioNew.mp4
With this command, I was able to create the video with zoom and pan
effects. It did not cycle through the images, though.
ffmpeg \
> -framerate 1/4 -start_number 1 -i 164470_%d.jpg \
> -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125" \
> -c:v libx264 -t 30 -s "800x450" outWithZoom.mp4
**To add in a blend effect I used this command:**
ffmpeg \
> -loop 1 -t 5 -i 164470_2.jpg \
> -loop 1 -t 5 -i 164470_3.jpg \
> -loop 1 -t 5 -i 164470_4.jpg \
> -loop 1 -t 5 -i 164470_5.jpg \
> -filter_complex \
> "[1:v][0:v]blend=all_expr='A*(if(gte(T,1.5),1,T/1.5))+B*(1-(
> if(gte(T,1.5),1,T/1.5)))'[b1v]; \
> [2:v][1:v]blend=all_expr='A*(if(gte(T,1.5),1,T/1.5))+B*(1-(
> if(gte(T,1.5),1,T/1.5)))'[b2v]; \
> [3:v][2:v]blend=all_expr='A*(if(gte(T,1.5),1,T/1.5))+B*(1-(
> if(gte(T,1.5),1,T/1.5)))'[b3v]; \
> [0:v][b1v][1:v][b2v][2:v][b3v][3:v]concat=n=7,format=yuv420p[v]" \
> -map "[v]" -aspect 16:9 outWithFasterBlend.mp4
This particular post is from where I got the command to create a video with
blend effect.
http://superuser.com/questions/833232/create-video-
with-5-images-with-fadein-out-effect-in-ffmpeg
**Blend with zoom**
>
> ffmpeg \
> -loop 1 -t 5 -i 164470_2.jpg \
> -loop 1 -t 5 -i 164470_3.jpg \
> -loop 1 -t 5 -i 164470_5.jpg \
> -filter_complex \
> "[0:v]zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/
> zoom/2)':y='ih/2-(ih/zoom/2)'[v0]; \
> [1:v]zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/
> zoom/2)':y='ih/2-(ih/zoom/2)'[v1]; \
> [2:v]zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/
> zoom/2)':y='ih/2-(ih/zoom/2)'[v2]; \
> [1:v][0:v]blend=all_expr='A*(if(gte(T,1.5),1,T/1.5))+B*(1-(
> if(gte(T,1.5),1,T/1.5)))'[b1v]; \
> [2:v][1:v]blend=all_expr='A*(if(gte(T,1.5),1,T/1.5))+B*(1-(
> if(gte(T,1.5),1,T/1.5)))'[b2v]; \
> [v0][b1v][v1][b2v][v2]concat=n=5,format=yuv420p[v]" \
> -map "[v]" -aspect 16:9 outWithBlendAndZoom.mp4
This command did not work out, I am not sure why. Here is the output:
ffmpeg version N-63893-gc69defd Copyright (c) 2000-2014 the FFmpeg
> developers
> built on Oct 31 2014 05:16:04 with gcc 4.6 (Debian 4.6.3-1)
> configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32
> --extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static'
> --extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static'
> --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared
> --disable-ffserver --disable-doc --enable-bzlib --enable-zlib
> --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl
> --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray
> --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex
> --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3
> --enable-libvpx
> libavutil 52. 89.100 / 52. 89.100
> libavcodec 55. 66.101 / 55. 66.101
> libavformat 55. 43.100 / 55. 43.100
> libavdevice 55. 13.101 / 55. 13.101
> libavfilter 4. 8.100 / 4. 8.100
> libswscale 2. 6.100 / 2. 6.100
> libswresample 0. 19.100 / 0. 19.100
> libpostproc 52. 3.100 / 52. 3.100
> Input #0, image2, from '164470_2.jpg':
> Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
> Stream #0:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25
> tbr, 25 tbn, 25 tbc
> Input #1, image2, from '164470_3.jpg':
> Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
> Stream #1:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25
> tbr, 25 tbn, 25 tbc
> Input #2, image2, from '164470_5.jpg':
> Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
> Stream #2:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25
> tbr, 25 tbn, 25 tbc
> File 'outWithBlendAndZoom.mp4' already exists. Overwrite ? [y/N] y
> [swscaler @ 0xba66100] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbaa23a0] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbac4680] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbae6960] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbb07260] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbb2af20] deprecated pixel format used, make sure you did
> set range correctly
> [swscaler @ 0xbb4d200] deprecated pixel format used, make sure you did
> set range correctly
> [Parsed_concat_5 @ 0xba8e060] Input link in1:v0 parameters (size
> 1600x1200, SAR 0:1) do not match the corresponding output link in0:v0
> parameters (1280x720, SAR 0:1)
> [Parsed_concat_5 @ 0xba8e060] Failed to configure output pad on
> Parsed_concat_5
So now, I want to be able to do all of this in one command. Summarizing
what I need in the video:
1. 30-second video with blend and zoom + pan effect.
2. Audio
3. And each image in the video must get an equal amount of time. If 5
images, then each image must last for about 6 seconds.
4. The aspect ratio of the video should be 16:9.
Not all the images I use have the same resolution, can FFmpeg work with
such images? Or I need to work on those images to have the same resolution
Regards,
*Nikhil*
More information about the ffmpeg-user
mailing list