我正在用ffmpeg创建视频。如何居中文字?另外,我的文字有新行。 这是我的代码:
OPEN
这里是
$json = json_decode($array[$j][$i]->text, true);
$remove_BSN = str_replace('\\', "\'\\'", addslashes($json['text']));
//max possible number of percents in text. Suppose 200
$max_count = 200;
$add_slashes_for_percent = str_replace("%","\\\\\\\\\\\\%",$remove_BSN, $max_count);
// print_r($add_slashes_for_percent);
$command_string .= ' && ffmpeg -y -i generated' . $unix_time . '.mp4 -filter_complex "drawtext="fontfile=/home/livescreen_fonts/'
. str_replace(' ', '', $json["font_family"]). '.ttf:' . '"' . "text=" . "'" . $add_slashes_for_percent . "'". ": fontcolor=white: fontsize=" . $json['font_size'] . ":" . $layout_string
. ":" . "fontcolor_expr=" . $json['font_color'] . "%{eif\\\\\\\\: clip(255*(1*between(t\\\\, $DS + $FID\\\\, $DE - $FOD) + "
. "((t - $DS)/$FID)*between(t\\\\, $DS\\\\, $DS + $FID) + (-(t - $DE)/$FOD)"
. "*between(t\\\\, $DE - $FOD\\\\, $DE) )\\\\, 0\\\\, 255) \\\\\\\\: x\\\\\\\\: 2 }:"
. "enable='between(t," . ($this->parseStartTime($array[$j][$i]->start_time) - $substracted_delay) . ","
. ($this->parseStartTime($array[$j][$i]->start_time) + $array[$j][$i]->duration + $added_delay) . ")'"
. '"' . " -codec:a copy temp" . $unix_time . ".mp4 2>&1";