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

Portrait videos are stretching #83

Open
shankar-bavan opened this issue Nov 10, 2020 · 5 comments · May be fixed by #137
Open

Portrait videos are stretching #83

shankar-bavan opened this issue Nov 10, 2020 · 5 comments · May be fixed by #137

Comments

@shankar-bavan
Copy link

shankar-bavan commented Nov 10, 2020

When I encode mobile portrait video to hls, it got stretch. how to encode without stretching?

This issue only for video recorded from iphone

            $video->hls()
            ->encryption($save_to, $url, 1)
            ->setFormat($format)
            ->setHlsTime(5)
            ->setHlsAllowCache(false)
            ->autoGenerateRepresentations()
            ->save($save_path);
@bekee
Copy link

bekee commented Nov 27, 2020

Has anyone found solution to this issue?

@shankar-bavan
Copy link
Author

@aminyazdanpanah any solution for this ?

@aminyazdanpanah
Copy link
Member

It seems like the FFmpeg library has an issue with the 'h264 apple encoder'. I will try to reach out to FFmpeg developers and report this bug.

I will be keeping this issue until I(or anyone else) find a solution.

@chmerev
Copy link

chmerev commented Apr 2, 2021

We had such a problem. It is necessary to take into account the aspect ratio when setting the dimensions.

By default you load 1080 by 1920 video for example. And FFMPEG takes and renders 1920 and 1080 and produces a stretched video image.

If the video is 1080 by 1920, then we take the closest available resize - this is 720p.

And set the parameters to resize 1280 x 720.

In general, you need to understand which video comes in and calculate the aspect ratio for each video and there will be no problem

@crishoj
Copy link

crishoj commented Sep 29, 2023

I suspect the cause could be that rotation is not handled by autoGenerateRepresentations().

Example input file in portrait format, from an iPhone:

  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      creation_time   : 2023-09-29T12:27:45.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 568x320, 705 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2023-09-29T12:27:45.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -90.00 degrees 👈 This indicates rotation

ffprobe indicates a resolution of 568x320 (landscape), but due to 90° rotation the video is actually 320x568 (portrait).

crishoj added a commit to monotreedk/PHP-FFmpeg-video-streaming that referenced this issue Sep 29, 2023
@crishoj crishoj linked a pull request Sep 29, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants