我正在ffmepg
使用以下命令运行版本 6.1:
ffmpeg \
-y \
-copyts \
-ss 2841000000us \
-to 2843000000us \
-i <INPUT_FILE/URL> \
-fps_mode passthrough \
-an \
-filter_complex "[v:0]fps=fps=4[t1];[t1]showinfo[out6]" \
-map [out6] "C:\\temp\\ffmpeg\\regions_%06d.bmp"
注意:☝️是简化的,参数中的fps
/ filter后面还有更多的过滤器。showinfo
filter_complex
出于兴趣:
- 我正在使用
showinfo
过滤器,因为我希望能够获取正在处理的帧的时间戳 - 我只想每秒处理四帧,因此使用
fps
过滤器 copyts
指定了输出,以便showinfo
与整个视频相关,而不仅仅是处理内容的开始fps_mode passthrough
这样就不会丢失或重复帧
当我运行这个程序时,我得到以下输出showinfo
:
[Parsed_showinfo_1 @ 000002247a51c900] config in time_base: 1/4, frame_rate: 4/1
[Parsed_showinfo_1 @ 000002247a51c900] config out time_base: 0/0, frame_rate: 0/0
[Parsed_showinfo_1 @ 000002247a51c900] n: 0 pts: 11624 pts_time:2906 duration: 1 duration_time:0.25 fmt:yuv420p cl:left sar:1/1 s:1920x1080 i:P iskey:0 type:B checksum:5EF9BE12 plane_checksum:[0EA20F02 7B431A80 7DCB9490] mean:[85 135 144] stdev:[41.5 17.1 29.3]
[Parsed_showinfo_1 @ 000002247a51c900] color_range:tv color_space:bt709 color_primaries:bt709 color_trc:bt709
输出似乎表明第一帧的时间戳为 11624 pts(即 2906 秒,或 48 分 26 秒)。
这是方式从开始显示的时间开始经过:2841000000us(2841 秒,或 47 分 21 秒)。
我怀疑这可能与格式有关。相关输出stderr
为:
mime type is not rfc8216 compliant
[hls @ 0000027c77fd2dc0] Skip ('#EXT-X-VERSION:3')
[hls @ 0000027c77fd2dc0] Skip ('#ID3-EQUIV-TDTG:2023-11-16T13:37:57')
[hls @ 0000027c77fd2dc0] Skip ('#EXT-X-TWITCH-ELAPSED-SECS:0.000')
[hls @ 0000027c77fd2dc0] Skip ('#EXT-X-TWITCH-TOTAL-SECS:21820.003')
[hls @ 0000027c77fd2dc0] Opening 'https://d1mhjrowxxagfy.cloudfront.net/c335467319186f0ab945_darumaisgod_40800750599_1700120047/chunked/0.ts' for reading
[hls @ 0000027c77fd2dc0] Opening 'https://d1mhjrowxxagfy.cloudfront.net/c335467319186f0ab945_darumaisgod_40800750599_1700120047/chunked/1.ts' for reading
Input #0, hls, from 'https://d1mhjrowxxagfy.cloudfront.net/c335467319186f0ab945_darumaisgod_40800750599_1700120047/chunked/index-dvr.m3u8':
Duration: 06:03:40.00, start: 64.001000, bitrate: 0 kb/s
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
Metadata:
variant_bitrate : 0
Stream #0:1: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn
Metadata:
variant_bitrate : 0
Stream #0:2: Data: timed_id3 (ID3 / 0x20334449)
Metadata:
variant_bitrate : 0
但当我尝试不同的视频类型时,我得到:
Input #0, matroska,webm, from 'https://rr5---sn-8xgp1vo-ab5d.googlevideo.com/videoplayback?expire=1703316710&ei=hjiGZYmWM6SP_9EPmtCYoAg&ip=96.250.109.72&id=o-AFKWMi6Avd7t8alGkE4l3B1AbzCBNApprFJAz720_n2G&itag=303&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=LW&mm=31%2C26&mn=sn-8xgp1vo-ab5d%2Csn-p5qddn7z&ms=au%2Conr&mv=m&mvi=5&pcm2cms=yes&pl=20&initcwndbps=1283750&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=6064827915&dur=14618.036&lmt=1699818339689953&mt=1703294953&fvip=5&keepalive=yes&fexp=24007246&c=IOS&txp=730F224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRQIgR_40aset9xfHYzBZGZ8TlrnHj4npZGEE5wnCp8b5JZsCIQDL0Tfk_Mfe0D-cR3qrv1Vm2o4A10ddPOq0qw7ehLRCbg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AAO5W4owRgIhAMVzisKgq6dFqEX3-XW9xxpD-1Wl44B3kZp9rImtC3SyAiEAhItXuk4kkG7pzNUm97sMZQ2twFYo2pG7kq3orIfUbCw%3D':
Metadata:
encoder : google/video-file
Duration: 04:03:38.04, start: 0.000000, bitrate: 3319 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 59.94 fps, 59.94 tbr, 1k tbn (default)
pts_time
第一帧是确切地2841(或 47 分 21 秒,指定的开始时间)。
我怀疑当谈到第一种格式类型时,我做错了一些/效率低下的事情,有没有办法让帧输出更接近这种情况下指定的开始时间?