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.

Revisions

  1. idawnlight created this gist Aug 26, 2017.
    31 changes: 31 additions & 0 deletions merge.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    <?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.";