ffmpeg - ffmpeg 输出中的 fps 是什么意思?

标签 ffmpeg

我正在使用 ffmpeg 流式传输一个静态 png 文件,它基本上使用了我所有的 CPU。这对我来说似乎有点贪心,即使我在输入和输出大小上限制了 fps,我还是看到打印出巨大的 fps。

w:\ffmpeg\bin>ffmpeg.exe -loop 1 -framerate 1 -i w:\colorbar2.png -r 10 -vcodec libx264 -pix_fmt yuv420p -r 10 -f mpegts udp://127.0.0.1:10001?pkt_size=1316
ffmpeg version N-68778-g5c7227b Copyright (c) 2000-2014 the FFmpeg developers
  built on Dec 29 2014 22:12:54 with gcc 4.9.2 (GCC)

Input #0, png_pipe, from 'w:\colorbar2.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, pal8, 320x240 [SAR 3779:3779 DAR 4:3], 1 fps, 1 tbr, 1 tbn, 1 tbc
[libx264 @ 00000000002fb320] using SAR=1/1
[libx264 @ 00000000002fb320] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000000002fb320] profile High, level 1.2
Output #0, mpegts, to 'udp://127.0.0.1:10001?pkt_size=1316':
  Metadata:
    encoder         : Lavf56.16.102
    Stream #0:0: Video: h264 (libx264), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 10 fps, 90k tbn, 10 tbc
    Metadata:
      encoder         : Lavc56.19.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=561310 fps=579 q=25.0 size=  144960kB time=15:35:25.80 bitrate=  21.2kbits/s dup=505179 drop=0

如您所见,帧计数器快速上升, fps=579 在最后一行报告。我现在很困惑,如果还提到了每秒低帧数(输出 10fps,输入 1 fps),那 fps 是什么意思

我做错了什么,考虑到它是一个正在流式传输的静态文件,我该如何减少 CPU 负载。

谢谢!

最佳答案

ffmpeg尝试尽可能快地解码和编码。仅仅因为您将输出设置为每秒 10 帧并不意味着它将以每秒 10 帧的速度实时(de|en)编码。

试试 -re输入选项。来自 ffmpeg cli-tool documentation :

Read input at native frame rate. Mainly used to simulate a grab device or live input stream (e.g. when reading from a file). Should not be used with actual grab devices or live input streams (where it can cause packet loss). By default ffmpeg attempts to read the input(s) as fast as possible. This option will slow down the reading of the input(s) to the native frame rate of the input(s). It is useful for real-time output (e.g. live streaming).



例子:
ffmpeg.exe -re -loop 1 -framerate 10 -i w:\colorbar2.png -c:v libx264 \
-tune stillimage -pix_fmt yuv420p -f mpegts udp://127.0.0.1:10001?pkt_size=1316

关于ffmpeg - ffmpeg 输出中的 fps 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28794793/

相关文章:

python - 过滤视频中的掌声

ffmpeg - 通过 mlt xml 传递 ffmpeg 选项

c++ - 捕获和播放 MJPEG - 使用 OpenCV 和 ffmpeg 通过 UDP 传输网络视频流

audio - FFMPEG AAC 编码器问题

ffmpeg - ffmpeg 编码后,AVPacket pts 和 dts 为 AV_NOPTS_VALUE

android - 在 Android 上使用 librtmp 编译 FFMPEG 时出现 "Undefined Reference"

android - 在androidNDK中使用FFmpeg库播放视频

.net - 软件包安装在 docker 内,但实际命令提供异常

ffmpeg 移动文本 drawtext

ffmpeg 给出错误选项 movflags not found