martin1982/live-broadcast-sonata-admin-bundle

直播捆绑包的Sonata插件

v4.0.1 2023-02-13 12:19 UTC

This package is auto-updated.

Last update: 2024-09-06 17:28:34 UTC


README

Build status Latest stable version

License Total downloads

目录

关于

直播捆绑包将使您能够将直播视频流计划到各种频道,如Twitch、YouTube Live、Facebook Live(称为输出或频道)。

作为“输入”,我们支持文件、URL或现有的RTMP流。

有关更多信息,您可以查看下面的最新记录演示,检查演示项目https://github.com/Martin1982/live-broadcast-demo或继续阅读;

IMAGE ALT TEXT

先决条件

广播员需要一些命令;

  • ffmpeg 3.x或更高版本

在Linux上

  • ps
  • kill

在Mac上

  • ps
  • grep
  • kill

在Windows上

  • tasklist
  • taskkill

要测试这些先决条件,可以在以下安装描述之后使用Symfony命令livebroadcaster:test:shell

基本安装

此捆绑包将在Packagist上提供。然后您可以使用Composer安装它。

$ composer require martin1982/live-broadcast-bundle

接下来,对于Symfony < 4,在内核中启用捆绑包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Martin1982\LiveBroadcastBundle\LiveBroadcastBundle(),
    );
}

使用Doctrine通过广播实体更新您的数据库模式,当升级时,建议使用迁移。

要启动广播调度程序,可以运行以下命令

$ php app/console livebroadcaster:broadcast

为了通过管理界面提供广播计划,我们已添加了对Sonata Admin捆绑包的支持。

FFMpeg日志目录

要查看FFMpeg的输出,您需要配置app/config/config.yml中的日志目录。

 live_broadcast:
    ffmpeg:
        log_directory: '%kernel.logs_dir%'

事件循环

您可以使用此配置来设置事件循环计时器

live_broadcast:
    eventloop:
        timer: 5

缩略图设置

为缩略图设置以下配置

live_broadcast:
    thumbnail:
        upload_directory: '%kernel.root_dir%/../web/uploads/thumbnails'
        web_path: '/uploads/thumbnails'

启用Facebook直播

https://developers.facebook.com上创建一个Facebook应用,并具有以下权限

  • user_videos
  • user_events
  • user_managed_groups
  • manage_pages
  • publish_actions
  • 直播视频API

编辑app/config/config.yml,使用以下配置

live_broadcast:
    facebook:
        application_id: YourFacebookAppId
        application_secret: YourFacebookAppSecret

启用YouTube直播

登录到https://console.developers.google.com/并启用“YouTube Data API v3”。

为您的服务器设置OAuth凭证。如果您使用此捆绑包中的Sonata Admin,则重定向URI的路径为<your domain>/admin/channel/youtube/oauthprovider

将YouTube API信息添加到您的config.yml

live_broadcast:
    youtube:
        client_id: YourGoogleOauthClientId
        client_secret: YourGoogleOauthClientSecret
        redirect_route: admin_martin1982_livebroadcast_channel_abstractchannel_youtubeoauth

将这些行添加到您的parameters.yml(用于生成缩略图URL)

parameters:
    router.request_context.host: broadcast.com
    router.request_context.scheme: https

添加新输出平台

在Entity/Channel中创建一个新的Channel实体,该实体扩展了AbstractChannel(例如,ChannelNew)

在Service/StreamOutput中创建一个新的StreamOutput服务,该服务实现OutputInterface(例如,OutputNew)

在Resources/config/services.yml中使用输出标签配置该服务

live.broadcast.output.new:
    class: Martin1982\LiveBroadcastBundle\Service\StreamOutput\OutputNew
    tags:
        - { name: live.broadcast.output, platform: 'New' }

要添加对Sonata admin的支持,请向Admin/ChannelAdmin.php添加一个新表单

protected function configureFormFields(FormMapper $formMapper)
{
    if ($subject instanceof ChannelNew) {
        $formMapper->add('...', 'text', array('label' => '...'));
    }
}

接下来,在Resources/config/admin.yml中为channelAdmin添加子类

sonata.admin.channel
    calls:
        - [setConfiguredSubclasses, [ { "Name": Martin1982\LiveBroadcastBundle\Entity\Channel\ChannelNew } ] ]

管理员GUI支持

此软件包是为了支持用于Web GUI界面的Sonata Admin而创建的,Packagist上还有其他风味可供选择(没有GUI的基础martin1982/live-broadcast-bundle软件包)以及EasyAdmin(martin1982/live-broadcast-easyadmin-bundle)。