ffmpeg叠加层未在第一帧显示

时间:2016-05-04 23:04:10

标签: video ffmpeg overlay mp4 video-processing

我正在尝试使用ffmpeg将720x720视频(previd.mp4)叠加到背景图像(bg.jpg)上。除了创建的视频的第一帧仅显示覆盖视频显示在其上方的帧之外,我才能使用它。

这就是我用来创建视频和叠加层的内容:

ffmpeg -loop 1 -i bg.jpg -i previd.mp4 -filter_complex "[1:v]scale=-1:1080[a]; [0:v][a]overlay=(main_w/2)-(overlay_w/2):0:shortest=1[video]" -map "[video]" -map 1:a -codec:a copy vid.mp4

ffmpeg version 3.0.2-tessus Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --as=yasm --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[mjpeg @ 0x7fa934808600] Changing bps to 8
Input #0, image2, from 'bg.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 16835 kb/s
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'previd_2_0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.25.100
  Duration: 00:00:06.57, start: 0.023220, bitrate: 1395 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x720, 1261 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[swscaler @ 0x7fa93400b000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7fa934001200] using SAR=1/1
[libx264 @ 0x7fa934001200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fa934001200] profile High, level 4.0
[libx264 @ 0x7fa934001200] 264 - core 148 - 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=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 'vid0.mp4':
  Metadata:
    encoder         : Lavf57.25.100
    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 (default)
    Metadata:
      encoder         : Lavc57.24.102 libx264
    Side data:
      unknown side data type 10 (24 bytes)
    Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 (mjpeg) -> overlay:main
  Stream #1:0 (h264) -> scale
  overlay -> Stream #0:0 (libx264)
  Stream #1:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   26 fps=0.0 q=0.0 size=       0kB time=00:00:01.32 bitrate=   0.3kbits/sframe=   49 fps= 48 q=0.0 size=       0kB time=00:00:02.20 bitrate=   0.2kbits/sframe=   69 fps= 45 q=28.0 size=     146kB time=00:00:03.01 bitrate= 396.3kbits/frame=   92 fps= 45 q=28.0 size=     315kB time=00:00:03.94 bitrate= 654.7kbits/frame=  115 fps= 45 q=28.0 size=     514kB time=00:00:04.87 bitrate= 863.3kbits/frame=  137 fps= 45 q=28.0 size=     677kB time=00:00:05.73 bitrate= 966.9kbits/frame=  155 fps= 43 q=28.0 size=     831kB time=00:00:06.50 bitrate=1046.8kbits/frame=  164 fps= 34 q=-1.0 Lsize=    1812kB time=00:00:06.57 bitrate=2259.0kbits/s speed=1.35x    
video:1700kB audio:106kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.344859%
[libx264 @ 0x7fa934001200] frame I:1     Avg QP:20.13  size: 36046
[libx264 @ 0x7fa934001200] frame P:91    Avg QP:24.37  size: 15003
[libx264 @ 0x7fa934001200] frame B:72    Avg QP:24.43  size:  4709
[libx264 @ 0x7fa934001200] consecutive B-frames: 38.4%  8.5%  1.8% 51.2%
[libx264 @ 0x7fa934001200] mb I  I16..4: 30.2% 67.1%  2.7%
[libx264 @ 0x7fa934001200] mb P  I16..4:  8.6% 17.6%  0.8%  P16..4: 16.6%  3.1%  0.9%  0.0%  0.0%    skip:52.3%
[libx264 @ 0x7fa934001200] mb B  I16..4:  0.7%  1.3%  0.1%  B16..8: 21.3%  1.2%  0.1%  direct: 0.7%  skip:74.7%  L0:44.5% L1:54.2% BI: 1.4%
[libx264 @ 0x7fa934001200] 8x8 transform intra:65.0% inter:93.5%
[libx264 @ 0x7fa934001200] coded y,uvDC,uvAC intra: 32.3% 45.6% 4.6% inter: 4.3% 8.5% 0.0%
[libx264 @ 0x7fa934001200] i16 v,h,dc,p: 30% 30%  5% 35%
[libx264 @ 0x7fa934001200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 25% 14%  4%  5%  5%  5%  5%  4%
[libx264 @ 0x7fa934001200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 27% 11%  3%  7%  5%  5%  3%  2%
[libx264 @ 0x7fa934001200] i8c dc,h,v,p: 52% 20% 22%  6%
[libx264 @ 0x7fa934001200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fa934001200] ref P L0: 74.9%  8.3% 12.6%  4.2%
[libx264 @ 0x7fa934001200] ref B L0: 92.4%  6.8%  0.9%
[libx264 @ 0x7fa934001200] ref B L1: 97.5%  2.5%
[libx264 @ 0x7fa934001200] kb/s:2122.37

1 个答案:

答案 0 :(得分:1)

可能是帧速率或开始时间不同的问题。

尝试

string.Format