Exemple #1
0
 function getMetadata()
 {
     $this->metadata = parent::getMetadata();
     $getid3 = new getid3();
     $getid3->encoding = 'UTF-8';
     try {
         $getid3->Analyze($this->filepath);
         $id3 = $getid3->info;
     } catch (Exception $e) {
         echo 'An error occured: ' . $e->message;
     }
     if (is_array($id3)) {
         if (isset($id3['video'])) {
             $v = $id3['video'];
             if ($v['dataformat']) {
                 $this->metadata['dataformat'] = $v['dataformat'];
             }
             if ($v['frame_rate']) {
                 $this->metadata['frame_rate'] = $v['frame_rate'];
             }
             if ($v['resolution_x']) {
                 $this->metadata['width'] = $v['resolution_x'];
             }
             if ($v['resolution_y']) {
                 $this->metadata['height'] = $v['resolution_y'];
             }
         }
     }
     return $this->metadata;
 }
Exemple #2
0
 public function __construct($film)
 {
     require_once 'getid3/getid3.php';
     global $logger;
     $logger->log("analyse " . $film, Zend_Log::DEBUG);
     $id3 = new getid3();
     $id3->option_tag_id3v1 = false;
     $id3->option_tag_id3v2 = false;
     $id3->option_tag_lyrics3 = false;
     $id3->option_tag_apetag = false;
     $id3->option_tags_html = false;
     $id3->option_max_2gb_check = false;
     //Zend_Debug::Dump($id3);
     $this->_data = $id3->Analyze($film);
     // ==> v2
     //getid3_lib::CopyTagsToComments($this->_data);
 }
Exemple #3
0
 function getMetadata()
 {
     $this->metadata = parent::getMetadata();
     $getid3 = new getid3();
     $getid3->encoding = 'UTF-8';
     try {
         $getid3->Analyze($this->filepath);
         $id3 = $getid3->info;
     } catch (Exception $e) {
         echo 'An error occured: ' . $e->message;
     }
     if (is_array($id3)) {
         if (isset($id3['comments']) && isset($id3['playtime_seconds']) && isset($id3['bitrate']) && isset($id3['audio'])) {
             $this->metadata['duration'] = $id3['playtime_seconds'];
             $this->metadata['bitrate'] = $id3['bitrate'];
             $this->metadata['channels'] = $id3['audio']['channels'];
             $this->metadata['samplingrate'] = $id3['audio']['sample_rate'];
             $this->metadata['audio_title'] = $id3['comments']['title'][0];
             $this->metadata['audio_artist'] = $id3['comments']['artist'][0];
             if (isset($id3['comments']['comment'])) {
                 $this->metadata['audio_comment'] = $id3['comments']['comment'][0];
             }
             if (isset($id3['comments']['album'])) {
                 $this->metadata['audio_album'] = $id3['comments']['album'][0];
             }
             if (isset($id3['comments']['year'])) {
                 $this->metadata['audio_year'] = $id3['comments']['year'][0];
             }
             if (isset($id3['comments']['encoded_by'])) {
                 $this->metadata['audio_encoded_by'] = $id3['comments']['encoded_by'][0];
             }
             if (isset($id3['comments']['track'])) {
                 $this->metadata['audio_track'] = $id3['comments']['track'][0];
             }
             if (isset($id3['comments']['genre'])) {
                 $this->metadata['audio_genre'] = $id3['comments']['genre'][0];
             }
             if (isset($id3['comments']['totaltracks'])) {
                 $this->metadata['audio_totaltracks'] = $id3['comments']['totaltracks'][0];
             }
         }
     }
     return $this->metadata;
 }
 public function read()
 {
     $engine = new getid3();
     $engine->filename = $this->filename;
     $engine->fp = fopen($this->filename, 'rb');
     $engine->include_module('tag.id3v1');
     $tag = new getid3_id3v1($engine);
     $tag->Analyze();
     if (!isset($engine->info['id3v1'])) {
         return;
     }
     $this->title = $engine->info['id3v1']['title'];
     $this->artist = $engine->info['id3v1']['artist'];
     $this->album = $engine->info['id3v1']['album'];
     $this->year = $engine->info['id3v1']['year'];
     $this->genre_id = $engine->info['id3v1']['genre_id'];
     $this->genre = $engine->info['id3v1']['genre'];
     $this->comment = $engine->info['id3v1']['comment'];
     $this->track = $engine->info['id3v1']['track'];
     return true;
 }
