What potential issues could arise when using shell_exec() in PHP to execute ffmpeg commands?

One potential issue when using shell_exec() to execute ffmpeg commands is the risk of command injection attacks if user input is not properly sanitized. To mitigate this risk, always validate and sanitize user input before passing it to shell_exec().

// Example of sanitizing user input before using shell_exec() with ffmpeg
$user_input = $_POST['input']; // Assuming user input comes from a form field
$sanitized_input = escapeshellarg($user_input); // Escape user input to prevent command injection

$output = shell_exec("ffmpeg -i $sanitized_input output.mp4");
echo $output;