Code Duplication    Length = 11-13 lines in 5 locations

src/PlaygroundCore/Service/Ffmpeg.php 5 locations

@@ 201-211 (lines=11) @@
198
        return $target;
199
    }
200
201
    public function mergeMp3ToMp4($audioSource, $videoSource, $target)
202
    {
203
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
204
       
205
        $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
206
           ->addCommand('-i', $videoSource)
207
           ->addCommand('-i', $audioSource, true)
208
           ->setOutputPath($target)
209
           ->execute();
210
        return $target;
211
    }
212
213
    public function convertMp4ToOgv($videoSource, $target)
214
    {
@@ 213-223 (lines=11) @@
210
        return $target;
211
    }
212
213
    public function convertMp4ToOgv($videoSource, $target)
214
    {
215
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
216
       
217
        $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
218
            ->addCommand('-i', $videoSource)
219
            ->setOutputPath($target)
220
            ->execute();
221
        
222
        return $target;
223
    }
224
225
    /**
226
     * ffmpeg -i sound.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 out.mp3
@@ 264-276 (lines=13) @@
261
        return $target;
262
    }
263
264
    public function mergeMp4($videoSource, $target)
265
    {
266
        // don't want this service to be a singleton. I have to reset the ffmpeg parameters for each call.
267
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
268
       
269
        $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
270
            ->addPreInputCommand('-y')
271
            ->addCommand('-i', $videoSource)
272
            ->setOutputPath($target)
273
            ->execute();
274
        
275
        return $target;
276
    }
277
278
    /*
279
    *  this method takes an image (with alpha) or a mov video (the format to keep alpha channel) and overlay this layer
@@ 340-352 (lines=13) @@
337
    *
338
    * ffmpeg -i title.wav -af "volume=4" titleok.wav
339
    */
340
    public function increaseVolumeSound($source, $level, $target)
341
    {
342
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
343
       
344
        $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
345
            ->addPreInputCommand('-y')
346
            ->addCommand('-i', $source, true)
347
            ->addCommand('-af', 'volume='.$level)
348
            ->setOutputPath($target)
349
            ->execute();
350
351
        return $target;
352
    }
353
354
    /*
355
    *  this method creates an audio file of $duration seconds with no sound
@@ 359-370 (lines=12) @@
356
    *  on a background video.
357
    *  ffmpeg -y -filter_complex 'aevalsrc=0:d=1.6' silence.wav
358
    */
359
    public function createNullSound($duration = 1, $target)
360
    {
361
        $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false);
362
       
363
        $this->serviceLocator->get('playgroundcore_phpvideotoolkit')
364
            ->addPreInputCommand('-y')
365
            ->addCommand('-filter_complex', 'aevalsrc=0:d='.$duration)
366
            ->setOutputPath($target)
367
            ->execute();
368
369
        return $target;
370
    }
371
372
    /**
373
    * This method concatenate an array of sounds