简体   繁体   English

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

[英]What does the fps mean in the ffmpeg output?

I am streaming a static png file with ffmpeg and it uses basically all my CPU. 我正在用ffmpeg流式传输一个静态png文件,它基本上使用了我的所有CPU。 It seems a bit greedy to me, and even though I limited the fps on the input and output size, I am seeing a huge fps printed out. 对我来说似乎有点贪婪,即使我将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

As you can see the frame counter goes up quickly and fps=579 is reported on the last line. 如您所见,帧计数器迅速增加,最后一行报告fps = 579 I am confused now, what does that fps mean, if above the low frame per secs are also mentioned (output 10fps, input 1 fps) 我现在很困惑,如果还提到每秒低帧以上,那么fps意味着什么(输出10fps,输入1fps)

What am I doing wrong and how could I reduce CPU load more given that it's a static file that is being streamed. 我做错了什么,并且鉴于正在传输的是静态文件,我该如何减少CPU负载?

Thanks! 谢谢!

ffmpeg attempts to decode and encode as fast as it can. ffmpeg尝试尽快解码和编码。 Just because you set the output to be 10 frames per second does not mean that it will (de|en)code realtime at 10 frames per second. 仅仅将输出设置为每秒10帧并不意味着它将以每秒10帧的速度实时(解码)。

Try the -re input option. 尝试使用-re输入选项。 From the ffmpeg cli-tool documentation : ffmpeg cli-tool文档中

Read input at native frame rate. 以原始帧速率读取输入。 Mainly used to simulate a grab device or live input stream (eg 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. 默认情况下, ffmpeg尝试尽快读取输入。 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 (eg live streaming). 这对于实时输出(例如实时流)很有用。

Example: 例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM