Ejemplo n.º 1
0
 public function updateFormatOptions(&$save_path)
 {
     parent::updateFormatOptions($save_path);
     //			ffmpeg moans about audio sample frequencies on videos that aren't one of the following
     //			audio sample rates. 44100, 22050, 11025
     if (empty($this->_format['audio_sample_frequency']) === true) {
         $audio_data = $this->_media_object->readAudioComponent();
         if (empty($audio_data['sample']['rate']) === true) {
             $this->setAudioSampleFrequency($this->_restricted_audio_sample_frequencies[0]);
         } else {
             if (in_array($audio_data['sample']['rate'], $this->_restricted_audio_sample_frequencies) === false) {
                 $current_sample_rate = $audio_data['sample']['rate'];
                 if ($current_sample_rate > $this->_restricted_audio_sample_frequencies[0]) {
                     $current_sample_rate = $this->_restricted_audio_sample_frequencies[0];
                 } else {
                     // TODO
                     $current_sample_rate = $this->_restricted_audio_sample_frequencies[0];
                 }
                 $this->setAudioSampleFrequency($current_sample_rate);
             }
         }
     }
     //			assign a post process so that yamdil (http://yamdi.sourceforge.net/) injects the meta data into to the flv.
     if ($this->_post_process_meta_data_injection === true) {
         $this->_media_object->registerOutputPostProcess(array($this, 'postProcessMetaData'));
     }
     return $this;
 }
Ejemplo n.º 2
0
 public function updateFormatOptions(&$save_path, $overwrite)
 {
     parent::updateFormatOptions($save_path, $overwrite);
     if ($this->_max_frames_on_no_timecode === true && preg_match('/%timecode|%index|%[0-9]*d/', $save_path) === 0) {
         $this->setVideoMaxFrames(1);
     }
     return $this;
 }
Ejemplo n.º 3
0
 public function __construct($input_output_type = Format::OUTPUT, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     if ($input_output_type === 'output') {
         $this->setAudioCodec('libvorbis')->setVideoCodec('libtheora')->setFormat('ogg');
     }
     $this->_restricted_audio_codecs = array('libvorbis', 'vorbis');
     $this->_restricted_video_codecs = array('libtheora', 'theora');
 }
Ejemplo n.º 4
0
 public function __construct($input_output_type = Format::OUTPUT, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     $this->_format = array_merge($this->_format, array('h264_preset' => null, 'h264_tune' => null, 'h264_constant_quantization' => null));
     $this->_format_to_command = array_merge($this->_format_to_command, array('h264_preset' => '-preset <setting>', 'h264_tune' => '-tune <setting>', 'h264_constant_quantization' => '-qp <setting>'));
     $this->_restricted_video_presets = null;
     if ($input_output_type === 'output') {
         $this->setAudioCodec('mp3')->setVideoCodec('h264')->setFormat('h264');
     }
 }
Ejemplo n.º 5
0
 public function __construct($input_output_type = Format::OUTPUT, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     // this list may be incomplete as it was documenation gleaned from
     // http://haali.su/mkv/codecs.pdf but I didn't really understand all of it.
     $this->_restricted_audio_codecs = array('ac3', 'mp1', 'mp2', 'mp3', 'dts', 'tta', 'libvorbis', 'vorbis', 'flac', 'ra_144', 'libfdk_aac', 'libfaac', 'aac', 'libvo_aacenc', 'pcm_alaw', 'pcm_f32le', 'pcm_f64le', 'pcm_lxf', 'pcm_mulaw', 'pcm_s16le', 'pcm_s16le_planar', 'pcm_s24daud', 'pcm_s24le', 'pcm_s24le_planar', 'pcm_s32le', 'pcm_s32le_planar', 'pcm_s8', 'pcm_s8_planar', 'pcm_u16le', 'pcm_u24le', 'pcm_u32le', 'pcm_u8');
     $this->_restricted_video_codecs = array('rv10', 'rv20', 'rv30', 'rv40', 'mpeg1video', 'mpeg2video', 'theora', 'snow', 'mpeg4');
     if ($input_output_type === 'output') {
         $this->setAudioCodec('libvorbis')->setVideoCodec('libtheora')->setFormat('matroska');
     }
 }
