goncziakos/sonata-media-provider-video-bundle

此包扩展了Sonata Media Bundle,创建了一个新的视频上传提供商,并使用FFmpeg

安装: 385

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 16

类型:symfony-bundle

v2.1.0 2024-07-17 14:57 UTC

This package is not auto-updated.

Last update: 2024-09-25 15:48:41 UTC


README

SonataMediaProviderVideoBundle 扩展了 SonataMediaBundle 提供商,创建了一个新的视频 提供商 用于上传视频,生成缩略图并使用FFmpeg。

此包基于 xmon/SonataMediaProviderVideoBundle,从 Grand-Central/SonataMediaProviderVideoBundle Grand-Central/SonataMediaProviderVideoBundle 分支而来,似乎已被遗弃,我进行了许多修改,因此决定创建一个新的功能齐全且文档完善的工程。

需求

您需要在服务器上安装 ffmpeg

安装

安装此包

$ composer require xmon/sonata-media-provider-video-bundle 

将VideoBundle添加到您的应用内核

// config/bundles.php
<?php

return [
    // ...
    Xmon\SonataMediaProviderVideoBundle\XmonSonataMediaProviderVideoBundle::class => ['all' => true],
];

配置示例

安装包后,请确保配置以下参数

xmon_sonata_media_provider_video:
    ffmpeg_binary: "/usr/bin/ffmpeg" # Required, ffmpeg binary path
    ffprobe_binary: "/usr/bin/ffprobe" # Required, ffprobe binary path
    binary_timeout: 60 # Optional, default 60
    threads_count: 4 # Optional, default 4
    config:
        image_frame: 0 # Optional, default 10, Can not be empty. Where the second image capture
        video_width: 640 # Optional, default 640, Can not be empty. Video proportionally scaled to this width
    formats:
        mp4: true # Optional, default true, generate MP4 format
        ogg: true # Optional, default true, generate OGG format
        webm: true # Optional, default true, generate WEBM format

Twig使用

为了打印已保存到元数据字段的转换视频的URL,我创建了3个twig过滤器

{{ media|video_mp4 }}
{{ media|video_ogg }}
{{ media|video_webm }}

致谢