如何为视频添加放大效果?


2

我正在一个项目中,我应该从一组输入的视频或图像中生成视频。

问题是,当我生成视频时,必须为每个输入元素添加一个放大效果。

我以这种方式解决了图像问题(我为每个图像重复此命令):

ffmpeg -loop 1 -i test.jpg -vf "zoompan=z='min(zoom+0.0015,1.5)':d=125" -c:v libx264 -pix_fmt yuvj420p -t 5 -s "796x450" test.mp4

在我合并生成的视频之后。

现在,我尝试使用相同的视频解决方案,但没有成功。我应该在图像中的视频之前进行转换吗?还是有另一种方式?

谢谢!


UPDATE

这是我用于视频的命令。

ffmpeg -i small.mp4 -vf "zoompan=z='min(zoom+0.0015,1.5)':d=125:s=640x360" -c:v libx264 -c:a libfdk_aac -y smallzoom.mp4ffmpeg version 2.3.git Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug  7 2014 18:14:20 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --prefix=/home/stuzzo/ffmpeg_build --extra-cflags=-I/home/stuzzo/ffmpeg_build/include --extra-ldflags=-L/home/stuzzo/ffmpeg_build/lib --bindir=/home/stuzzo/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-nonfree
  libavutil      52. 98.100 / 52. 98.100
  libavcodec     55. 72.102 / 55. 72.102
  libavformat    55. 51.101 / 55. 51.101
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.102 /  4. 11.102
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'small.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2010-03-20 21:29:11
    encoder         : HandBrake 0.9.4 2009112300
  Duration: 00:00:05.57, start: 0.000000, bitrate: 551 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 560x320, 465 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
      encoder         : JVT/AVC Coding
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 83 kb/s (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
[libx264 @ 0x3066180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x3066180] profile High, level 3.0
[libx264 @ 0x3066180] 264 - core 142 - 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=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 'smallzoom.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf55.51.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
      encoder         : Lavc55.72.102 libx264
    Stream #0:1(eng): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, mono, s16, 104 kb/s (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
      encoder         : Lavc55.72.102 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[output stream 0:0 @ 0x30671a0] 100 buffers queued in output stream 0:0, something may be wrong.
frame=  175 fps= 11 q=-1.0 Lsize=     244kB time=00:00:05.76 bitrate= 346.6kbits/s dup=0 drop=20575    
video:165kB audio:71kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.131025%
[libx264 @ 0x3066180] frame I:1     Avg QP:20.98  size: 20122
[libx264 @ 0x3066180] frame P:46    Avg QP:21.52  size:  2151
[libx264 @ 0x3066180] frame B:128   Avg QP:25.80  size:   385
[libx264 @ 0x3066180] consecutive B-frames:  2.3%  0.0%  1.7% 96.0%
[libx264 @ 0x3066180] mb I  I16..4: 46.3% 27.6% 26.1%
[libx264 @ 0x3066180] mb P  I16..4:  1.8%  0.4%  0.1%  P16..4: 37.3%  7.8%  5.7%  0.0%  0.0%    skip:46.8%
[libx264 @ 0x3066180] mb B  I16..4:  0.0%  0.1%  0.0%  B16..8: 22.7%  1.1%  0.2%  direct: 0.4%  skip:75.5%  L0:45.0% L1:52.6% BI: 2.4%
[libx264 @ 0x3066180] 8x8 transform intra:25.2% inter:68.0%
[libx264 @ 0x3066180] coded y,uvDC,uvAC intra: 29.7% 62.3% 31.5% inter: 2.9% 9.0% 1.4%
[libx264 @ 0x3066180] i16 v,h,dc,p:  0% 30%  1% 69%
[libx264 @ 0x3066180] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 30% 17%  4%  6%  4% 13%  4%  9%
[libx264 @ 0x3066180] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 30%  9%  4%  8%  6% 13%  4%  7%
[libx264 @ 0x3066180] i8c dc,h,v,p: 44% 40%  9%  7%
[libx264 @ 0x3066180] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x3066180] ref P L0: 61.2%  5.1% 22.5% 11.1%
[libx264 @ 0x3066180] ref B L0: 82.0% 13.6%  4.4%
[libx264 @ 0x3066180] ref B L1: 94.0%  6.0%
[libx264 @ 0x3066180] kb/s:230.91

您是否绝对必须在终端机中执行此操作?是否无法安装OpenShot?如果我没记错的话,OpenShot中有一个选项,可让您平移和缩放视频。而且,您还可以更轻松地将图像合成为视频...或者是在Windows上执行此操作?我以为不是Windows,因为您使用的是ffmpeg ...
zorvalent

1
您对视频尝试了什么命令?控制台输出了什么?
拉吉布(Rajib)2015年

@zorvalent我在一个Web项目中,我需要一个命令行工具。不管怎么说,还是要谢谢你。
stuzzo

@Rajib我编辑了答案。ffmpeg生成新视频,但未添加缩放效果。
stuzzo

嗯。ffplay test.mp4 -vf "scale=640:360, zoompan=z='min(zoom+0.0015,1.5)':d=125"为我工作,而相同的使用ffmpeg给出1280x720输出。当我像您一样使用比例过滤器时,会出现相同的越野车行为。也许我们应该发布另一个错误报告。必须调查更多。还可以尝试在ffmpeg.org/mailman/listinfo/ffmpeg-user
slhck

Answers:


-1

这是一个可以在一个命令中完成所有操作的命令:

ffmpeg -y -loop 1 -i image1jpg -loop 1 -i image2.jpg -loop 1 -i image3.jpg -filter_complex "[0:v]zoompan=z='min(zoom+0.0015,1.5)':d=125,trim=duration=5,fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5,scale=796x450,setpts=PTS-STARTPTS[v0];[1:v]zoompan=z='min(zoom+0.0015,1.5)':d=125,trim=duration=5,fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5,scale=796x450,setpts=PTS-STARTPTS[v1];[2:v]zoompan=z='min(zoom+0.0015,1.5)':d=125,trim=duration=5,fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5,scale=796x450,setpts=PTS-STARTPTS[v2]; [v0][v1][v2] concat=n=3:v=1:a=0, format=yuv420p[v]" -map '[v]' -c:v libx264 -pix_fmt yuvj420p -q:v 1 test.mp4

4
这将是太多,太多,如果你解释如何提出命令的工作做得更好!
CVn 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.