Exemple #5
0
 public function Analyze($filename)
 {
     // Init and save values
     $this->filename = $filename;
     $this->warnings = array();
     // Init result array and set parameters
     $this->info = array();
     $this->info['GETID3_VERSION'] = getid3::VERSION;
     // Remote files not supported
     if (preg_match('/^(ht|f)tp:\\/\\//', $filename)) {
         throw new getid3_exception('Remote files are not supported - please copy the file locally first.');
     }
     // Open local file
     if (!($this->fp = @fopen($filename, 'rb'))) {
         throw new getid3_exception('Could not open file "' . $filename . '"');
     }
     // Set filesize related parameters
     $this->info['filesize'] = filesize($filename);
     $this->info['avdataoffset'] = 0;
     $this->info['avdataend'] = $this->info['filesize'];
     // Option_max_2gb_check
     if ($this->option_max_2gb_check) {
         // PHP doesn't support integers larger than 31-bit (~2GB)
         // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
         // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
         fseek($this->fp, 0, SEEK_END);
         if ($this->info['filesize'] != 0 && ftell($this->fp) == 0 || $this->info['filesize'] < 0 || ftell($this->fp) < 0) {
             unset($this->info['filesize']);
             fclose($this->fp);
             throw new getid3_exception('File is most likely larger than 2GB and is not supported by PHP.');
         }
     }
     // ID3v2 detection (NOT parsing) done to make fileformat easier.
     if (!$this->option_tag_id3v2) {
         fseek($this->fp, 0, SEEK_SET);
         $header = fread($this->fp, 10);
         if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
             $this->info['id3v2']['header'] = true;
             $this->info['id3v2']['majorversion'] = ord($header[3]);
             $this->info['id3v2']['minorversion'] = ord($header[4]);
             $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10;
             // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
         }
     }
     // Handle tags
     foreach (array("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) {
         $option_tag = 'option_tag_' . $tag_name;
         if ($this->{$option_tag}) {
             $this->include_module('tag.' . $tag_name);
             try {
                 $tag_class = 'getid3_' . $tag_name;
                 $tag = new $tag_class($this);
                 $tag->Analyze();
             } catch (getid3_exception $e) {
                 throw $e;
             }
         }
     }
     //// Determine file format by magic bytes in file header.
     // Read 32 kb file data
     fseek($this->fp, $this->info['avdataoffset'], SEEK_SET);
     $filedata = fread($this->fp, 32774);
     // Get huge FileFormatArray
     $file_format_array = getid3::GetFileFormatArray();
     // Identify file format - loop through $format_info and detect with reg expr
     foreach ($file_format_array as $name => $info) {
         if (preg_match('/' . $info['pattern'] . '/s', $filedata)) {
             // The /s switch on preg_match() forces preg_match() NOT to treat newline (0x0A) characters as special chars but do a binary match
             // Format detected but not supported
             if (!@$info['module'] || !@$info['group']) {
                 fclose($this->fp);
                 $this->info['fileformat'] = $name;
                 $this->info['mime_type'] = $info['mime_type'];
                 $this->warning('Format only detected. Parsing not available yet.');
                 $this->info['warning'] = $this->warnings;
                 return $this->info;
             }
             $determined_format = $info;
             // copy $info deleted by foreach()
             continue;
         }
     }
     // Unable to determine file format
     if (!@$determined_format) {
         // Too many mp3 encoders on the market put gabage in front of mpeg files
         // use assume format on these if format detection failed
         if (preg_match('/\\.mp[123a]$/i', $filename)) {
             $determined_format = $file_format_array['mp3'];
         } else {
             fclose($this->fp);
             throw new getid3_exception('Unable to determine file format');
         }
     }
     // Free memory
     unset($file_format_array);
     // Check for illegal ID3 tags
     if (@$determined_format['fail_id3'] && (@$this->info['id3v1'] || @$this->info['id3v2'])) {
         if ($determined_format['fail_id3'] === 'ERROR') {
             fclose($this->fp);
             throw new getid3_exception('ID3 tags not allowed on this file type.');
         } elseif ($determined_format['fail_id3'] === 'WARNING') {
             @$this->info['id3v1'] and $this->warning('ID3v1 tags not allowed on this file type.');
             @$this->info['id3v2'] and $this->warning('ID3v2 tags not allowed on this file type.');
         }
     }
     // Check for illegal APE tags
     if (@$determined_format['fail_ape'] && @$this->info['tags']['ape']) {
         if ($determined_format['fail_ape'] === 'ERROR') {
             fclose($this->fp);
             throw new getid3_exception('APE tags not allowed on this file type.');
         } elseif ($determined_format['fail_ape'] === 'WARNING') {
             $this->warning('APE tags not allowed on this file type.');
         }
     }
     // Set mime type
     $this->info['mime_type'] = $determined_format['mime_type'];
     // Calc module file name
     $determined_format['include'] = 'module.' . $determined_format['group'] . '.' . $determined_format['module'] . '.php';
     // Supported format signature pattern detected, but module deleted.
     if (!file_exists($this->include_path . $determined_format['include'])) {
         fclose($this->fp);
         throw new getid3_exception('Format not supported, module "' . $determined_format['include'] . '" was removed.');
     }
     // Include module
     $this->include_module($determined_format['group'] . '.' . $determined_format['module']);
     // Instantiate module class and analyze
     $class_name = 'getid3_' . $determined_format['module'];
     if (!class_exists($class_name)) {
         throw new getid3_exception('Format not supported, module "' . $determined_format['include'] . '" is corrupt.');
     }
     $class = new $class_name($this);
     try {
         $this->option_analyze and $class->Analyze();
     } catch (getid3_exception $e) {
         throw $e;
     } catch (Exception $e) {
         throw new getid3_exception('Corrupt file.');
     }
     // Close file
     fclose($this->fp);
     // Optional - Process all tags - copy to 'tags' and convert charsets
     if ($this->option_tags_process) {
         $this->HandleAllTags();
     }
     //// Optional - perform more calculations
     if ($this->option_extra_info) {
         $this->ChannelsBitratePlaytimeCalculations();
         $this->CalculateCompressionRatioVideo();
         $this->CalculateCompressionRatioAudio();
         $this->CalculateReplayGain();
         $this->ProcessAudioStreams();
     }
     // Get the md5/sha1sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags.
     if ($this->option_md5_data || $this->option_sha1_data) {
         // Load data-hash library if needed
         $this->include_module('lib.data_hash');
         if ($this->option_sha1_data) {
             new getid3_lib_data_hash($this, 'sha1');
         }
         if ($this->option_md5_data) {
             // no md5_data_source or option disabled -- md5_data_source supported by FLAC, MAC, OptimFROG, Wavpack4
             if (!$this->option_md5_data_source || !@$this->info['md5_data_source']) {
                 new getid3_lib_data_hash($this, 'md5');
             } elseif ($this->option_md5_data_source && @$this->info['md5_data_source']) {
                 $this->info['md5_data'] = $this->info['md5_data_source'];
             }
         }
     }
     // Set warnings
     if ($this->warnings) {
         $this->info['warning'] = $this->warnings;
     }
     // Return result
     return $this->info;
 }
