deepmedia / deepmedia/Transcoder
Incorrect Cropping When Desired Aspect Ratio < 1
- Dominant language
- Java
- Stars
- 864
- Forks
- 181
- PR merge metrics
- No merged PRs in 30d
Description
#### **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**).
```kotlin
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.
Contributor guide
Assessment
This issue has not been assessed yet.