如何从TS视频流截图?

2024-09-29 23:26:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从视频流每1分钟截图。视频流提供为m3u8 file

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:112076
#EXT-X-PROGRAM-DATE-TIME:2019-03-19T16:16:53Z
#EXTINF:6.000, 2019/03/19/16/16/53-06000.ts
#EXTINF:6.000, 2019/03/19/16/16/59-06000.ts
#EXTINF:6.000, 2019/03/19/16/17/05-06000.ts
#EXTINF:6.000, 2019/03/19/16/17/11-06000.ts

我找到了一个库来解析它-https://github.com/globocom/m3u8。但是我不明白如何将这个TS视频流转换成单个jpeg文件。 我应该这么做吗

  1. 下载TS文件
  2. 查找所需帧
  3. 把它拔出来
  4. 删除ts文件?在

我应该使用OpenCV还是有更简单的解决方案?在

使用OpenV


Tags: 文件dateversionprogrammediaextfilesequence
2条回答

我想你可以用VLC来做。在

EDIT:看起来与https://superuser.com/questions/1379361/vlc-and-m3u8-file非常相似。以下答案可能不适用于您的文件格式(除非更高版本的VLC可以正常工作…)。或许可以看看this question,这可能会给你更多的洞察力

据我所知,VLC使用TS文件/流进行罚款


一旦有了TS文件,就应该能够使用vlc执行屏幕截图。

根据this link和to this SO question and answers,可以启动VLC并使其执行屏幕捕获。 根据VLC documentation,这似乎是可能的。在

应该在win/linux/mac上运行。在

我已经测试过了,我需要用我的个人电脑来测试。

引用:

With new VLC versions (VLC 1.1.0 and above), the thumbnails are generated with scene video filter

vlc C:\video\to\process.mp4 rate=1 video-filter=scene vout=dummy start-time=10 stop-time=11 scene-format=png scene-ratio=24 scene-prefix=snap scene-path=C:\path\for\snapshots\ vlc://quit

If you want to get rid of the sound you can add " aout=dummy" next to " vout=dummy".

For older VLC versions (1.0.0 and below) the same can be done with image output module

vlc C:\video\to\process.mp4 -V image start-time 0 stop-time 1 image-out-format jpg image-out-ratio 24 image-out-prefix snap vlc://quit

What it does:

When VLC media player runs it 'plays' the video for one second without actually showing the video on screen, and then quits, leaving us with a file named 'snap000000.jpg', containing an image of the first frame of the video.

这是ffmpeg的工作。
要每分钟从playlist捕获帧,可以使用:

ffmpeg -i "http://cam.l-invest.ru/nagatinskaya4/tracks-v1/index.m3u8" -vf fps=1/60 invest.ru_%04d.jpg -hide_banner

以上将产生:

^{pr2}$

invest.ru_0001.jpg

^{3}$

invest.ru_0002.jpg

等等。。。每60英寸一次


注意事项

  1. invest.ru_0002.jpg正好是在invest.ru_0001.jpg之后60〃拍摄的,正如您在右上角的时间戳中看到的。

  2. -vf表示ffmpeg使用视频过滤器fps=1/60,因此它将每60〃(src)提取一帧。

  3. 如果需要,可以更改输出格式和文件名结构(例如:^{})。请检查ffmpegimage2 docs中的可用选项。在

相关问题 更多 >

    热门问题