【发布时间】:2017-04-05 15:10:44
【问题描述】:
代码可以正常工作,但如果文件名只有一个 qoute,就像“Britney's video.mp4”一样,它就不起作用。
$ffmpeg = "/usb/bin/local/ffmpeg";
$videos = "/videos/*.mp4";
$ouput_path = "/videos/thumbnails/";
foreach(glob($videos) as $video_file){
$lfilename = basename($video_file);
$filename = basename($video_file, ".mp4");
$thumbnail = $ouput_path.$filename.'.jpg';
if (!file_exists($filename)) {
#$thumbnail = str_replace("'", "%27", $thumbnail);
exec("/usr/local/bin/ffmpeg -i '$video_file' -an -y -f mjpeg -ss 00:00:30 -vframes 1 '$thumbnail'");
}
echo "<a href='$lfilename'>$filename<img src='thumbnails/$filename.jpg' width='350'>";
【问题讨论】:
-
您可以在
$video_file和$thumbnail上使用php.net/manual/en/function.escapeshellarg.php。 -
谢谢,我不知道如何使用或放置它。只是看起来过于复杂..
-
是否点击了提供的链接?它解释了它的作用。
escapeshellarg() adds single quotes around a string and quotes/escapes any existing single quotes allowing you to pass a string directly to a shell function and having it be treated as a single safe argument. -
感谢我确实访问过它,但我不知道把它放在哪里......或如何。
-
您了解手册页的内容/您的代码在做什么吗?你挂在哪儿了?