FFmpeg 命令为 mpg2、mss、lxf、3g2 视频文件添加文本水印

问题描述

我正在使用以下命令在视频文件添加水印:

ffmpeg -i input.mpg2 -vf "drawtext=text='Hello World':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" textoutput.mpg2

mpg2 输入文件错误

输入#0,mpeg,来自'mpg2.mpg2':
持续时间:00:02:27.07,开始:0.213367,比特率:4419 kb/s 流 #0:0[0x1e0]:视频:mpeg2video(主),yuv420p(tv,bt470bg/bt470m/bt4 70m,底部优先),704x480 [SAR 1:1 DAR 22:15], 29.97 fps、29.97 tbr、90k tbn、59.94 tbc 侧面数据: cpb:比特率最大/最小/平均:6000000/0/0 缓冲区大小:1835008 vbv_delay:不适用 流 #0:1[0x1c0]:音频:mp2,44100 Hz,立体声,s16p,224 kb/s [NULL @ 000000bd67d2b3c0] 无法找到合适的输出格式 '输出.mp g2' Output.mpg2:无效参数

mss、lxf 和 3g2 视频文件出现类似错误。 如何为这些视频文件格式添加水印?

解决方法

FFmpeg 不支持这些任意扩展/格式。相反,请使用:

不支持 支持的等价物
// Initialization this->stream.msg = nullptr; this->stream.state = nullptr; this->stream.zalloc = &allocate; // delegates to malloc() (Z_SOLO) this->stream.zfree = &free; // delegates to free() (Z_SOLO) this->stream.data_type = Z_BINARY; int result = ::deflateInit(&this->stream,Z_DEFAULT_COMPRESSION); // error handling performed here // ... while(input_data_available) { this->stream.next_in = uncompressedBuffer; this->stream.avail_in = static_cast<uInt>(uncompressedByteCount); this->stream.next_out = outputBuffer; this->stream.avail_out = static_cast<uInt>(outputByteCount); int result = ::deflate(&this->stream,Z_NO_FLUSH); // error handling performed here } do { this->stream.next_in = nullptr; this->stream.avail_in = 0; this->stream.next_out = outputBuffer; this->stream.avail_out = static_cast<uInt>(outputByteCount); int result = ::deflate(&this->stream,Z_FINISH); // error handling performed here } while(this->stream.avail_out == 0); assert(result == Z_STREAM_END); .mpg2
-c:v mpeg2video output.mpg .mss
.wmv 不支持(或使用 .lxf
.mpg 这是支持的,但受限于某些参数。见下文。

3G2

输出必须是:

  • 具有 8000 Hz 采样率的单声道音频。 (假设您需要 AMR 音频。)
  • 以下音频比特率之一:4.75k、5.15k、5.90k、6.70k、7.40k、7.95k、10.20k、12.20k、12.20k(假设您需要 AMR 音频。)
  • 以下视频尺寸之一:128x96、176x144、352x288、704x576 和 1408x1152。

如果失败,请查看错误消息。他们会告诉你哪里出了问题。

示例命令:

.3g2

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...