|
@@ 126-144 (lines=19) @@
|
| 123 |
|
* This method takes a mp4 source and transform it to Mpeg (with .ts as extension) |
| 124 |
|
* ffmpeg -i in.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts out.ts |
| 125 |
|
*/ |
| 126 |
|
public function transformMp4ToMpg($source, $target) |
| 127 |
|
{ |
| 128 |
|
try { |
| 129 |
|
$this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); |
| 130 |
|
$this->serviceLocator->get('playgroundcore_phpvideotoolkit') |
| 131 |
|
->addCommand('-i', $source) |
| 132 |
|
->addCommand('-c', 'copy') |
| 133 |
|
->addCommand('-bsf:v', 'h264_mp4toannexb') |
| 134 |
|
->addCommand('-f', 'mpegts') |
| 135 |
|
->setOutputPath($target) |
| 136 |
|
->execute(); |
| 137 |
|
} catch (FfmpegProcessOutputException $e) { |
| 138 |
|
throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); |
| 139 |
|
} catch (\PHPVideoToolkit\Exception $e) { |
| 140 |
|
throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
return $target; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
/** |
| 147 |
|
* This method takes a mp4 source and transform it to Mpeg (with .ts as extension) |
|
@@ 150-168 (lines=19) @@
|
| 147 |
|
* This method takes a mp4 source and transform it to Mpeg (with .ts as extension) |
| 148 |
|
* ffmpeg -i in.mov -vcodec h264 -pix_fmt yuv420p -f mpegts out.ts |
| 149 |
|
*/ |
| 150 |
|
public function transformMovToMpg($source, $target) |
| 151 |
|
{ |
| 152 |
|
try { |
| 153 |
|
$this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); |
| 154 |
|
$this->serviceLocator->get('playgroundcore_phpvideotoolkit') |
| 155 |
|
->addCommand('-i', $source) |
| 156 |
|
->addCommand('-vcodec', 'h264') |
| 157 |
|
->addCommand('-pix_fmt', 'yuv420p') |
| 158 |
|
->addCommand('-f', 'mpegts') |
| 159 |
|
->setOutputPath($target) |
| 160 |
|
->execute(); |
| 161 |
|
} catch (FfmpegProcessOutputException $e) { |
| 162 |
|
throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); |
| 163 |
|
} catch (\PHPVideoToolkit\Exception $e) { |
| 164 |
|
throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
return $target; |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
/** |
| 171 |
|
* This method will merge videos in .mpg format with exactly the same codec and codec parameters : |