简体   繁体   English

FFMPEG 创建演示文件

[英]FFMPEG create a demo file

From a given file (eg test.mp4) I want to create a new file with exact same properties (eg video rate, resolution etc) with the only difference to be the duration.从给定的文件(例如 test.mp4)我想创建一个具有完全相同属性(例如视频速率、分辨率等)的新文件,唯一的区别是持续时间。 eg 10 minutes while the original can be 2 hours.例如 10 分钟,而原来的可能是 2 小时。

This will helps me to create preview video files.这将帮助我创建预览视频文件。

PS1: This conversion should be done within a PHP file, so I'll appreciate the code to be in PHP. PS1:这个转换应该在一个 PHP 文件中完成,所以我会很欣赏 PHP 中的代码。 PS2: For testing purposes the original file should be at /home/user/original and the new file must be at /home/user/demo PS2:出于测试目的,原始文件应该在/home/user/original,新文件必须在/home/user/demo

Thank you谢谢

The Linux command to do it is:执行此操作的 Linux 命令是:

ffmpeg -ss 00:00:01 -i Demo.mp4 -to 00:05:00 -c copy NewDemo.mp4

To execute this command from within a PHP file, the syntax is:要从 PHP 文件中执行此命令,语法为:

shell_exec('/usr/local/bin/ffmpeg -ss 00:00:01 -i /origin_folder/myvideo.mp4 -to 00:15:00 -c copy /destination_folder/mynewvideo.mp4 >/dev/null 2>/dev/null &');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM