/**
  * Completes track information from a given path using ffmpeg.
  * @param Track $track
  */
 public function autocompleteTrack(Track $track)
 {
     if (!$track->getPath()) {
         throw new \BadMethodCallException('Input track has no path defined');
     }
     $file = $track->getPath();
     $movie = new \ffmpeg_movie($file, false);
     $finfo = new \finfo();
     if (!$this->fileHasMediaContent($finfo, $file)) {
         throw new \InvalidArgumentException("This file has no video nor audio tracks");
     }
     $only_audio = true;
     // General
     $track->setMimetype($finfo->file($file, FILEINFO_MIME_TYPE));
     $track->setBitrate($movie->getBitRate());
     $track->setDuration(ceil($movie->getDuration()));
     $track->setSize(filesize($file));
     if ($movie->hasVideo()) {
         $only_audio = false;
         $track->setVcodec($movie->getVideoCodec());
         $track->setFramerate($movie->getFrameRate());
         $track->setWidth($movie->getFrameWidth());
         $track->setHeight($movie->getFrameHeight());
     }
     if ($movie->hasAudio()) {
         $track->setAcodec($movie->getAudioCodec());
         $track->setChannels($movie->getAudioChannels());
     }
     $track->setOnlyAudio($only_audio);
 }
Пример #2
0
 public function getVideoSize($fileName)
 {
     $ffmpegInstance = new ffmpeg_movie($fileName);
     $video_size['width'] = $ffmpegInstance->getFrameWidth();
     $video_size['height'] = $ffmpegInstance->getFrameHeight();
     $video_size['duration'] = $ffmpegInstance->getDuration();
     $video_size['frame_rate'] = $ffmpegInstance->getFrameRate();
     $video_size['frame_count'] = $ffmpegInstance->getFrameCount();
     return $video_size;
 }
Пример #3
0
 function getVideoMetadata(&$form_values)
 {
     module_load_include('php', 'Fedora_Repository', 'mimetype');
     global $base_url;
     $fileUrl = $form_values["ingest-file-location"];
     $file_size = filesize($fileUrl);
     $file_md5 = md5_file($fileUrl);
     $file_path = $base_url . '/fedora/repository/' . $form_values['pid'] . '/FULL_SIZE';
     $ffmpegInstance = new ffmpeg_movie($fileUrl);
     $form_values['vid_framerate'] = $ffmpegInstance->getFrameRate();
     $form_values['vid_frameheight'] = $ffmpegInstance->getFrameHeight();
     $form_values['vid_framewidth'] = $ffmpegInstance->getFrameWidth();
     $form_values['vid_bitrate'] = $ffmpegInstance->getBitRate();
     $form_values['vid_mime'] = mime_content_type($fileUrl);
     $form_values['vid_size'] = $file_size;
     $form_values['vid_md5'] = $file_md5;
     $form_values['vid_file'] = $file_path;
 }
