当前位置: 首页 > news >正文

wordpress 去掉描述的超链接电子商务沙盘seo关键词

wordpress 去掉描述的超链接,电子商务沙盘seo关键词,广东哪家网站建设,自己做的网站加入购物车价格这些函数是用于处理视频文件的Python代码片段,它们依赖于ffmpeg和ffprobe工具,这些工具是FFmpeg项目的一部分,用于处理视频和音频数据。下面是每个函数的用途和用法的总结: 1. ffmpeg_installed() 函数: - 用途&am…

这些函数是用于处理视频文件的Python代码片段,它们依赖于`ffmpeg`和`ffprobe`工具,这些工具是`FFmpeg`项目的一部分,用于处理视频和音频数据。下面是每个函数的用途和用法的总结:

1. `ffmpeg_installed()` 函数:
   - 用途:检查系统是否安装了`ffmpeg`工具。
   - 用法:调用此函数无需参数,它会返回一个布尔值,指示`ffmpeg`是否可用。

2. `video_is_playable(video_filepath: str)` 函数:
   - 用途:确定视频文件是否可以在浏览器中播放。
   - 用法:传入视频文件的路径作为字符串,函数会检查视频的容器格式和编解码器是否符合浏览器的播放标准(如`.mp4`容器使用`h264`编解码器,`.webm`容器使用`vp9`编解码器等)。如果视频符合标准,则返回`True`,否则返回`False`。

3. `convert_video_to_playable_mp4(video_path: str)` 函数:
   - 用途:将视频转换为浏览器可以播放的MP4格式。
   - 用法:传入视频文件的路径作为字符串,函数会尝试将视频转换为MP4格式。如果转换过程中出现错误,则返回原始视频路径。

4. `get_video_length(video_path: str | Path)` 函数:
   - 用途:获取视频文件的时长。
   - 用法:传入视频文件的路径,函数会使用`ffprobe`工具来获取视频的时长,并以秒为单位返回一个浮点数。

这些函数的实现依赖于外部命令行工具`ffmpeg`和`ffprobe`,因此在使用这些函数之前,需要确保这些工具已经正确安装在系统上。此外,代码中还包含了一些错误处理机制,以确保在处理视频文件时能够优雅地处理异常情况。例如,如果`ffmpeg`或`ffprobe`命令失败,或者视频文件的格式不符合预期,函数会返回原始视频路径或抛出异常。
IS_WASM = sys.platform == "emscripten"

def ffmpeg_installed() -> bool:
    if wasm_utils.IS_WASM:
        # TODO: Support ffmpeg in WASM
        return False

    return shutil.which("ffmpeg") is not None


def video_is_playable(video_filepath: str) -> bool:
    """Determines if a video is playable in the browser.

    A video is playable if it has a playable container and codec.
        .mp4 -> h264
        .webm -> vp9
        .ogg -> theora
    """
    from ffmpy import FFprobe, FFRuntimeError

    try:
        container = Path(video_filepath).suffix.lower()
        probe = FFprobe(
            global_options="-show_format -show_streams -select_streams v -print_format json",
            inputs={video_filepath: None},
        )
        output = probe.run(stderr=subprocess.PIPE, stdout=subprocess.PIPE)
        output = json.loads(output[0])
        video_codec = output["streams"][0]["codec_name"]
        return (container, video_codec) in [
            (".mp4", "h264"),
            (".ogg", "theora"),
            (".webm", "vp9"),
        ]
    # If anything goes wrong, assume the video can be played to not convert downstream
    except (FFRuntimeError, IndexError, KeyError):
        return True


def convert_video_to_playable_mp4(video_path: str) -> str:
    """Convert the video to mp4. If something goes wrong return the original video."""
    from ffmpy import FFmpeg, FFRuntimeError

    try:
        with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
            output_path = Path(video_path).with_suffix(".mp4")
            shutil.copy2(video_path, tmp_file.name)
            # ffmpeg will automatically use h264 codec (playable in browser) when converting to mp4
            ff = FFmpeg(
                inputs={str(tmp_file.name): None},
                outputs={str(output_path): None},
                global_options="-y -loglevel quiet",
            )
            ff.run()
    except FFRuntimeError as e:
        print(f"Error converting video to browser-playable format {str(e)}")
        output_path = video_path
    finally:
        # Remove temp file
        os.remove(tmp_file.name)  # type: ignore
    return str(output_path)


def get_video_length(video_path: str | Path):
    if wasm_utils.IS_WASM:
        raise wasm_utils.WasmUnsupportedError(
            "Video duration is not supported in the Wasm mode."
        )
    duration = subprocess.check_output(
        [
            "ffprobe",
            "-i",
            str(video_path),
            "-show_entries",
            "format=duration",
            "-v",
            "quiet",
            "-of",
            "csv={}".format("p=0"),
        ]
    )
    duration_str = duration.decode("utf-8").strip()
    duration_float = float(duration_str)

    return duration_float

http://www.qdjiajiao.com/news/10375.html

相关文章:

  • 网站后台模板 下载互联网产品推广
  • 如何制作一个好网站seo与sem的区别与联系
  • 做app网站的公司名称天津网站优化
  • 库尔勒网站建设推广洛阳seo外包公司费用
  • 在dw里如何做网站网店交易平台
  • 开发网站培训班南宁正规的seo费用
  • 网站公司建设网站关键词列表
  • 网站建设 中企动力 武汉优化网站排名软件
  • 有哪些做废品的网站友情链接作用
  • 甘肃做高端网站的公司广州seo服务外包
  • 搜索引擎推广网站免费推广网站
  • 360建筑网密码忘了seo搜索排名
  • dw做的网站与浏览器不匹配百度sem认证
  • 南通网站建设seo导航站
  • 网站没有备案能访问吗十大软件培训机构
  • 那种系统做网站比较好上海牛巨微seo
  • 网站排名消失广告竞价推广
  • 农业畜牧网站开发站长工具seo综合查询论坛
  • 手机怎么做图纸设计青岛seo网站排名
  • 建站之星收费版quark搜索引擎入口
  • 华为云服务器官网入口广州网站seo
  • 做招聘网站客户要发票怎么办360搜索网址是多少
  • 专业烟台房产网站建设百度推广开户免费
  • php网站开发pptseo是哪里
  • 迅雷黄冈网站推广软件免费网络推广的方法
  • asp和php的建站区别色盲测试图 考驾照
  • 北京建设委员会网站首页优化公司怎么优化网站的
  • 网站建设cms抖音账号权重查询入口
  • 网站建设客户沟通模块百度录入网站
  • 合肥网站设计制作微信群发软件