<?php namespace Api\Api;
use Dever;
class Video
{
    # 获取视频基本信息
    public function remote()
    {
        $txt = Dever::input('txt');
        if (!$txt) {
            Dever::error('请传入参数');
        }
        $type = Dever::input('type');
        return Dever::load('video', 'api')->remote($txt, $type);
    }

    # 视频处理
    public function handle()
    {
        $input = Dever::input('input');
        if (!$input) {
            Dever::error('请传入参数');
        }
        $output = Dever::input('output');
        $option = array
        (
            'time' => array(3, 1),
            'video' => array
            (
                // 去除水印 delogo=x=714:y=28:w=130:h=50
                # 自带的过滤器
                /*
                'drawtext' => array
                (
                    'fontfile' => 'test',
                    'text' => '你好',
                ),*/
                //'transpose' => 1,
                # 定义好的过滤器
                'text' => array
                (
                    '你好',
                    25,
                    'white',
                    50,
                    50,
                ),
            ),
            /*
            'filter_complex' => array
            (
                '[1:v]chromakey=0x00d810:0.1:0.2[ckout]',
                '[0:v][ckout]overlay[out]',
            ),*/
        );
        /*
        $input = array
        (
            'file' => $input,
            'option' => array
            (
                'f' => 'lavfi',
            ),
        );
        $output = array
        (
            'file' => $input['file'] . '_clip.mp4',
            'option' => array
            (
                # 覆盖
                'y' => '',
                # 音频码率
                'b:a' => '10000k',
                # 视频码率
                'b:v' => '10000k',
                'an' => '',
                'sn' => '',
                'vn' => '',
            ),
        );*/
        return Dever::load('video', 'api')->handle($input, $output, $option);
    }

    # 视频合并
    public function merge()
    {
        $video = Dever::input('video');
        if (!$video) {
            Dever::error('请传入参数');
        }
        $option = array();
        return Dever::load('video', 'api')->handle($video, $option);
    }
}