Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL & ~E_NOTICE);
- if (isset($_POST['submit'])) {
- $currentPath = $_FILES['video']['tmp_name'];
- $watermark = $_POST['watermark'];
- $xy = $_POST['xy'];
- $star = $_POST['star'];
- $end = $_POST['end'];
- if (empty($currentPath)) {
- exit('die');
- }
- if (empty($star)) {
- $cut = null;
- } elseif (!empty($star) && empty($end)) {
- $cut = "-ss $star";
- } elseif (!empty($star) && !empty($end)) {
- $cut = "-ss $star -to $end";
- }
- /*vi tri (10|-10 là padding thêm cách lề)*/
- if ($xy == 'tl') {
- $vt = ": x=10:y=10";
- } elseif ($xy == 'tr') {
- $vt = ": x=w-tw-10:y=10";
- } elseif ($xy == 'bl') {
- $vt = ": x=10:y=h-th-10";
- } elseif ($xy == 'br') {
- $vt = ": x=w-tw-10:y=h-th-10";
- }
- if (!empty($watermark)) {
- $wm = "-vf drawtext=\"fontfile=old_stamper.ttf: text='" . $watermark . "': fontsize=40: fontcolor=white: box=0" . $vt . "\"";
- }
- /*thuc thi*/
- $output = rand(1, 100);
- exec("ffmpeg.exe");
- exec("ffmpeg -y -i " . $currentPath . " " . $cut . " " . $wm . " " . $output . ".mp4");
- /*show*/
- echo "<code>ffmpeg -y -i " . $currentPath . " " . $cut . " " . $wm . " " . $output . ".mp4</code>";
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>FFMPEG PHP</title>
- <style>
- input[type="file"],
- input[type="text"],
- input[type="submit"]
- {
- margin: 10px 0;
- }
- </style>
- </head>
- <body>
- <form method="post" enctype="multipart/form-data">
- <input type="file" name="video" style="width: 100%; background: #ccc">
- <input type="text" name="star" placeholder="00:00:00.0000"> to
- <input type="text" name="end" placeholder="00:00:00.0000"> (giờ:phút:giây:mili giây)
- <input type="text" name="watermark" placeholder="watermark text" style="width: 100%">
- <p>
- <select name="xy">
- <option value="tl">Top left</option>
- <option value="tr">Top right</option>
- <option value="bl">Bottom left</option>
- <option value="br">Bottom right</option>
- </select> (vị trí watermark)
- </p>
- <input type="submit" name="submit" value="FFMPEG">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement