Reputation: 49
The ffmpeg command in php below creates mp4 file from avi file without deleting the original avi file meaning that,for example, there are two files, 1221222.avi and 1221222.mp4 exist in the directry after all.
('for i in /xxxxx/xxxxxx/*.avi; do ffmpeg -i "$i" -frames:v 1 "/xxxxx/xxxxxx/$(basename "$i" .avi).mp4"; done')
I'd like to delete this 1221222.avi file right after the command created 1221222.mp4 file.
Is there any command that converts the file from avi to mp4 by replacing it? Or do I have to add delete command after the command above?
I would appreciate if anyone could help me out for the command.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Even though the php script below can upload avi file from local drive to application I'm currently developping, the avi will not be played at html. So, I'm trying to convert from the avi file to mp4 file which is working fine by using ffmpeg command in php. This ffmpeg command creates mp4, but the html still do not play it. Is it because the original avi file still exists in the directory?
//php
case "video/x-msvideo":
if($header){
header("Content-Type: video/x-msvideo");
$dst_im = copy($path, $dst_file);
return "";
}else{
$dst_file = $dst_file . ".avi";
shell_exec('for i in /xxxxxx/xxxxxx/*.avi; do ffmpeg -i "$i" - frames:v 1 "/xxxxxx/xxxxxx/$(basename "$i" .avi).mp4"; done');
$dst_im = copy($path, $dst_file);
}
unlink($dst_im);
break;
//html
<video width="500" height="250" id="bgvid" poster="video.jpg" controls="controls" preload="auto" autoplay>
<source type="video/mp4" src="xxxxxxxxxxxxxxxxxxxxx.mp4" />
</video>
Upvotes: 0
Views: 633
Reputation: 776
There is no such operation, you can just append a bash command like
rm filename.mp4
to the script or you remove the file through php with
unlink($filepath);
Upvotes: 2