简体   繁体   中英

How to run ffmpeg with php in debian 10

i am trying to run a ffmpeg command with my php in Debian 10, but its not working, but the command is working perfectly in windows. The command is to add a watermark and a text at the bottom of the video. Here is the php code

<?php
    $new_file="new.mp4";
    $text="eloke";
    $video_name="video.mp4";
    echo file_exists($new_file)? "<video autoplay src='$new_file'></video>":"No file";
   
    $cmd="ffmpeg -i $video_name -i watermark.jpg -filter_complex overlay=W-w-5:H-h-15[video];[video]drawtext=\"text=$text:fontcolor=white:fontsize=12:x=(w-text_w)-5: y=(h-text_h)-5\" $new_file";
    exec("$cmd 2>&1", $output);
    var_dump($output);
?>

I am getting this in the browser

array(1) { [0]=> string(103) "sh: 1: [video]drawtext=text=eloke:fontcolor=white:fontsize=12:x=(w-text_w)-5: y=(h-text_h)-5: not found" }

Please what am i doing wrong

Try using the following snippet and replace into your original code:

$cmd = "ffmpeg -i ".$video_name." -i watermark.jpg -filter_complex overlay=W-w-5:H-h-15[video];[video]drawtext=\"text=".$text.":fontcolor=white:fontsize=12:x=(w-text_w)-5: y=(h-text_h)-5\" ".$new_file;
$cmd = escapeshellcmd($cmd);
exec($cmd." > /path/to/stdout_file 2>&1", $output);

Also, beware of using escapeshellcmd()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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