Пример #4
0
 function get_info($file)
 {
     if (!class_exists('ffmpeg_movie') or !($movie = new ffmpeg_movie($file))) {
         //ffmpeg extension required
         return false;
     }
     $duration = $movie->getDuration();
     $width = $movie->getFrameWidth();
     $height = $movie->getFrameHeight();
     $framerate = $movie->getFrameRate();
     $data = '';
     if ($duration) {
         $data .= "Duration: {$duration}\n";
     }
     if ($width and $height) {
         $data .= "Dimensions: {$width} x {$height} px\n";
     }
     if ($framerate) {
         $data .= "Framerate: {$framerate} fps\n";
     }
     return $data;
 }
 function genLocalStreamImage($stream_id, $req_time, $req_size)
 {
     global $mvLocalVideoPath, $mvStreamImageTable;
     //zsh edit
     return false;
     if (!$stream_id) {
         return false;
     }
     if (!$req_time) {
         $req_time = 0;
     }
     if (!$req_size) {
         $req_size = '320x240';
     }
     list($im_width, $im_height, $ext) = MV_StreamImage::getSizeType($req_size);
     if ($req_size == null) {
         $s = '';
     } else {
         $s = '_' . $im_width . 'x' . $im_height;
     }
     $img_dir = MV_StreamImage::getLocalImageDir($stream_id);
     $img_file = $img_dir . "/" . $req_time . $s . "." . $ext;
     $streampath = $mvLocalVideoPath . MV_StreamImage::getLocalStreamPath($stream_id);
     if (is_file($streampath)) {
         //check if the ffmpeg extension is installed:
         $extension = "ffmpeg";
         $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
         $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
         // load extension
         if (!extension_loaded($extension)) {
             if (!dl($extension_soname)) {
                 return false;
             }
         }
         $mov = new ffmpeg_movie($streampath);
         $fps = $mov->getFrameRate();
         if ($req_time == 0) {
             $ff_frame = $mov->getFrame(1);
         } else {
             $ff_frame = $mov->getFrame($req_time * $fps);
         }
         if ($ff_frame) {
             $ff_frame->resize($im_width, $im_height);
             $gd_image = $ff_frame->toGDImage();
             if ($gd_image) {
                 if ($ext == 'png') {
                     imagepng($gd_image, $img_file);
                     imagedestroy($gd_image);
                 } else {
                     imagejpeg($gd_image, $img_file);
                     imagedestroy($gd_image);
                 }
             }
         }
         if (is_file($img_file) && ($req_size == '320x240' || $req_size == '')) {
             $insAry = array();
             $insAry[stream_id] = $stream_id;
             $insAry[time] = $req_time;
             $db =& wfGetDB(DB_WRITE);
             if ($db->insert($mvStreamImageTable, $insAry)) {
                 return $img_file;
             } else {
                 //probably error out before we get here
                 return false;
             }
         }
     }
     return $img_file;
 }
