该程序youtube-dl
本身支持文件名中的非 ASCII 字符,它在我的网络服务器上以 root 用户和 www-data 用户完美运行,但是当我尝试使用 youtube-dl 和 PHP 下载视频时,非 ASCII 字符被完全跳过。
例如:Stromae - bâtard
将被保存为Stromae - btard.mp4
或البث الحي
作为.mp4
我正在使用此代码运行 CLI 命令
function cmd($string) {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
$process = proc_open($string, $descriptorspec, $pipes);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$ret = proc_close($process);
return $stdout;
}
$value = ('youtube-dl https://some.valid/link');
echo cmd($value);
请告诉我应该怎么做才能解决这个问题。