Skip to main content
Glama

play_video

Play video files locally using FFmpeg, supporting formats like mkv, mp4, mov, and avi. Adjust playback speed and enable loop mode for continuous viewing.

Instructions

使用 ffplay 播放视频文件,支持mkv,mp4,mov,avi,3gp等等

参数:
video_path(str) - 视频文件的路径。
speed(float) - 浮点型,播放速率,建议0.5-2之间。
loop(int) - 整形,是否循环播放,1:不循环,播放后就退出,0: 循环播放。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
loopNo
speedNo
video_pathYes

Implementation Reference

  • MCP tool handler for 'play_video', registered via @mcp.tool() decorator. Delegates execution to cut_video.video_play with parameters.
    @mcp.tool()
    def play_video(video_path, speed = 1, loop = 1):
        """
        使用 ffplay 播放视频文件,支持mkv,mp4,mov,avi,3gp等等
    
        参数:
        video_path(str) - 视频文件的路径。
        speed(float) - 浮点型,播放速率,建议0.5-2之间。
        loop(int) - 整形,是否循环播放,1:不循环,播放后就退出,0: 循环播放。
        """
        return cut_video.video_play(video_path,speed=speed,loop=loop)
  • Core helper function implementing video playback logic using ffplay. Constructs FFplay command with speed adjustment via filters and loop option.
    def video_play(video_path: str, speed, loop):
        speed = float(speed)
        loop = int(loop)
        cmd = f" -loop {loop} "
        if loop != 0:
            cmd = f" {cmd} -autoexit"
        audio_filter_str = ""
        video_filter_str = ""
        if (speed != 1):
            fmt_ctx = ffmpeg.media_format_ctx(video_path)
            if len(fmt_ctx.audio_streams) > 0:
                audio_filter_str = f"-af atempo={speed}"
            if len(fmt_ctx.video_streams) > 0:
                video_filter_str = f"-vf setpts={1/speed}*PTS"
        cmd = f" {cmd } {audio_filter_str} {video_filter_str}   -i {video_path}"
        print(cmd)
        return ffmpeg.run_ffplay(cmd, timeout=60)
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/video-creator/ffmpeg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server