Пример #6
0
}
printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
printf("ffmpeg-php build date string: %s\n", FFMPEG_PHP_BUILD_DATE_STRING);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
print_class_methods("ffmpeg_movie");
print_class_methods("ffmpeg_frame");
// get an array for movies from the test media directory
$movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
echo "--------------------\n\n";
foreach ($movies as $movie) {
    $mov = new ffmpeg_movie($movie);
    printf("file name = %s\n", $mov->getFileName());
    printf("duration = %s seconds\n", $mov->getDuration());
    printf("frame count = %s\n", $mov->getFrameCount());
    printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
    printf("comment = %s\n", $mov->getComment());
    printf("title = %s\n", $mov->getTitle());
    printf("author = %s\n", $mov->getAuthor());
    printf("copyright = %s\n", $mov->getCopyright());
    printf("get bit rate = %d\n", $mov->getBitRate());
    printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
    if ($mov->hasAudio()) {
        printf("get audio stream id= %s\n", $mov->getAudioStreamId());
        printf("get audio codec = %s\n", $mov->getAudioCodec());
        printf("get audio bit rate = %d\n", $mov->getAudioBitRate());
        printf("get audio sample rate = %d \n", $mov->getAudioSampleRate());
        printf("get audio channels = %s\n", $mov->getAudioChannels());
    }
    printf("has video = %s\n", $mov->hasVideo() == 0 ? 'No' : 'Yes');
    if ($mov->hasVideo()) {
Пример #7
0
echo '<img src="processed/thumbnails/' . $file_info['filename'] . '-cropped.jpg" alt="" width="' . $frame->getWidth() . '" height="' . $frame->getHeight() . '" border="0" /><br /><br />';
// 	resize the thumbnail
$frame->resize(50, 50);
$gd_resource = $frame->toGDImage();
imagejpeg($gd_resource, PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'processed/thumbnails/' . $file_info['filename'] . '-resized.jpg', 80);
$small_width = $frame->getWidth();
$small_height = $frame->getHeight();
echo '<strong>Cropped and Resized Frame Grab of Movie</strong>.<br />';
echo 'This is a frame grab that has been cropped then resized.<br />';
echo '<img src="processed/thumbnails/' . $file_info['filename'] . '-resized.jpg" alt="" width="' . $small_width . '" height="' . $small_height . '" border="0" /><br /><br />';
// 	create 2 animated gifs, one normal size, one small
// 	create the normal one
$ffmpeg_gif = new ffmpeg_animated_gif(PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'processed/thumbnails/' . $file_info['filename'] . '-animated.gif', $orig_width, $orig_height, 5, 0);
// 	create the small one
$ffmpeg_gif_small = new ffmpeg_animated_gif(PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'processed/thumbnails/' . $file_info['filename'] . '-animated-small.gif', $small_width, $small_height, 5, 0);
for ($i = 1, $a = $ffmpeg_movie->getFrameCount(), $inc = $ffmpeg_movie->getFrameRate() / 2; $i < $a; $i += $inc) {
    // 		get the required frame
    $ffmpeg_frame = $ffmpeg_movie->getFrame($i);
    if ($ffmpeg_frame !== false) {
        // 			add the frame to the gif
        $result = $ffmpeg_gif->addFrame($ffmpeg_frame);
        if (!$result) {
            'There was an error adding frame ' . $i . ' to the gif.<br />';
        }
    }
    // 		get the required frame
    $ffmpeg_frame_small = $ffmpeg_movie->getFrame($i);
    if ($ffmpeg_frame_small !== false) {
        // 			crop and resize the frame
        $ffmpeg_frame_small->resize(50, 50, 20, 20, 20, 20);
        // 			then add it to the small one
Пример #8
0
 // load extension
 if (!extension_loaded($extension)) {
     dl($extension_soname);
 }
 // Set our source file
 $srcFile = $gdir . $filename;
 $destFile = $gdir . "tmp_" . substr($filename, 0, strrpos($filename, ".")) . ".flv";
 $newFile = substr($filename, 0, strrpos($filename, ".")) . ".flv";
 $thumbFile = $gdir . "tn_" . substr($filename, 0, strrpos($filename, ".")) . ".flv.jpg";
 $ffmpegPath = "ffmpeg";
 // Create our FFMPEG-PHP class
 $ffmpegObj = new ffmpeg_movie($srcFile);
 // Save our needed variables
 $srcWidth = $ffmpegObj->getFrameWidth();
 $srcHeight = $ffmpegObj->getFrameHeight();
 $srcFPS = $ffmpegObj->getFrameRate();
 $srcAB = intval($ffmpegObj->getAudioBitRate() / 1000);
 $srcAR = $ffmpegObj->getAudioSampleRate();
 // thumbnail
 $ff_frame = $ffmpegObj->getFrame(30);
 if ($ff_frame) {
     $ff_frame->resize($_SESSION['site_thumbwidth'], $_SESSION['site_thumbheight']);
     $gd_image = $ff_frame->toGDImage();
     if ($gd_image) {
         //ha nincs konvertalas, akkor mas lez a file neve
         if (empty($_SESSION['site_gallery_is_convert'])) {
             $thumbFile = $gdir . $tn_name . ".jpg";
         }
         imagejpeg($gd_image, $thumbFile);
         imagedestroy($gd_image);
     }
Пример #9
0
function analyzeMediaFile(&$metaData, $filePath = NULL, $cachePath = NULL)
{
    if (!isset($metaData->fileName) || !isset($metaData->fileType)) {
        throw new Exception("meta data invalid");
    }
    $file = $filePath . DIRECTORY_SEPARATOR . $metaData->fileName;
    if (!is_file($file) || !is_readable($file)) {
        throw new Exception("file does not exist");
    }
    if (!is_dir($cachePath)) {
        throw new Exception("cache dir does not exist");
    }
    switch ($metaData->fileType) {
        case "video/quicktime":
        case "application/ogg":
        case "audio/mpeg":
        case "video/mp4":
        case "video/x-msvideo":
        case "video/ogg":
        case "video/webm":
        case "video/x-ms-asf":
        case "video/x-flv":
        case "audio/x-wav":
        case "application/octet-stream":
            if (isMediaFile($metaData, $filePath)) {
                $media = new ffmpeg_movie($file, FALSE);
                /****************************************************
                 * VIDEO
                 ****************************************************/
                if ($media->hasVideo()) {
                    $metaData->video->codec = $media->getVideoCodec();
                    $metaData->video->width = $media->getFrameWidth();
                    $metaData->video->height = $media->getFrameHeight();
                    $metaData->video->bitrate = $media->getVideoBitRate();
                    $metaData->video->framerate = $media->getFrameRate();
                    $metaData->video->duration = $media->getDuration();
                    /* Video Still */
                    $stillFile = $cachePath . DIRECTORY_SEPARATOR . uniqid("ft_") . ".png";
                    $fc = (int) ($media->getFrameCount() / 32);
                    /* frame count is not necessarily reliable! */
                    foreach (array($fc, 100, 10, 1) as $fno) {
                        if ($fno == 0) {
                            continue;
                        }
                        $f = $media->getFrame($fno);
                        if ($f !== FALSE) {
                            imagepng($f->toGDImage(), $stillFile);
                            $metaData->video->still = basename($stillFile);
                            break;
                        }
                    }
                    /* Video Thumbnails */
                    $thumbSizes = array(90, 180, 360);
                    foreach ($thumbSizes as $tS) {
                        $thumbFile = $cachePath . DIRECTORY_SEPARATOR . uniqid("ft_") . ".png";
                        list($thumb_width, $thumb_height) = generateThumbnail($stillFile, $thumbFile, $tS);
                        $metaData->video->thumbnail->{$tS}->file = basename($thumbFile);
                        $metaData->video->thumbnail->{$tS}->width = $thumb_width;
                        $metaData->video->thumbnail->{$tS}->height = $thumb_height;
                    }
                    /* Schedule for transcoding */
                    $transcodeSizes = array(360);
                    $metaData->transcodeStatus = 'WAITING';
                    $metaData->transcodeProgress = 0;
                    foreach ($transcodeSizes as $tS) {
                        $transcodeFile = $cachePath . DIRECTORY_SEPARATOR . uniqid("ft_") . ".webm";
                        list($width, $height) = scaleVideo($media->getFrameWidth(), $media->getFrameHeight(), $tS);
                        $metaData->video->transcode->{$tS}->file = basename($transcodeFile);
                        $metaData->video->transcode->{$tS}->width = $width;
                        $metaData->video->transcode->{$tS}->height = $height;
                    }
                }
                /****************************************************
                 * AUDIO
                 ****************************************************/
                if ($media->hasAudio()) {
                    $metaData->audio->codec = $media->getAudioCodec();
                    $metaData->audio->bitrate = $media->getAudioBitRate();
                    $metaData->audio->samplerate = $media->getAudioSampleRate();
                    $metaData->audio->duration = $media->getDuration();
                    $metaData->transcodeStatus = 'WAITING';
                    $metaData->transcodeProgress = 0;
                    $transcodeFile = $cachePath . DIRECTORY_SEPARATOR . uniqid("ft_") . ".ogg";
                    $metaData->audio->transcode->file = basename($transcodeFile);
                }
            } else {
                /* No media? */
            }
            break;
        case "image/jpeg":
        case "image/png":
        case "image/gif":
        case "image/bmp":
            list($width, $height) = getimagesize($file);
            $metaData->image->width = $width;
            $metaData->image->height = $height;
            $thumbFile = $cachePath . DIRECTORY_SEPARATOR . uniqid("ft_") . ".png";
            list($thumb_width, $thumb_height) = generateThumbnail($file, $thumbFile, 360);
            $metaData->image->thumbnail->{360}->file = basename($thumbFile);
            $metaData->image->thumbnail->{360}->width = $thumb_width;
            $metaData->image->thumbnail->{360}->height = $thumb_height;
            break;
        default:
            /* no idea about this file, let it go... */
    }
}
Пример #10
0
 function path($param1 = array(), $param2 = array(), $param3 = array())
 {
     if (is_array($param1)) {
         $path = $param1['path'];
         $filename = $param1['filename'];
         $options =& $param2;
     } else {
         $path = $param1;
         $filename = $param2;
         $options = $param3;
     }
     if ($path == '' || $filename == '') {
         return false;
     }
     // Set default values
     if (!isset($options['full'])) {
         $options['full'] = false;
     }
     if (!isset($options['dims'])) {
         $options['dims'] = 'original';
     }
     if (isset($options['size'])) {
         $options['dims'] = $options['size'];
     }
     if ($options['dims'] != 'original' && !isset($options['method'])) {
         $options['method'] = 'crop';
     }
     if (!isset($options['saveas'])) {
         $options['saveas'] = null;
     }
     if (!isset($options['time'])) {
         $options['time'] = null;
     }
     if (!isset($options['watermark'])) {
         $options['watermark'] = null;
     }
     // Path must not begin with slash but must end with slash
     if ($path[0] == '/') {
         $path = substr($path, 1);
     }
     if (substr($path, -1) != '/') {
         $path .= '/';
     }
     // Absolute path to directory
     $absolutePath = WWW_ROOT . $path;
     // Absolute path to file
     $absoluteFilePath = $absolutePath . $filename;
     if (file_exists($absoluteFilePath)) {
         $fileSize = filesize($absoluteFilePath);
         $fileExt = strtolower(strrchr($filename, '.'));
         if ($fileExt == '.jpeg') {
             $fileExt = '.jpg';
         }
         if (!in_array($fileExt, array('.jpg', '.jpeg', '.png', '.gif', '.f4v', '.flv'))) {
             return false;
         }
         $fileNameNoExt = substr($filename, 0, -strlen($fileExt));
         if ($options['saveas'] == null) {
             if ($fileExt == '.flv' || $fileExt == '.f4v') {
                 $options['saveas'] = '.jpg';
             }
             $options['saveas'] = $fileExt;
         } else {
             $options['saveas'] = strtolower($options['saveas']);
             if ($options['saveas'] == '.jpeg') {
                 $options['saveas'] == '.jpg';
             }
             if ($options['saveas'][0] != '.') {
                 $options['saveas'] = '.' . $options['saveas'];
             }
         }
         if ($options['dims'] == 'original' && $options['saveas'] == $fileExt && $fileExt != '.flv' && $fileExt != '.f4v' && $options['watermark'] == null) {
             // original file returned
             return $this->url('/' . $path . $filename, $options['full']);
         } else {
             $cachedFile = $this->_cachePath($path, $fileNameNoExt, $fileExt, $fileSize, $options);
             if ($cachedFile['exists']) {
                 return $this->url($cachedFile['path'] . $cachedFile['filename'], $options['full']);
             } else {
                 // create file
                 if ($fileExt == '.flv' || $fileExt == '.f4v') {
                     // if video, check if a screenshot already exists
                     $optionsOriginal = $options;
                     $optionsOriginal['dims'] = 'original';
                     $optionsOriginal['watermark'] = null;
                     $videoScreenshot = $this->_cachePath($path, $fileNameNoExt, $fileExt, $fileSize, $optionsOriginal);
                     if ($videoScreenshot['exists']) {
                         // Screenshot already exists, use it
                         $img = $this->_loadImage($videoScreenshot['path'], $videoScreenshot['filename']);
                     } else {
                         // No screenshot available, take one
                         if (class_exists('ffmpeg_movie')) {
                             $ffmpegInstance = new ffmpeg_movie($absoluteFilePath);
                             if ($options['time'] != null) {
                                 // take screenshot at specified time
                                 $framerate = $ffmpegInstance->getFrameRate();
                                 $framecount = $ffmpegInstance->getFrameCount();
                                 $frame_number = $framerate * $options['time'];
                                 if ($frame_number > $framecount - 1) {
                                     // invalid time
                                     $frame = $ffmpegInstance->getFrame((int) ($ffmpegInstance->getFrameCount() / 2));
                                 } else {
                                     $frame = $ffmpegInstance->getFrame($frame_number);
                                 }
                             } else {
                                 // take screenshot at middle of video
                                 $frame = $ffmpegInstance->getFrame((int) ($ffmpegInstance->getFrameCount() / 2));
                             }
                             $img = $frame->toGDImage();
                             // Save screenshot for future use
                             $this->_saveImage($img, $videoScreenshot['path'], $videoScreenshot['filename'], $options['saveas']);
                         } else {
                             return false;
                         }
                     }
                 } else {
                     // this is not a video
                     // load image
                     $img = $this->_loadImage($path, $filename, $fileExt);
                 }
                 // Add watermark if needed
                 if ($options['watermark'] != null) {
                     if ($options['watermark'][0] == '/') {
                         $options['watermark'] = substr($options['watermark'], 1);
                     }
                     $absoluteWatermarkFile = WWW_ROOT . $options['watermark'];
                     if (file_exists($absoluteWatermarkFile)) {
                         $watermarkFileName = basename($options['watermark']);
                         $watermark = $this->_loadImage(dirname($options['watermark']) . '/', $watermarkFileName, strtolower(strrchr($watermarkFileName, '.')));
                         //var_dump($watermark);
                         //die();
                         $watermark_width = imagesx($watermark);
                         $watermark_height = imagesy($watermark);
                         $img_height = imagesy($img);
                         $img_width = imagesx($img);
                         for ($i = 0; $i < $img_width; $i = $i + 1.5 * $watermark_width) {
                             for ($j = 0; $j < $img_height; $j = $j + 1.5 * $watermark_height) {
                                 imagecopy($img, $watermark, $i, $j, 0, 0, $watermark_width, $watermark_height);
                             }
                         }
                     }
                 }
                 // crop/resize if needed
                 if ($options['dims'] != 'original') {
                     if ($options['method'] == 'crop') {
                         $img = $this->_crop($img, $options['dims'], $fileExt == '.png' && $options['saveas'] == '.png');
                     } elseif ($options['method'] == 'resize') {
                         $img = $this->_resize($img, $options['dims'], $fileExt == '.png' && $options['saveas'] == '.png');
                     }
                 }
                 // Save image
                 if ($this->_saveImage($img, $cachedFile['path'], $cachedFile['filename'], $options['saveas'])) {
                     imagedestroy($img);
                     return $this->url($cachedFile['path'] . $cachedFile['filename'], $options['full']);
                 }
                 return false;
             }
         }
     }
     return false;
 }
Пример #11
0
echo "<p/>";
print_class_methods("ffmpeg_movie");
echo "<p/>";
print_class_methods("ffmpeg_frame");
// get an array for movies from the test media directory
$movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
$i = 1;
foreach ($movies as $movie) {
    $mov = new ffmpeg_movie($movie);
    echo '<table width="90%" class="hor-minimalist-a">';
    printf('<caption>Processing Test File: %s...</caption>', basename($mov->getFilename()));
    printf('<thead><tr><th width="150">Method</th><th>Result<br/></th></tr></thead>', $mov->getFileName());
    printf("<tr><td>file name:</td><td>%s<br/></td></tr>", $mov->getFileName());
    printf("<tr><td>duration</td><td>%s seconds<br/></td></tr>", $mov->getDuration());
    printf("<tr><td>frame count</td><td>%s<br/></td></tr>", $mov->getFrameCount());
    printf("<tr><td>frame rate</td><td>%0.3f fps<br/></td></tr>", $mov->getFrameRate());
    printf("<tr><td>comment</td><td>%s<br/></td></tr>", $mov->getComment());
    printf("<tr><td>title</td><td>%s<br/></td></tr>", $mov->getTitle());
    printf("<tr><td>author</td><td>%s<br/></td></tr>", $mov->getAuthor());
    printf("<tr><td>copyright</td><td>%s<br/></td></tr>", $mov->getCopyright());
    printf("<tr><td>get bit rate</td><td>%d<br/></td></tr>", $mov->getBitRate());
    printf("<tr><td>has audio</td><td>%s<br/></td></tr>", $mov->hasAudio() == 0 ? 'No' : 'Yes');
    if ($mov->hasAudio()) {
        printf("<tr><td>get audio stream id</td><td>%s<br/></td></tr>", $mov->getAudioStreamId());
        printf("<tr><td>get audio codec</td><td>%s<br/></td></tr>", $mov->getAudioCodec());
        printf("<tr><td>get audio bit rate</td><td>%d<br/></td></tr>", $mov->getAudioBitRate());
        printf("<tr><td>get audio sample rate</td><td>%d<br/></td></tr>", $mov->getAudioSampleRate());
        printf("<tr><td>get audio channels</td><td>%s<br/></td></tr>", $mov->getAudioChannels());
    }
    printf("<tr><td>has video</td><td>%s<br/></td></tr>", $mov->hasVideo() == 0 ? 'No' : 'Yes');
    if ($mov->hasVideo()) {
Пример #12
0
<?php

$time = $_GET["time"];
//store the time passed in the URL form start.php
//get the frame object from the movie at time = $time
$movie = new ffmpeg_movie("bunny.webm", false);
$fps = $movie->getFrameRate();
$frameNumber = floor($time * $fps);
$frame = $movie->getFrame($frameNumber);
//convert the frame to an image
$image = $frame->toGDImage();
//save the images sequentially (starting at filename = 1.jpeg) in a directory
$array = glob("*.jpeg");
$maxint = 1;
//find the "maximum" jpeg filename in a directory
//for example, if a directory has file 1.jpeg, 2.jpeg, 3.jpeg, then $maxint will be 3
foreach ($array as $filename) {
    $name = ltrim($filename, "pic");
    $name = rtrim($name, ".jpeg");
    $name = intval($name);
    if ($name > $maxint) {
        $maxint = $name;
    }
}
//increase $maxint by 1 to get the current filename
$name = $maxint + 1;
echo $name;
//save the image as a file in the current directory
imagejpeg($image, "pic" . $name . ".jpeg");
$path = "pic" . $name . ".jpeg";
echo "<img src='{$path}'/>";
Пример #13
0
    $VOB = "/VIDEO_TS/VTS_01_[12345].VOB";
    shell_exec("cat {$tmp}{$pelnomf}{$VOB} > {$tmp}{$pelnomf}.VOB");
    shell_exec("ffmpeg -threads {$th} -i {$tmp}{$pelnomf}.VOB -vcodec libx264 -vb {$bit} -maxrate {$bit} -bufsize 1000k -s hd720 -acodec libfaac -ab {$bita} -ac 2 {$diref}{$pelnomf}.mp4");
    shell_exec("rm -Rf {$tmp}{$pelnomf}");
    shell_exec("rm -Rf {$tmp}{$pelnomf}.VOB");
} else {
    //Formatos tradicionales de video
    $pelif = "../files/{$files5}";
    $varpel = new ffmpeg_movie($pelif);
    //obtener ancho y alto original del video
    $ancho = $varpel->getFrameWidth();
    $alto = $varpel->getFrameHeight();
    //Hz del audio
    $hz = $varpel->getAudioSampleRate();
    //Framer por segundo
    $fps = $varpel->getFrameRate();
    //Canales
    $canales = $varpel->getAudioChannels();
    // Formula para convertir alto equivalente para ancho 720
    $calcula = $HD * $alto / $ancho;
    if ($calcula % 2 == 0) {
        $altof = "{$calcula}";
    } else {
        $altof = ++$calcula;
    }
    // Fin de Formula
    //Resolucion
    $x = "x";
    if ($ancho >= $HD) {
        $resolucion = "{$HD}{$x}{$altof}";
    } else {