Proyectos de Subversion LeadersLinked - Services

Rev

Rev 333 | Rev 345 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 333 Rev 334
Línea 94... Línea 94...
94
            else if($video->type == VideoConvert::TYPE_MICRO_LEARNING_SLIDES) {
94
            else if($video->type == VideoConvert::TYPE_MICRO_LEARNING_SLIDES) {
95
                $targe_path = $storage->getPathMicrolearningSlide();
95
                $targe_path = $storage->getPathMicrolearningSlide();
96
            }
96
            }
97
            else if($video->type == VideoConvert::TYPE_MEDIA) {
97
            else if($video->type == VideoConvert::TYPE_MEDIA) {
98
                $targe_path = $storage->getPathMedia();
98
                $targe_path = $storage->getPathMedia();
-
 
99
            }
-
 
100
            else if($video->type == VideoConvert::TYPE_HABIT_CONTENT) {
-
 
101
                    $targe_path = $storage->getPathHabitContent();
99
            } else {
102
            } else {
100
                $targe_path = '';
103
                $targe_path = '';
101
            }
104
            }
Línea 102... Línea 105...
102
            
105
            
103
            if(empty($targe_path)) {
106
            if(empty($targe_path)) {
104
                $videos_ignorados++;
107
                $videos_ignorados++;
105
                $videoConvertMapper->delete($video);
108
                $videoConvertMapper->delete($video);
106
                continue;
109
                continue;
Línea -... Línea 110...
-
 
110
            }
-
 
111
 
Línea -... Línea 112...
-
 
112
            
-
 
113
            $directory = $storage->getDirectoryFromDisk($targe_path, $video->uuid);
107
            }
114
           
108
 
-
 
109
           
115
            $currentfile = $directory . DIRECTORY_SEPARATOR .  $video->filename;
110
           
116
            $posterfile  = $directory . DIRECTORY_SEPARATOR .  substr($video->filename, 0, strrpos($video->filename, '.')).  '.jpg';
111
            $url = $storage->getGenericFile($targe_path, $video->uuid, $video->filename, $checkExists);
117
            
112
            if(empty($url)) {
118
            if(!file_exists($currentfile)) {
113
                $videos_ignorados++;
119
                $videos_ignorados++;
Línea 114... Línea 120...
114
                $videoConvertMapper->delete($video);
120
                $videoConvertMapper->delete($video);
Línea 115... Línea 121...
115
                continue;
121
                continue;
116
            }
122
            }
117
            
123
            
118
            $s = explode('.', $video->filename);
-
 
119
            
124
            $s = explode('.', $video->filename);
120
            $tmpname  =  sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $s[0] . '-tmp.' . $s[1];
125
            
121
            $filename =  sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $video->filename;
126
            $tmpfile    = sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $s[0] . '-tmp.' . $s[1];
122
            
127
            $newfile    = sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $video->filename;
-
 
128
      
123
            $content = file_get_contents($url);
129
            if(!@copy($currentfile, $tmpfile)) {
124
            if(empty($content)) {
-
 
Línea 125... Línea 130...
125
                $videos_ignorados++;
130
                $videos_ignorados++;
126
                $videoConvertMapper->delete($video);
-
 
127
                continue;
-
 
128
            }
-
 
129
            file_put_contents($tmpname, $content);
-
 
130
            
-
 
131
            if(file_exists($tmpname)) {
-
 
132
                
131
                $videoConvertMapper->delete($video);
133
                $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $full_filename";
-
 
134
                $response   = trim(shell_exec($cmd));
-
 
135
                
-
 
136
                $source_duration = 0;
132
                continue;
137
 
-
 
138
                
-
 
139
                $lines = explode("\n", $response);
133
                
140
                foreach($lines as $line)
-
 
141
                {
134
            }
142
                    $line = trim(strtolower($line));
-
 
Línea 143... Línea -...
143
                     if(strpos($line, 'duration') !== false) {
-
 
144
                         $values = explode('=', $line);
-
 
145
                         $source_duration = intval($values[1], 10);
-
 
146
                     }
-
 
147
                }
-
 
148
 
-
 
149
                
-
 
150
                if($source_duration == 0) {
-
 
151
                    $second_extract = '00:00:02';
-
 
152
                } else {
-
 
153
                    if($source_duration > 10) {
-
 
154
                        $second_extract = '00:00:10';
-
 
155
                    } else {
-
 
156
                        $second_extract = '00:00:02';
-
 
157
                    }
-
 
158
                    
-
 
159
                }
-
 
160
                
-
 
161
                $poster = substr($video->filename, 0, strrpos($video->filename, '.')).  '.jpg';
-
 
162
                $poster =  sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $poster;
-
 
163
                
135
            
164
                $cmd = "/usr/bin/ffmpeg -y -i $tmpname  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y $poster";
136
            if(file_exists($tmpfile)) {
165
                $output->writeln("command  : $cmd" );
137
  
Línea 166... Línea 138...
166
                exec($cmd);
138
                if(!file_exists($posterfile)) {
Línea -... Línea 139...
-
 
139
                    \LeadersLinked\Library\Video::extractPoster($tmpfile, $posterfile);
-
 
140
                }
-
 
141
                
167
                
142
                $cmd = "/usr/bin/ffmpeg -y -i $tmpfile  -preset medium -crf 24 -codec:v libx264 $newfile";  
168
                $storage->putFile($targe_path, $video->uuid, $poster); 
143
                $output->writeln("command  : $cmd" );
169
                                     
-
 
Línea 170... Línea 144...
170
                $cmd = "/usr/bin/ffmpeg -y -i $tmpname  -preset medium -crf 24 -codec:v libx264 $filename";  
144
                exec($cmd);
171
                $output->writeln("command  : $cmd" );
145
 
172
                exec($cmd);
146
                @copy($newfile, $currentfile);
173
 
147
                
174
                $storage->putFile($targe_path, $video->uuid, $filename);            
-
 
175
                
148
                @unlink($tmpfile);
176
                $videos_procesados++;
149
                @unlink($newfile);
177
                $videoConvertMapper->delete($video);
-
 
178
            
150
 
179
                
151
                $videos_procesados++;
180
            } else {
152
                $videoConvertMapper->delete($video);
Línea 181... Línea 153...
181
                $videoConvertMapper->delete($video);
153