Exemple #6
0
 /**
  * Confirm this is an NFO file.
  *
  * @param string $possibleNFO The nfo.
  * @param string $guid        The guid of the release.
  *
  * @return bool               True on success, False on failure.
  *
  * @access public
  */
 public function isNFO(&$possibleNFO, $guid)
 {
     if ($possibleNFO === false) {
         return false;
     }
     // Make sure it's not too big or small, size needs to be at least 12 bytes for header checking. Ignore common file types.
     $size = strlen($possibleNFO);
     if ($size < 65535 && $size > 11 && !preg_match('/\\A(\\s*<\\?xml|=newz\\[NZB\\]=|RIFF|\\s*[RP]AR|.{0,10}(JFIF|matroska|ftyp|ID3))|;\\s*Generated\\s*by.*SF\\w/i', $possibleNFO)) {
         // File/GetId3 work with files, so save to disk.
         $tmpPath = $this->tmpPath . $guid . '.nfo';
         file_put_contents($tmpPath, $possibleNFO);
         // Linux boxes have 'file' (so should Macs), Windows *can* have it too: see GNUWIN.txt in docs.
         $result = Utility::fileInfo($tmpPath);
         if (!empty($result)) {
             // Check if it's text.
             if (preg_match('/(ASCII|ISO-8859|UTF-(8|16|32).*?)\\s*text/', $result)) {
                 @unlink($tmpPath);
                 return true;
                 // Or binary.
             } else {
                 if (preg_match('/^(JPE?G|Parity|PNG|RAR|XML|(7-)?[Zz]ip)/', $result) || preg_match('/[\\x00-\\x08\\x12-\\x1F\\x0B\\x0E\\x0F]/', $possibleNFO)) {
                     @unlink($tmpPath);
                     return false;
                 }
             }
         }
         // If above checks couldn't  make a categorical identification, Use GetId3 to check if it's an image/video/rar/zip etc..
         $getid3 = new getid3();
         $check = $getid3->analyze($tmpPath);
         @unlink($tmpPath);
         if (isset($check['error'])) {
             // Check if it's a par2.
             $par2info = new Par2Info();
             $par2info->setData($possibleNFO);
             if ($par2info->error) {
                 // Check if it's an SFV.
                 $sfv = new SfvInfo();
                 $sfv->setData($possibleNFO);
                 if ($sfv->error) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
 public function remove()
 {
     $engine = new getid3();
     $engine->filename = $this->filename;
     $engine->fp = fopen($this->filename, 'rb');
     $engine->include_module('tag.apetag');
     $tag = new getid3_apetag($engine);
     $tag->Analyze();
     if (isset($engine->info['ape']['tag_offset_start']) && isset($engine->info['ape']['tag_offset_end'])) {
         if (!($fp = @fopen($this->filename, 'a+b'))) {
             throw new getid3_exception('Could not open a+b: ' . $this->filename);
         }
         // get data after apetag
         if (filesize($this->filename) > $engine->info['ape']['tag_offset_end']) {
             fseek($fp, $engine->info['ape']['tag_offset_end'], SEEK_SET);
             $data_after_ape = fread($fp, filesize($this->filename) - $engine->info['ape']['tag_offset_end']);
         }
         // truncate file before start of apetag
         ftruncate($fp, $engine->info['ape']['tag_offset_start']);
         // rewrite data after apetag
         if (isset($data_after_ape)) {
             fseek($fp, $engine->info['ape']['tag_offset_start'], SEEK_SET);
             fwrite($fp, $data_after_ape, strlen($data_after_ape));
         }
         fclose($fp);
         clearstatcache();
     }
     // success when removing non-existant tag
     return true;
 }
 public function Analyze($filename)
 {
     if (file_exists($filename)) {
         // Calc key     filename::mod_time::size    - should be unique
         $key = $filename . '::' . filemtime($filename) . '::' . filesize($filename);
         // Loopup key
         $result = dba_fetch($key, $this->dba);
         // Hit
         if ($result !== false) {
             return unserialize($result);
         }
     }
     // Miss
     $result = parent::Analyze($filename);
     // Save result
     if (file_exists($filename)) {
         dba_insert($key, serialize($result), $this->dba);
     }
     return $result;
 }
Exemple #9
0
 public function write($filepath, $mimetype)
 {
     if (!$this->handle) {
         return false;
     }
     if (!($ext = $this->info["EXPORT"][$mimetype])) {
         # this plugin can't write this mimetype
         $this->postError(1610, _t("Can't convert '%1' to '%2': unsupported format", $this->handle["mime_type"], $mimetype), "WLPlugAudio->write()");
         return false;
     }
     $o_config = Configuration::load();
     $va_tags = $this->get("getID3_tags");
     $vs_intro_filepath = $this->get("intro_filepath");
     $vs_outro_filepath = $this->get("outro_filepath");
     if (($vn_output_bitrate = $this->get("bitrate")) < 32) {
         $vn_output_bitrate = 64;
     }
     if (($vn_sample_frequency = $this->get("sample_frequency")) < 4096) {
         $vn_sample_frequency = 44100;
     }
     if (($vn_channels = $this->get("channels")) < 1) {
         $vn_channels = 1;
     }
     if ($this->properties["mimetype"] == $mimetype && !($this->properties["mimetype"] == "audio/mpeg" && ($vs_intro_filepath || $vs_outro_filepath)) && ($vn_output_bitrate == $this->input_bitrate && $vn_sample_frequency == $this->input_sample_frequency && $vn_channels == $this->input_channels)) {
         # write the file
         if (!copy($this->filepath, $filepath . "." . $ext)) {
             $this->postError(1610, _t("Couldn't write file to '%1'", $filepath), "WLPlugAudio->write()");
             return false;
         }
     } else {
         if ($mimetype != "image/png" && $mimetype != "image/jpeg" && $this->opb_ffmpeg_available) {
             #
             # Do conversion
             #
             if ($mimetype == 'audio/ogg') {
                 exec($this->ops_path_to_ffmpeg . " -f " . $this->info["IMPORT"][$this->properties["mimetype"]] . " -i " . caEscapeShellArg($this->filepath) . " -acodec libvorbis -ab " . $vn_output_bitrate . " -ar " . $vn_sample_frequency . " -ac " . $vn_channels . "  -y " . caEscapeShellArg($filepath . "." . $ext) . " 2>&1", $va_output, $vn_return);
             } else {
                 exec($this->ops_path_to_ffmpeg . " -f " . $this->info["IMPORT"][$this->properties["mimetype"]] . " -i " . caEscapeShellArg($this->filepath) . " -f " . $this->info["EXPORT"][$mimetype] . " -ab " . $vn_output_bitrate . " -ar " . $vn_sample_frequency . " -ac " . $vn_channels . "  -y " . caEscapeShellArg($filepath . "." . $ext) . " 2>&1", $va_output, $vn_return);
             }
             if ($vn_return != 0) {
                 @unlink($filepath . "." . $ext);
                 $this->postError(1610, _t("Error converting file to %1 [%2]: %3", $this->typenames[$mimetype], $mimetype, join("; ", $va_output)), "WLPlugAudio->write()");
                 return false;
             }
             if ($mimetype == "audio/mpeg") {
                 if ($vs_intro_filepath || $vs_outro_filepath) {
                     // add intro
                     $vs_tmp_filename = tempnam(caGetTempDirPath(), "audio");
                     if ($vs_intro_filepath) {
                         exec($this->ops_path_to_ffmpeg . " -i " . caEscapeShellArg($vs_intro_filepath) . " -f mp3 -ab " . $vn_output_bitrate . " -ar " . $vn_sample_frequency . " -ac " . $vn_channels . " -y " . caEscapeShellArg($vs_tmp_filename), $va_output, $vn_return);
                         if ($vn_return != 0) {
                             @unlink($filepath . "." . $ext);
                             $this->postError(1610, _t("Error converting intro to %1 [%2]: %3", $this->typenames[$mimetype], $mimetype, join("; ", $va_output)), "WLPlugAudio->write()");
                             return false;
                         }
                     }
                     $r_fp = fopen($vs_tmp_filename, "a");
                     $r_mp3fp = fopen($filepath . "." . $ext, "r");
                     while (!feof($r_mp3fp)) {
                         fwrite($r_fp, fread($r_mp3fp, 8192));
                     }
                     fclose($r_mp3fp);
                     if ($vs_outro_filepath) {
                         $vs_tmp_outro_filename = tempnam(caGetTempDirPath(), "audio");
                         exec($this->ops_path_to_ffmpeg . " -i " . caEscapeShellArg($vs_outro_filepath) . " -f mp3 -ab " . $vn_output_bitrate . " -ar " . $vn_sample_frequency . " -ac " . $vn_channels . " -y " . caEscapeShellArg($vs_tmp_outro_filename), $va_output, $vn_return);
                         if ($vn_return != 0) {
                             @unlink($filepath . "." . $ext);
                             $this->postError(1610, _t("Error converting outro to %1 [%2]: %3", $this->typenames[$mimetype], $mimetype, join("; ", $va_output)), "WLPlugAudio->write()");
                             return false;
                         }
                         $r_mp3fp = fopen($vs_tmp_outro_filename, "r");
                         while (!feof($r_mp3fp)) {
                             fwrite($r_fp, fread($r_mp3fp, 8192));
                         }
                         unlink($vs_tmp_outro_filename);
                     }
                     fclose($r_fp);
                     copy($vs_tmp_filename, $filepath . "." . $ext);
                     unlink($vs_tmp_filename);
                 }
                 $o_getid3 = new getid3();
                 $va_mp3_output_info = $o_getid3->analyze($filepath . "." . $ext);
                 $this->properties = array();
                 if (is_array($va_mp3_output_info["tags"]["id3v1"]["title"])) {
                     $this->properties["title"] = join("; ", $va_mp3_output_info["tags"]["id3v1"]["title"]);
                 }
                 if (is_array($va_mp3_output_info["tags"]["id3v1"]["artist"])) {
                     $this->properties["author"] = join("; ", $va_mp3_output_info["tags"]["id3v1"]["artist"]);
                 }
                 if (is_array($va_mp3_output_info["tags"]["id3v1"]["comment"])) {
                     $this->properties["copyright"] = join("; ", $va_mp3_output_info["tags"]["id3v1"]["comment"]);
                 }
                 if (is_array($va_mp3_output_info["tags"]["id3v1"]["album"]) && is_array($va_mp3_output_info["tags"]["id3v1"]["year"]) && is_array($va_mp3_output_info["tags"]["id3v1"]["genre"])) {
                     $this->properties["description"] = join("; ", $va_mp3_output_info["tags"]["id3v1"]["album"]) . " " . join("; ", $va_mp3_output_info["tags"]["id3v1"]["year"]) . " " . join("; ", $va_mp3_output_info["tags"]["id3v1"]["genre"]);
                 }
                 $this->properties["type_specific"] = array("audio" => $va_mp3_output_info["audio"], "tags" => $va_mp3_output_info["tags"]);
                 $this->properties["bandwidth"] = array("min" => $va_mp3_output_info["bitrate"], "max" => $va_mp3_output_info["bitrate"]);
                 $this->properties["bitrate"] = $va_mp3_output_info["bitrate"];
                 $this->properties["channels"] = $va_mp3_output_info["audio"]["channels"];
                 $this->properties["sample_frequency"] = $va_mp3_output_info["audio"]["sample_rate"];
                 $this->properties["duration"] = $va_mp3_output_info["playtime_seconds"];
             }
         } else {
             # use default media icons if ffmpeg is not present or the current version is an image
             if (!$this->get("width") && !$this->get("height")) {
                 $this->set("width", 580);
                 $this->set("height", 200);
             }
             return __CA_MEDIA_AUDIO_DEFAULT_ICON__;
         }
     }
     if ($mimetype == "audio/mpeg") {
         // try to write getID3 tags (if set)
         if (is_array($pa_options) && is_array($pa_options) && sizeof($pa_options) > 0) {
             require_once 'parsers/getid3/getid3.php';
             require_once 'parsers/getid3/write.php';
             $o_getID3 = new getID3();
             $o_tagwriter = new getid3_writetags();
             $o_tagwriter->filename = $filepath . "." . $ext;
             $o_tagwriter->tagformats = array('id3v2.3');
             $o_tagwriter->tag_data = $pa_options;
             // write them tags
             if (!$o_tagwriter->WriteTags()) {
                 // failed to write tags
             }
         }
     }
     $this->properties["mimetype"] = $mimetype;
     $this->properties["typename"] = $this->typenames[$mimetype];
     return $filepath . "." . $ext;
 }
Exemple #10
0
 public function mobile_mp4($VideoTask)
 {
     $this->create();
     $this->id = $VideoTask['VideoTask']['id'];
     $this->save(array("task_status" => "working"));
     //import objects
     $MediaFile = ClassRegistry::init("MediaFile");
     App::import("Vendor", "LLFTP", array("LLFTP.php"));
     App::import("Vendor", "getid3", array("file" => "getid3/getid3.php"));
     $video = $MediaFile->find("first", array("conditions" => array("MediaFile.id" => $VideoTask['VideoTask']['foreign_key']), "contain" => array()));
     $llftp = new LLFTP();
     $id3 = new getid3();
     //let's download the video to tmp
     $tmp_file = $MediaFile->downloadVideoToTmp($VideoTask['VideoTask']['foreign_key']);
     //let's get the size of the FLV file
     $vid = $id3->analyze($tmp_file);
     $height = $vid['video']['resolution_y'];
     $width = $vid['video']['resolution_x'];
     $newFileName = str_replace(".mp4", ".mobile.mp4", $video['MediaFile']['limelight_file']);
     $newFilePath = "/home/sites/tmpfiles/" . $newFileName;
     //determine height and width
     if ($height == 394 && $width > 640 || $height == 720) {
         $height = 180;
         $width = 320;
     } else {
         $height = 240;
         $width = 320;
     }
     $cmd = "/usr/local/bin/ffmpeg -y -i {$tmp_file} -vcodec libx264 -vf 'scale={$width}:{$height}' {$newFilePath}";
     SysMsg::add(array("category" => "MobileMp4", "from" => "VideoTask", "crontab" => 1, "title" => $cmd));
     $this->query("SET SESSION wait_timeout = 28800");
     $this->getDatasource()->disconnect();
     $output = `{$cmd}`;
     $this->getDatasource()->connect();
     //ftp the file
     $llftp->ftpFile($newFileName, $newFilePath);
     //update the video file
     $MediaFile->create();
     $MediaFile->id = $video['MediaFile']['id'];
     $MediaFile->save(array("limelight_file_mobile" => $newFileName));
     $this->create();
     $this->id = $VideoTask['VideoTask']['id'];
     $this->save(array("task_status" => "completed"));
 }
Exemple #11
0
 public function remove()
 {
     $engine = new getid3();
     $engine->filename = $this->filename;
     $engine->fp = fopen($this->filename, 'rb');
     $engine->include_module('tag.id3v2');
     $tag = new getid3_id3v2($engine);
     $tag->Analyze();
     if ((int) @$engine->info['avdataoffset']) {
         if (!($fp_source = @fopen($this->filename, 'rb'))) {
             throw new getid3_exception('Could not open ' . $this->filename . ' mode "rb"');
         }
         fseek($fp_source, $engine->info['avdataoffset'], SEEK_SET);
         if (!($fp_temp = @fopen($this->filename . 'getid3tmp', 'w+b'))) {
             throw new getid3_exception('Could not open ' . $this->filename . 'getid3tmp mode "w+b"');
         }
         while ($buffer = fread($fp_source, 16384)) {
             fwrite($fp_temp, $buffer, strlen($buffer));
         }
         fclose($fp_temp);
         fclose($fp_source);
         $this->save_permissions();
         unlink($this->filename);
         rename($this->filename . 'getid3tmp', $this->filename);
         $this->restore_permissions();
         clearstatcache();
     }
     // success when removing non-existant tag
     return true;
 }
 /**
  * Get duration of audio file
  * Uses getid3 class for calculation audio duration - http://www.getid3.org/
  * @param  string $file File name & path
  * @return mixed        File duration on success, boolean false on failure
  */
 public function get_file_duration($file)
 {
     if ($file) {
         if (!class_exists('getid3')) {
             require_once $this->assets_dir . '/getid3/getid3.php';
         }
         $getid3 = new getid3();
         // Identify file by root path and not URL (required for getID3 class)
         $site_root = trailingslashit(ABSPATH);
         $file = str_replace($this->home_url, $site_root, $file);
         $info = $getid3->analyze($file);
         $duration = false;
         if (isset($info['playtime_string']) && strlen($info['playtime_string']) > 0) {
             $duration = $info['playtime_string'];
         } else {
             if (isset($info['playtime_seconds']) && strlen($info['playtime_seconds']) > 0) {
                 $duration = gmdate('H:i:s', $info['playtime_seconds']);
             }
         }
         return apply_filters('ssp_file_duration', $duration, $file);
     }
     return false;
 }
Exemple #13
0
<?php

header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
include '.lib/id3/getid3/getid3.lib.php';
include '.lib/id3/getid3/getid3.php';
$getID3 = new getid3();
$title = 'Your Podcast Title here';
$desc = 'Your description';
$baseref = 'http://yourhost/yourpath/podcast';
// path where this script is.
$icon = 'http://yourhost/yourpath/icon.jpg';
// url of icon
$abouturl = 'http://yourhost/yourpath/';
// A page about your podcast
echo <<<EOW
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
    <channel>
        <!-- begin RSS 2.0 tags -->
        <title>{$title}</title>
        <link>{$abouturl}</link>
        <language>en-us</language>

        <description>{$desc}</description>
        <ttl>720</ttl>
EOW;
if ($icon) {
    echo <<<EOW
        <image>
            <url>{$icon}</url>
            <title>{$title}</title>