Ejemplo n.º 6
0
 public function __construct($input_output_type, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     $this->_restricted_audio_codecs = array('wmav2', 'wmav1');
     $this->_restricted_video_codecs = array('wmv2', 'wmv1');
     if ($input_output_type === 'output') {
         $this->setAudioCodec('wmav2')->setVideoCodec('wmv2')->setFormat('wmv');
     } else {
         array_push($this->_restricted_audio_codecs, 'wmalossless', 'wmapro', 'wmavoice');
         array_push($this->_restricted_video_codecs, 'wmv3', 'wmv3image');
     }
 }
Ejemplo n.º 7
0
 public function __construct($input_output_type = Format::OUTPUT, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     $this->_restricted_audio_codecs = array('libfdk_aac', 'libfaac', 'aac', 'libvo_aacenc', 'amr', 'libmp3lame', 'libshine', 'mp3');
     $this->_restricted_audio_bitrates = array('4.75k', '5.15k', '5.9k', '6.7k', '7.4k', '7.95k', '8k', '10.2k', '12k', '16k', '48k', '56k', '64k', '96k', '112k', '128k', '160k', '192k', '224k', '256k', '320k');
     $this->_restricted_audio_sample_frequencies = array(8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000);
     $this->_restricted_video_codecs = array('h263', 'h264', 'libx264');
     $this->_restricted_video_bitrates = array('32k', '40k', '60k', '64k', '80k', '96k', '104k', '128k', '160k', '240k', '256k');
     $this->_restricted_video_frame_rates = array(10, 12, 15, 20, 24, 25);
     if ($input_output_type === 'output') {
         $this->setAudioCodec('libfdk_aac')->setAudioSampleFrequency(44100)->setVideoCodec('libx264')->setFormat('3gp');
     }
 }
Ejemplo n.º 8
0
 public function __construct($input_output_type, Config $config = null)
 {
     parent::__construct($input_output_type, $config);
     $this->_format = array_merge($this->_format, array('h264_preset' => null, 'h264_tune' => null, 'h264_constant_quantization' => null));
     $this->_format_to_command = array_merge($this->_format_to_command, array('h264_preset' => '-preset <setting>', 'h264_tune' => '-tune <setting>', 'h264_constant_quantization' => '-qp <setting>'));
     $this->_restricted_video_presets = null;
     if ($input_output_type === 'output') {
         $this->setAudioCodec('mp3')->setVideoCodec('h264')->setFormat('h264');
     }
     //			both enable meta data injection and then force
     $this->forceQtFastStartSuccess();
     $this->enableQtFastStart();
 }
Ejemplo n.º 9
0
        $this->mp4 = '.mp4';
        $this->ogv = '.ogv';
        $this->webm = '.webm';
        $this->path = 'img/randVID/vid-';
    }
    public function createMP4()
    {
        return $this->path . $this->num . $this->mp4;
    }
    public function createOGV()
    {
        return $this->path . $this->num . $this->ogv;
    }
    public function createWEBM()
    {
        return $this->path . $this->num . $this->webm;
    }
}
//SCAN IMG DIR AND RANDOMIZE NUMBER
$imgDir = glob('img/randBG/*.jpg');
//ONLY RETURNS FILES ENDING IN .JPG
$num = mt_rand(0, count($imgDir) - 1);
//MT_RAND IS INCLUSIVE; -1 SO WE DON'T GENERATE A PATH THAT DOESN'T EXIST
//INSTANTIATE BG OBJECT
$img = new ImageFormat($num);
$bgImg = $img->createImg();
//INSTANTIATE VID OBJECT
$vid = new VideoFormat($num);
$bgMP4 = $vid->createMP4();
$bgOGV = $vid->createOGV();
$bgWEBM = $vid->createWEBM();
<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $audio = new Audio($example_audio_path);
    $process = $audio->getProcess();
    $process->addPreInputCommand('-framerate', '1/5');
    $process->addPreInputCommand('-pattern_type', 'glob');
    $process->addPreInputCommand('-i', $example_images_dir . '*.jpg');
    $process->addCommand('-pix_fmt', 'yuv420p');
    $process->addCommand('-shortest', '');
    $output_format = new VideoFormat();
    $output_format->setVideoFrameRate('1/5')->setVideoDimensions(320, 240)->setAudioCodec('libfdk_aac')->setVideoCodec('mpeg4');
    //  $process->setProcessTimelimit(1);
    $process = $audio->save('./output/my_homemade_video.mp4', $output_format, Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    echo '<hr /><h1>FFmpeg Process Messages</h1>';
    Trace::vars($process->getMessages());
    echo '<hr /><h1>Buffer Output</h1>';
    Trace::vars($process->getBuffer(true));
    echo '<hr /><h1>Resulting Output</h1>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $audio->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';