我使用以下命令行通过SDL播放视频:
ffmpeg -i input.mkv -f sdl "Video"
视频播放速度太快,ffmpeg打印出帧速率约为500(不稳定,只是尽可能快地播放) 我试图按如下方式限制帧速率,但这些都没有任何影响:
ffmpeg -i input.mkv -r 25 -f sdl "Video"
ffmpeg -i input.mkv -f sdl -r 25 "Video"
ffmpeg -i input.mkv -framerate 25 -f sdl "Video"
ffmpeg -i input.mkv -f sdl -framerate 25 "Video"
我在Windows 7上使用ffmpeg版本ffmpeg-20150605-git-7be0f48-win64-static
ffplay input.mkv
效果非常好。
谢谢!
编辑 ffmpeg -i input.mkv -r 25 -f sdl "Video"
的控制台输出如下:
ffmpeg version N-72662-g7be0f48 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopenc
ore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --ena
ble-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable
-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enabl
e-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable
-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --e
nable-lzma --enable-decklink --enable-zlib
libavutil 54. 26.101 / 54. 26.101
libavcodec 56. 41.101 / 56. 41.101
libavformat 56. 34.100 / 56. 34.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, matroska,webm, from 'input.mkv':
Metadata:
ENCODER : Lavf56.34.100
Duration: 00:20:00.20, start: 0.000000, bitrate: 1006 kb/s
Stream #0:0: Video: h264 (High), yuv420p, 720x304, SAR 1:1 DAR 45:19, 23.98
fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
BPS : 813254
BPS-eng : 813254
DURATION : 02:13:35.090000000
DURATION-eng : 02:13:35.090000000
NUMBER_OF_FRAMES: 192170
NUMBER_OF_FRAMES-eng: 192170
NUMBER_OF_BYTES : 814788601
NUMBER_OF_BYTES-eng: 814788601
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 32bit built on
Jun 9 2014 15:08:34
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 32bit buil
t on Jun 9 2014 15:08:34
_STATISTICS_WRITING_DATE_UTC: 2015-01-07 06:01:37
_STATISTICS_WRITING_DATE_UTC-eng: 2015-01-07 06:01:37
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
Metadata:
LANGUAGE : eng
BPS : 185184
BPS-eng : 185184
DURATION : 02:13:35.125000000
DURATION-eng : 02:13:35.125000000
NUMBER_OF_FRAMES: 375709
NUMBER_OF_FRAMES-eng: 375709
NUMBER_OF_BYTES : 185534548
NUMBER_OF_BYTES-eng: 185534548
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 32bit built on
Jun 9 2014 15:08:34
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 32bit buil
t on Jun 9 2014 15:08:34
_STATISTICS_WRITING_DATE_UTC: 2015-01-07 06:01:37
_STATISTICS_WRITING_DATE_UTC-eng: 2015-01-07 06:01:37
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Output #0, sdl, to 'Video':
Metadata:
encoder : Lavf56.34.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x304 [SAR 1:1
DAR 45:19], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
BPS : 813254
BPS-eng : 813254
DURATION : 02:13:35.090000000
DURATION-eng : 02:13:35.090000000
NUMBER_OF_FRAMES: 192170
NUMBER_OF_FRAMES-eng: 192170
NUMBER_OF_BYTES : 814788601
NUMBER_OF_BYTES-eng: 814788601
_STATISTICS_WRITING_APP: mkvmerge v7.0.0 ('Where We Going') 32bit built on
Jun 9 2014 15:08:34
_STATISTICS_WRITING_APP-eng: mkvmerge v7.0.0 ('Where We Going') 32bit buil
t on Jun 9 2014 15:08:34
_STATISTICS_WRITING_DATE_UTC: 2015-01-07 06:01:37
_STATISTICS_WRITING_DATE_UTC-eng: 2015-01-07 06:01:37
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
encoder : Lavc56.41.101 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=28726 fps=244 q=0.0 Lsize=N/A time=00:20:00.20 bitrate=N/A
video:9210274kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxi
ng overhead: unknown
答案 0 :(得分:3)
在试验和阅读文档后,我最终找到了我的问题的答案:
ffmpeg -re -i input.mkv -f sdl "Video"
解释:-r
,-framerate
个选项以及fps
过滤器都会影响制作的视频帧率并将其写入作为输出文件的元数据,稍后由视频播放器使用。对于sdl
(以及其他一些),这没有任何效果,因为视频只是逐帧输出到OpenGL表面。执行此操作的速度完全取决于ffmpeg处理速度(在我的情况下,这个速度约为500fps)。为了限制这一点,存在-re
选项,它将处理速度设置为输入定义的速度。