24秒后覆盖图片总是丢失


1

我正试图转换一个 MKV 文件并添加水印徽标,但我尝试了一堆不同的说明,但在视频24秒后它总是丢失徽标。

这是我的代码:

ffmpeg \
   -i RTed83e104ac4d98c46383630d733a3282.mkv \
   -i RT894ce44c6ba84eb98300566adae4e7bf.mka \
   -i logo_white.png \
   -filter_complex "[2] scale=120:18 [ovr1], [0:v][ovr1]overlay=10:452" \
   output.mp4

例如: https://cl.ly/0F3K1K121E2W 你可以看到24秒后图像消失了。

我做错了什么?

输出/日志

ffmpeg \
  -i RTed83e104ac4d98c46383630d733a3282.mkv \
  -i RT894ce44c6ba84eb98300566adae4e7bf.mka \
  -i logo_white.png \
  -filter_complex "[2] scale=120:18 [ovr1], [0:v][ovr1]overlay=10:452" \
  output.mp4
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, matroska,webm, from 'RTed83e104ac4d98c46383630d733a3282.mkv':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2018-02-13T18:16:31.000000Z
  Duration: 00:05:48.26, start: 1.456000, bitrate: 528 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
    Metadata:
      title           : Video
Input #1, matroska,webm, from 'RT894ce44c6ba84eb98300566adae4e7bf.mka':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2018-02-13T18:16:31.000000Z
  Duration: 00:05:47.78, start: 1.421000, bitrate: 45 kb/s
    Stream #1:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Audio
Input #2, png_pipe, from 'logo_white.png':
  Duration: N/A, bitrate: N/A
    Stream #2:0: Video: png, rgba(pc), 600x90, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:main (graph 0)
  Stream #2:0 (png) -> scale (graph 0)
  overlay (graph 0) -> Stream #0:0 (libx264)
  Stream #1:0 -> #0:1 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fc62308c400] using SAR=1/1
[libx264 @ 0x7fc62308c400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fc62308c400] profile High, level 3.0
[libx264 @ 0x7fc62308c400] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=6 lookahead_threads=1 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 'output.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      title           : Audio
      encoder         : Lavc57.107.100 aac
Past duration 0.609993 too large       0kB time=00:00:01.73 bitrate=   0.2kbits/s dup=7 drop=0 speed=3.43x
    Last message repeated 2 times
frame=10449 fps=152 q=-1.0 Lsize=   11658kB time=00:05:48.20 bitrate= 274.3kbits/s dup=151 drop=0 speed=5.06x
video:5860kB audio:5422kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.338063%
[libx264 @ 0x7fc62308c400] frame I:42    Avg QP:13.16  size: 32061
[libx264 @ 0x7fc62308c400] frame P:2657  Avg QP:18.79  size:  1347
[libx264 @ 0x7fc62308c400] frame B:7750  Avg QP:22.91  size:   138
[libx264 @ 0x7fc62308c400] consecutive B-frames:  0.9%  0.5%  0.5% 98.1%
[libx264 @ 0x7fc62308c400] mb I  I16..4: 13.1% 64.6% 22.3%
[libx264 @ 0x7fc62308c400] mb P  I16..4:  0.3%  0.7%  0.1%  P16..4: 10.4%  3.3%  1.7%  0.0%  0.0%    skip:83.5%
[libx264 @ 0x7fc62308c400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  8.0%  0.1%  0.0%  direct: 0.0%  skip:91.7%  L0:41.7% L1:56.6% BI: 1.7%
[libx264 @ 0x7fc62308c400] 8x8 transform intra:63.1% inter:64.4%
[libx264 @ 0x7fc62308c400] coded y,uvDC,uvAC intra: 75.8% 77.6% 61.0% inter: 1.3% 2.0% 0.2%
[libx264 @ 0x7fc62308c400] i16 v,h,dc,p: 17% 13% 37% 33%
[libx264 @ 0x7fc62308c400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 17% 25%  5%  4%  4%  5%  6%  9%
[libx264 @ 0x7fc62308c400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 18% 17%  8%  5%  5%  5%  5%  7%
[libx264 @ 0x7fc62308c400] i8c dc,h,v,p: 57% 20% 18%  5%
[libx264 @ 0x7fc62308c400] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fc62308c400] ref P L0: 65.0%  9.6% 16.7%  8.8%
[libx264 @ 0x7fc62308c400] ref B L0: 85.7% 12.4%  1.9%
[libx264 @ 0x7fc62308c400] ref B L1: 93.5%  6.5%
[libx264 @ 0x7fc62308c400] kb/s:137.80
[aac @ 0x7fc623086600] Qavg: 5304.135

建议添加解决方案作为答案,而不是将其添加到您的问题中。
llogan

@LordNeckbeard抱歉,刚刚做到了!
Filipe Braganca

Answers:


0

WebRTC采购的输入通常很邋and,可能会在中途改变参数,从而产生意外。在您的情况下,懒惰的解决方案可能是循环叠加图像:

ffmpeg \
  -i RTed83e104ac4d98c46383630d733a3282.mkv \
  -i RT894ce44c6ba84eb98300566adae4e7bf.mka \
  -loop 1 -i logo_white.png \
  -filter_complex "[2] scale=120:18 [ovr1], [0:v][ovr1]overlay=10:452:shortest=1" \
  output.mp4

感谢@LordNeckbeard,这可能是WebRTC的一些问题,昨天我设法得到我想要的东西,但我必须分步进行,首先转换每个视频,然后添加水印徽标,最后将一个视频添加到另一个。不确定我是否可以只用一个命令来做到这一点。
Filipe Braganca

0

我能够做我想要的,但我必须分步进行。我认为我的问题是因为我的视频来自WebRTC,正如@LordNeckbeard所解释的那样。这是我的 如果将来有人需要它:

# convert student video + audio
ffmpeg \
  -i RT0dcbc54f85d17eb6f7922f58f7b12079.mkv \
  -i RTb0ccec59e2119a15642b7cd772db843e.mka \
  student.mp4

# convert instructor video + audio
ffmpeg \
  -i RTed83e104ac4d98c46383630d733a3282.mkv \
  -i RT894ce44c6ba84eb98300566adae4e7bf.mka \
  instructor.mp4

# add watermark to instructor_video
ffmpeg \
  -i instructor.mp4 \
  -i logo_white.png \
  -filter_complex "[1] scale=120:18 [ovr1], [0:v][ovr1]overlay=10:452" \
  instructor_with_logo.mp4

# Final - Include student video
ffmpeg \
  -i instructor_with_logo.mp4 \
  -i student.mp4 \
  -filter_complex "[1:v]setpts=PTS-STARTPTS+24/TB[v1]; \
                   [v1] scale=120:90 [student], [0:v][student]overlay=510:380:enable='between(t,24,36)'" \
  final.mp4
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.