使用ffmpeg添加视频水印,附为封面图

使用ffmpeg添加视频水印,附为封面图

使用ffmpeg添加视频水印,视频包含封面图,水印作为封面图附加。

像这样的命令

ffmpeg -ss 0 -t 60 -i .\test2.mp4 -i logo_gray20p.png 
 -filter_complex "[0:V]overlay=x=W-w-20:y=10[out]"  -f mp4 test2_out.mp4

视频添加水印使用了“Stream #1:0: Video: png”,而不是logo_gray20p.png。输出信息包含“Stream #0:2 (png) -> overlay (graph 0)”。

输出

.................ffmpeg version & info
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000022d4c51eb00] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\test2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2022-01-11T12:16:31.000000Z
    encoder         : Lavf59.10.100
  Duration: 00:44:07.93, start: 0.000000, bitrate: 1587 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x818 [SAR 1:1 DAR 960:409], 1487 kb/s, 24.88 fps, 25 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2022-01-11T12:16:31.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x3](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 92 kb/s (default)
    Metadata:
      creation_time   : 2022-01-11T12:16:31.000000Z
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x0]: Video: png, rgba(pc), 250x100, 90k tbr, 90k tbn (attached pic)
Input #1, png_pipe, from 'logo_gray20p.png':
  Duration: N/A, bitrate: N/A
  Stream #1:0: Video: png, rgba(pc), 150x53 [SAR 3780:3780 DAR 150:53], 25 fps, 25 tbr, 25 tbn
File 'test2_out.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 (h264) -> overlay (graph 0)
  Stream #0:2 (png) -> overlay (graph 0)
  overlay:default (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))

答案1

访问FFMPEG:如何为视频添加水印?

参考这篇文章,效果很好

代码修改为

 ffmpeg -ss 0 -t 60 -i .\test2.mp4 -i logo_gray20p.png  -filter_complex "[0:v][1:v]overlay=x=W-w-20:y=10[outv]" -map [outv] -map 0:a  -f mp4 test2_out.mp4

相关内容