我正在尝试在我的视频上叠加一个seconds:milliseconds
时间戳,但是我已经在这个问题上突破了几个小时而没有任何结果。如果我写:
ffmpeg -f lavfi -i testsrc=duration=5:size=800x600:rate=30 -vf drawtext="fontfile=C\\:/Windows/Fonts/arial.ttf:text='%{pts}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" -preset ultrafast output.mp4
%{pts}
未展开,仅显示框架上的文字文字{pts}
。
请注意,我已经在这个时间戳覆盖的内容上阅读了大量关于网络的指南(ffmpeg docs / guides / wikis,stackoverflow,博客等),但没有一个解决方案/语法有效:它只是覆盖了文字。
某些背景信息:
ffmpeg
Zeranoe版本git-12a419d(2015-11-23)完整输出日志:
[E:\]ffmpeg -f lavfi -i testsrc=duration=5:size=800x600:rate=30 -vf drawtext="fontfile=C\\:/Windows/Fonts/arial.ttf:text=%{pts}: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" -preset ultrafast output.mp4
ffmpeg version N-76822-g12a419d Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.100 / 57. 16.100
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 15.100 / 6. 15.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, lavfi, from 'testsrc=duration=5:size=800x600:rate=30':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 800x600 [SAR 1:1 DAR 4:3], 30 tbr, 30 tbn, 30 tbc
File 'output.mp4' already exists. Overwrite ? [y/N] y
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 00000000003f83c0] using SAR=1/1
[libx264 @ 00000000003f83c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 00000000003f83c0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 00000000003f83c0] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf57.19.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 800x600 [SAR 1:1 DAR 4:3], q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.16.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 150 fps= 61 q=-1.0 Lsize= 185kB time=00:00:05.00 bitrate= 303.2kbits/s
video:184kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.755086%
[libx264 @ 00000000003f83c0] frame I:1 Avg QP:20.00 size: 18409
[libx264 @ 00000000003f83c0] frame P:149 Avg QP:16.11 size: 1135
[libx264 @ 00000000003f83c0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 00000000003f83c0] mb P I16..4: 0.7% 0.0% 0.0% P16..4: 5.1% 0.0% 0.0% 0.0% 0.0% skip:94.2%
[libx264 @ 00000000003f83c0] coded y,u,v intra: 5.0% 3.3% 2.8% inter: 1.1% 1.0% 0.9%
[libx264 @ 00000000003f83c0] i16 v,h,dc,p: 81% 6% 2% 11%
[libx264 @ 00000000003f83c0] kb/s:299.93
[E:\]
答案 0 :(得分:2)
删除%{pts}
周围的撇号(由航空公司提出),并将百分号用双引号括起来,如下所示。
ffmpeg -f lavfi -i testsrc=duration=5:size=800x600:rate=30 -vf drawtext=
"fontfile=C\\:/Windows/Fonts/arial.ttf:text="%"{pts}:x=(w-tw)/2:y=h-(2*lh):
fontcolor=white:box=1:boxcolor=0x00000000@1" -preset ultrafast output.mp4
(我还删除了-vf参数中的空格,因为它们不是必需的。)
你看,Unix shell以及Windows命令行对命令进行了一些更改,这就是为什么你需要重复这样的反斜杠:\\
。这可能会变得复杂和混乱。每个平台都有点不同,因此很难在没有经过实验的情况下为您提供有效的解决方案。目前我无法访问安装了ffmpeg的Windows命令行,因此我无法测试此解决方案。但我知道百分号%
是专门处理的。它似乎被你的命令行吃了,这就是为什么你看到文字{pts}
覆盖在框架上的原因。
请参阅此StackOverflow回答Is there a way to prevent percent expansion of env variable in Windows command line?
编辑:由于OP补充说他使用TCC/LE作为shell,我建议加倍百分号,如下所示:
ffmpeg -f lavfi -i testsrc=duration=5:size=800x600:rate=30 -vf drawtext=
"fontfile=C\\:/Windows/Fonts/arial.ttf:text=%%{pts}:x=(w-tw)/2:y=h-(2*lh):
fontcolor=white:box=1:boxcolor=0x00000000@1" -preset ultrafast output.mp4
此解决方案也在上面提到的StackOverflow答案中讨论过。