Skip to content

Instantly share code, notes, and snippets.

@idawnlight
Created August 26, 2017 02:53
Show Gist options
  • Save idawnlight/cda6da0ed1c4fb84d423e19692cab4cf to your computer and use it in GitHub Desktop.
Save idawnlight/cda6da0ed1c4fb84d423e19692cab4cf to your computer and use it in GitHub Desktop.
合并 Bilibili 下载的视频/电影
<?php
echo "Making a list..." . "\n";
foreach(scandir("./") as $name) {
if (preg_match_all("/[0-9]+-(.*)-hd.flv/", $name, $id)) {
$file[$id[1][0]] = $name;
}
}
if (empty($file)) {
echo "Can't find any video.\nExit.";
exit;
}
$list = "";
for ($i = 1; true; $i++) {
if (!isset($file[$i+1])) {
$list .= "file '" . $file[$i] . "'";
break;
}
$list .= "file '" . $file[$i] . "'\n";
}
file_put_contents("./ff.txt", $list);
echo "Using ffmpeg to merge..." . "\n";
passthru("ffmpeg -f concat -i ./ff.txt -c copy output.mp4");
echo "Done.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment