Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I need help to post an instagram story #506

Open
ismailbentabett opened this issue Oct 13, 2023 · 2 comments
Open

I need help to post an instagram story #506

ismailbentabett opened this issue Oct 13, 2023 · 2 comments

Comments

@ismailbentabett
Copy link

i need to apply this in php

ffmpeg -i input.mp4 \
-c:v libx264 -aspect 16:9 -crf 18 \
-vf "scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2" \
-fpsmax 60 -preset ultrafast -c:a aac -b:a 128k -ac 1 -pix_fmt yuv420p -movflags +faststart -t 59 -y output.mp4```
@ismailbentabett
Copy link
Author

that is my code to make the video for upload

   $video = $request->file('video');

    // Step 1: Upload the original video to Amazon S3
    $originalVideoPath = Storage::disk('s3')->putFile('videos', $video, 'public');

    // Step 2: Generate a URL for the uploaded video
    $originalVideoUrl = Storage::disk('s3')->url($originalVideoPath);

    // Step 3: Transcode the video with FFmpeg
    $ffmpeg = FFMpeg::fromDisk('s3');
    /* -fpsmax 60 -preset ultrafast -c:a aac -b:a 128k -ac 1 -pix_fmt yuv420p -movflags +faststart -t 59 -y */
    $format = (new \FFMpeg\Format\Video\X264())->setAdditionalParameters(['-pix_fmt', 'yuv420p']);
    $randomStr = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);


    $ffmpeg->open($originalVideoPath)
    ->export()
    /*  \ */

        ->addFilter(function (VideoFilters $filters) {
            $filters->custom('scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih)')->resize(new Dimension(1024, 490), $mode = \FFMpeg\Filters\Video\ResizeFilter::RESIZEMODE_INSET, true)
            ->crop(new \FFMpeg\Coordinate\Point(0, 0), new \FFMpeg\Coordinate\Dimension(1024, 490));

        })
      
        ->addFilter(function (VideoFilters $filters) {
            $filters->custom('pad=1280:720:(1280-iw)/2:(720-ih)/2');

        })    
        ->addFilter('-fpsmax', '60', '-preset', 'ultrafast', '-c:a', 'aac', '-b:a', '128k', '-ac', '1', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', '-t', '59', '-y')
        ->toDisk('s3')
        ->inFormat($format)
        ->save('transcoded/' . pathinfo($originalVideoPath, PATHINFO_FILENAME) . $randomStr . '.mp4');
    // Step 4: Generate the URL for the transcoded video
    $transcodedVideoPath = 'transcoded/' . pathinfo($originalVideoPath, PATHINFO_FILENAME) . $randomStr . '.mp4';
    // Make the transcoded video public
    Storage::disk('s3')->setVisibility($transcodedVideoPath, 'public');
    $transcodedVideoUrl = Storage::disk('s3')->url($transcodedVideoPath);
    return $transcodedVideoUrl;

@ismailbentabett
Copy link
Author

what am i doing wrong ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant