Guest User

Untitled

a guest
Oct 11th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. 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 ).
  2.  
  3. 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.
  4.  
  5. Started this by just generating slide show of images from the video
  6.  
  7. **Slideshow of images**
  8.  
  9. 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
  10.  
  11. Then, tried adding an audio to the video, and this is the command I used.
  12.  
  13. 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
  14.  
  15. With this command, I was able to create the video with zoom and pan effects. It did not cycle through the images, though.
  16.  
  17. ffmpeg \
  18. -framerate 1/4 -start_number 1 -i 164470_%d.jpg \
  19. -vf "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125" \
  20. -c:v libx264 -t 30 -s "800x450" outWithZoom.mp4
  21.  
  22.  
  23. **To add in a blend effect I used this command:**
  24.  
  25. ffmpeg \
  26. -loop 1 -t 5 -i 164470_2.jpg \
  27. -loop 1 -t 5 -i 164470_3.jpg \
  28. -loop 1 -t 5 -i 164470_4.jpg \
  29. -loop 1 -t 5 -i 164470_5.jpg \
  30. -filter_complex \
  31. "[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]; \
  32. [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]; \
  33. [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]; \
  34. [0:v][b1v][1:v][b2v][2:v][b3v][3:v]concat=n=7,format=yuv420p[v]" \
  35. -map "[v]" -aspect 16:9 outWithFasterBlend.mp4
  36.  
  37. This particular post is from where I got the command to create a video with blend effect.
  38. http://superuser.com/questions/833232/create-video-with-5-images-with-fadein-out-effect-in-ffmpeg
  39.  
  40. **Blend with zoom**
  41.  
  42. ffmpeg \
  43. -loop 1 -t 5 -i 164470_2.jpg \
  44. -loop 1 -t 5 -i 164470_3.jpg \
  45. -loop 1 -t 5 -i 164470_5.jpg \
  46. -filter_complex \
  47. "[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]; \
  48. [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]; \
  49. [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]; \
  50. [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]; \
  51. [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]; \
  52. [v0][b1v][v1][b2v][v2]concat=n=5,format=yuv420p[v]" \
  53. -map "[v]" -aspect 16:9 outWithBlendAndZoom.mp4
  54.  
  55. This command did not work out, I am not sure why. Here is the output:
  56.  
  57. ffmpeg version N-63893-gc69defd Copyright (c) 2000-2014 the FFmpeg developers
  58. built on Oct 31 2014 05:16:04 with gcc 4.6 (Debian 4.6.3-1)
  59. 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
  60. libavutil 52. 89.100 / 52. 89.100
  61. libavcodec 55. 66.101 / 55. 66.101
  62. libavformat 55. 43.100 / 55. 43.100
  63. libavdevice 55. 13.101 / 55. 13.101
  64. libavfilter 4. 8.100 / 4. 8.100
  65. libswscale 2. 6.100 / 2. 6.100
  66. libswresample 0. 19.100 / 0. 19.100
  67. libpostproc 52. 3.100 / 52. 3.100
  68. Input #0, image2, from '164470_2.jpg':
  69. Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
  70. Stream #0:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25 tbr, 25 tbn, 25 tbc
  71. Input #1, image2, from '164470_3.jpg':
  72. Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
  73. Stream #1:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25 tbr, 25 tbn, 25 tbc
  74. Input #2, image2, from '164470_5.jpg':
  75. Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
  76. Stream #2:0: Video: mjpeg, yuvj422p(pc), 1600x1200, 25 fps, 25 tbr, 25 tbn, 25 tbc
  77. File 'outWithBlendAndZoom.mp4' already exists. Overwrite ? [y/N] y
  78. [swscaler @ 0xba66100] deprecated pixel format used, make sure you did set range correctly
  79. [swscaler @ 0xbaa23a0] deprecated pixel format used, make sure you did set range correctly
  80. [swscaler @ 0xbac4680] deprecated pixel format used, make sure you did set range correctly
  81. [swscaler @ 0xbae6960] deprecated pixel format used, make sure you did set range correctly
  82. [swscaler @ 0xbb07260] deprecated pixel format used, make sure you did set range correctly
  83. [swscaler @ 0xbb2af20] deprecated pixel format used, make sure you did set range correctly
  84. [swscaler @ 0xbb4d200] deprecated pixel format used, make sure you did set range correctly
  85. [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)
  86. [Parsed_concat_5 @ 0xba8e060] Failed to configure output pad on Parsed_concat_5
  87.  
  88. So now, I want to be able to do all of this in one command. Summarizing what I need in the video:
  89. 1. 30-second video with blend and zoom + pan effect.
  90. 2. Audio
  91. 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.
  92. 4. The aspect ratio of the video should be 16:9.
  93.  
  94. 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
  95.  
  96. With my current understanding, I know what a 'filtergraph', 'filterchain' and a 'filter' is. But I do not fully understand what each filter argument does.
Add Comment
Please, Sign In to add comment