How to Compress Video Bitrate and Resolution in PHP Using FFMPEG Library Full Project For Beginners

You are currently viewing How to Compress Video Bitrate and Resolution in PHP Using FFMPEG Library Full Project For Beginners
  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

Welcome folks today in this post we will be talking about how to compress video bitrate and resolution in php using ffmpeg library. All the source code is given below. A step by step youtube video is given below.

 

 

 

 

<link rel="stylesheet" type="text/css" href="bootstrap-darkly.min.css">
 
<div class="container" style="margin-top: 200px;">
    <div class="row">
        <div class="col-md-4 offset-md-4">
            <h1>Change bitrate</h1>
 
            <form method="POST" enctype="multipart/form-data" action="change-bitrate.php">
                <div class="form-group">
                    <label>Select video</label>
                    <input type="file" name="video" class="form-control" required="" accept="video/*">
                </div>
 
                <div class="form-group">
                    <label>Select bitrate</label>
                    <select name="bitrate" class="form-control">
                        <option value="350k">240p</option>
                        <option value="700k">360p</option>
                        <option value="1200k">480p</option>
                        <option value="2500k">720p</option>
                        <option value="5000k">1080p</option>
                    </select>
                </div>
 
                <input type="submit" name="change_bitrate" class="btn btn-info" value="Change bitrate">
            </form>
        </div>
    </div>
</div>

 

<?php
 
$video = $_FILES["video"]["tmp_name"];
$bitrate = $_POST["bitrate"];
 
$command = "/usr/local/bin/ffmpeg -i $video -b:v $bitrate -bufsize $bitrate output.mp4";
system($command);
 
echo "File has been converted";

 

<div class="container" style="margin-top: 50px; margin-bottom: 100px;">
    <div class="row">
        <div class="col-md-4 offset-md-4">
            <h1>Change resolution</h1>
 
            <form method="POST" enctype="multipart/form-data" action="change-resolution.php">
                <div class="form-group">
                    <label>Select video</label>
                    <input type="file" name="video" class="form-control" required="">
                </div>
 
                <div class="form-group">
                    <label>Select resolution</label>
                    <input type="text" name="resolution" class="form-control" placeholder="640x480">
                </div>
 
                <input type="submit" name="change_resolution" class="btn btn-info" value="Change resolution">
            </form>
        </div>
    </div>
</div>

 

<?php
 
$video = $_FILES["video"]["tmp_name"];
$resolution = $_POST["resolution"];
 
$command = "/usr/local/bin/ffmpeg -i $video -s $resolution output2.mp4";
system($command);
 
echo "File has been converted";

Leave a Reply