libriciel / file-converters
允许通过回调函数转换文件类型
1.2.4
2023-04-24 10:15 UTC
Requires
- php: >=7.2 || ^8.1
- ext-fileinfo: *
- ext-json: *
Requires (Dev)
- libriciel/file-converters-tests: dev-master
- libriciel/file-validator: ^1.1
- phpunit/phpunit: ~8.5.0
Suggests
- libriciel/file-converters-tests: Pour les tests unitaires
README
需求
为了很好地使用此工具,建议安装Ubuntu 16.04 LTS。需要PHP版本 >= 5.6(兼容PHP 7)。您还需要确保以下包已安装,以在所有支持文件类型上获得最佳性能。
sudo apt-get install imagemagick handbrake-cli soundconverter libavcodec-extra libav-tools
安装
composer config repositories.libriciel/file-converters git git@gitlab.libriciel.fr:file-converters/file-converters.git
composer require libriciel/file-converters ~1.0
使用
使用非常简单,只需调用静态方法 \File\Converters\FileConverters::convert($filename, $formatDeDestination)
以获取二进制字符串。第3个参数允许在需要时将结果保存到文件中(指定路径)。第4个参数允许将参数发送到转换回调。
使用示例
\File\Converters\FileConverters::convert(
'uploaded/file.avi',
'mp4',
'converted/file.mp4',
[
'video' => 'x265',
'audio' => 'ac3',
]
);
$imageBin = \File\Converters\FileConverters::convert(
'uploaded/image.jpg',
'png'
);
可能的转换(已测试)
音频
- aac
- ac3
- aiff
- amr
- au
- flac
- m4a
- mid
- mka
- mp3
- ogg
- ra
- voc
- wav
- wma
版本
- flac
- ogg
- mp3 (未测试)
- wav
图像
- bmp
- gif
- 动画gif(第一帧)
- ico
- jpg
- png
- svg
- tiff
- webp
版本
- jpg
- png
办公/文本文件类型
- css
- csv
- doc
- docx
- html
- json
- ods
- odt
- ppt
- pptx
- rtf
- txt
- uot
- xls
- xlsx
版本
- jpg
- png
- html
视频,输入/输出支持大量编解码器
- 3gp
- avi
- flv
- mkv
- mov
- mp4
- mpg
- webm
版本(默认编解码器:h264和aac)
- mkv
- mp4