Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新版本关于分辨率的获取问题 #608

Open
hllkk opened this issue Dec 1, 2024 · 3 comments
Open

新版本关于分辨率的获取问题 #608

hllkk opened this issue Dec 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@hllkk
Copy link

hllkk commented Dec 1, 2024

新版本中无法获取到视频的分辨率信息,我尝试使用解释器直接运行这段代码,但会的info信息中没有视频的长度和宽度的信息,虽然有resolution字段,但是都是返回的NULL,因此我在这提议,使用ffmpeg-python来实现这个功能,实现方式也很简单
大致我写的代码如下:
async def get_resolution_ffmpeg(url):
"""
获取直播流的视频分辨率(宽度和高度)
"""
try:
# 将参数封装成字典
probe_args = {
'v': 'error',
'select_streams': 'v:0',
'show_entries': 'stream=width,height'
}
# 使用 asyncio.wait_for 控制超时
probe = await asyncio.wait_for(
asyncio.to_thread(ffmpeg.probe, url, **probe_args),
timeout=settings.TIMEOUT # 设置超时为 10 秒
)
# 解析输出
width = probe['streams'][0]['width']
height = probe['streams'][0]['height']

    if width and height:
        return f"{width}x{height}"  # 返回字符串格式的分辨率
    return None  # 如果未能获取分辨率,则返回 None
except asyncio.TimeoutError:
    print(f"TimeoutError: Timeout occurred while probing {url}")
    return None
except ffmpeg.Error as e:
    print(f"Error occurred while probing {url}: {e}")
    return None
@Guovin
Copy link
Owner

Guovin commented Dec 2, 2024

旧版是有ffmpeg提取分辨率数据的,但由于效率、性能消耗、构建等原因暂时停用了,yt-dlp也有结合ffmpeg的配置,具体我会去研究下

@Guovin Guovin added the enhancement New feature or request label Dec 2, 2024
@Mrmanbanpai
Copy link

我想在软路由上跑此项目 配合投影仪使用 有内网页面版的组播播放器吗

@Guovin
Copy link
Owner

Guovin commented Dec 2, 2024

我想在软路由上跑此项目 配合投影仪使用 有内网页面版的组播播放器吗

目前暂没有网页版的播放器,但在计划中,项目已经创建https://github.com/Guovin/iptv-web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants