V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
algas
V2EX  ›  Python

imageio 能否从视频中间某帧开始读视频(其它方案也行)

  •  
  •   algas · 2021-08-28 00:23:26 +08:00 · 1619 次点击
    这是一个创建于 971 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我的视频稍微有点大,我想同时从视频的不同位置开始读取,并行处理。
    但是,目前只能循环 vid.get_data(i) 到需要的目标位置,如果直接给一个比较大的 i,
    vid.get_data(i)就会返回全 0 的数据。

    不知道有没有什么方法可以快速定位到视频中间的某些位置。

    以下是一些信息:

    In [2]: import imageio
    In [3]: vid=imageio.get_reader('380670.avi','ffmpeg')
    In [4]: vid.get_meta_data()
    Out[4]:
    {'plugin': 'ffmpeg',
    'nframes': inf,
    'ffmpeg_version': '4.2.2-static https://johnvansickle.com/ffmpeg/ built with gcc 8 (Debian 8.3.0-6)',
    'codec': 'rawvideo,',
    'pix_fmt': 'pal8',
    'fps': 50.0,
    'source_size': (832, 832),
    'size': (832, 832),
    'duration': 12032.6}
    5 条回复    2021-08-29 18:34:58 +08:00
    LXJ
        1
    LXJ  
       2021-08-28 09:04:59 +08:00   ❤️ 1
    用 moviepy
    emonber
        2
    emonber  
       2021-08-28 11:03:46 +08:00 via iPhone   ❤️ 1
    用 OpenCV 或者 PyAV
    Juszoe
        3
    Juszoe  
       2021-08-28 11:11:57 +08:00   ❤️ 1
    题外话,考虑一下将 rawvideo 转换成其他编码?用 rawvideo 来存储未免也太大了
    algas
        4
    algas  
    OP
       2021-08-29 18:32:14 +08:00
    @emonber
    用 pyav 解决了,av 库里有 seek 函数,定位很快。感谢!
    algas
        5
    algas  
    OP
       2021-08-29 18:34:58 +08:00
    @Juszoe
    是超级大,3.5 小时的视频,400GB 的空间....
    这个默认格式我现在还改不了它(上游贡献了这么一个玩意),好在视频处理完成后就可以删除了,目前问题还不大。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2680 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:55 · PVG 23:55 · LAX 08:55 · JFK 11:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.