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

Aspect ratio distorted with newer Samsung Galaxy videos #48

Open
zealot128 opened this issue May 31, 2017 · 0 comments
Open

Aspect ratio distorted with newer Samsung Galaxy videos #48

zealot128 opened this issue May 31, 2017 · 0 comments

Comments

@zealot128
Copy link

After upgrading a Samsung Galaxy phone, all my newer videos made in portrait mode have the wrong aspect ratio after transcoding (any target format), e.g.:

preview_20170531_114221

I have a fix that works for my videos now:

  1. I've forked the Gem and removed the default resolution (640x360) and preserve_aspect_ratio attributes (:width), as those interfer with the solution
  2. I've replaced the resizing with a decrease as written in the ffmpeg docs in the last paragraph here (https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg)
  3. When transcoding a video, I've moved the resolution parameters together with the solution in the custom block, as otherwise streamio-ffmpeg will add a nasty aspect-param that distorts the image again
# old video->jpg
# process encode_video: [:jpg, resolution: '500x500', preserve_aspect_ratio: :width]
process encode_video: [:jpg, custom: '-vf scale=w=500:h=500:force_original_aspect_ratio=decrease']

# old video->mp4
# process encode_video: [:mp4, resolution: '640x360', preserve_aspect_ratio: :width, audio_codec: 'aac']
process encode_video: [:mp4, custom: '-s 640x360 -vf scale=w=640:h=360:force_original_aspect_ratio=decrease', audio_codec: 'aac']

I am aware, that Carrierwave Video can't do to much but just change the default resolution/preserve_aspect_ratio params to allow override. There seem to be a problem in combination with the streamio-ffmpeg Gem. Just leaving this here to help other people with the same problem!

Difference between Samsung's meta data: I've compared a "new" and a "old" video. Most params are similar, but one stood out.

It seems, that the old format didn't specify the aspect ratio, but the new one specify it:

// NEW format (output from ffprobe)
{
    ///...
    "sample_aspect_ratio": "1:1",                                                              
    "display_aspect_ratio": "16:9",
}

// OLD format (output from ffprobe)
{
    ///...
    "sample_aspect_ratio": "0:1",
    "display_aspect_ratio": "0:1",
}
@zealot128 zealot128 changed the title Aspect ratio ignored with newer Samsung Galaxy videos Aspect ratio distorted with newer Samsung Galaxy videos May 31, 2017
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