Skip to content

Incorrect Cropping When Desired Aspect Ratio < 1 #215

@fedoseevav

Description

@fedoseevav

1. Description of the Bug

When the input video's aspect ratio is greater than 1 (landscape) and the desired aspect ratio is less than 1 (portrait), the cropping behavior is incorrect.

Example:

  • Input video resolution: 1280×720 (aspect ratio: ~1.77)
  • Desired aspect ratio: 0.5 (expected output: 360×720)
  • Actual output: 1280×640 (aspect ratio: 2.0)

This is a bug because 2.0 ≠ 0.5.


2. Environment Details

  • Transcoder version: 0.11.2
  • Device type: Samsung A15 (likely not device-specific)
  • Android API level: 34 (likely not OS-specific)
  • Note: The issue appears consistently across devices and API levels.

3. Steps to Reproduce

  1. Provide an input video with an aspect ratio > 1 (width > height).
  2. Set the desired aspect ratio to 0.5f (or any value < 1).
Transcoder.into(outputFilePath)  
    .addDataSource(inputFilePath)  
    .setVideoTrackStrategy(DefaultVideoStrategy.aspectRatio(0.5f).build())  
    .transcode()  

4. Expected Behavior

For an input of 1280×720 (~1.77) and a desired aspect ratio of 0.5, the output should be:

  • Correct resolution: 360×720 (aspect ratio: 0.5)

5. Media Files Affected

The issue occurs with any landscape video (aspect ratio > 1) when a portrait aspect ratio (< 1) is requested. No specific file is required to reproduce.


Additional Notes

  • The bug suggests a miscalculation in the cropping logic when converting landscape to portrait.
  • A fix should ensure the output respects the exact requested aspect ratio.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions