0

I'm using amazon s3 as video storage for my website. I'm having problems for some videos. black screen or sound problems etc.

I want to convert the video to mp4 format after uploading the video to my server and then upload it to amazon. Is it possible with FFMPEG?

I'm using this code for uploading files now:

$file1 = $_FILES['file']['name'];
$videoFileType = strtolower(pathinfo($file1,PATHINFO_EXTENSION));
$file_name = sprintf('%s_%s', uniqid(),uniqid().".".$videoFileType);
$temp_file_location = $_FILES["file"]["tmp_name"];

require 'application/libraries/Amazon/aws-autoloader.php';
        $s3 = new Aws\S3\S3Client([
            'region'  => $amazon_region,
            'version' => 'latest',
            'credentials' => [
            'key'    => $amazon_key,
            'secret' => $amazon_secret,
            ]
        ]);     

        $result = $s3->putObject([
            'Bucket' => $amazon_bucket,
            'Key'    => $file_name,
            'SourceFile' => $temp_file_location,
            'ACL'    => 'public-read',
            'CacheControl' => 'max-age=3153600',
        ]);
            $filepath = $result['ObjectURL'] . PHP_EOL;

            echo json_encode([
                'status' => 'ok',
                'path' => $filepath

            ]);
  • 1
    https://stackoverflow.com/questions/46066860/php-convert-any-video-to-mp4-using-ffmpeg – Jeremy Harris Oct 31 '19 at 12:23
  • Does this answer your question? [PHP convert any video to MP4 using ffmpeg](https://stackoverflow.com/questions/46066860/php-convert-any-video-to-mp4-using-ffmpeg) – John Klakegg Oct 31 '19 at 12:28
  • No. I want to convert and reupload amazon s3. I dont want to storage files in my server – Kadir Geçit Oct 31 '19 at 12:32
  • @KadirGeçit You'll usually have to write that file out to disk first, before uploading. You can't stream straight on through, as (ideally) the muxer goes back in the file to write some boxes after it's done with the video. – Brad Oct 31 '19 at 18:17

0 Answers0