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

Stretching resolution for potrait video with ratio of 18:9 #77

Closed
emmbyiringiro opened this issue Jan 4, 2022 · 10 comments
Closed

Stretching resolution for potrait video with ratio of 18:9 #77

emmbyiringiro opened this issue Jan 4, 2022 · 10 comments

Comments

@emmbyiringiro
Copy link

The latest android device camera has support for 18:9. when a device uses this aspect ratio the video is rendered in portrait mode which is better for video reels platforms like TikTok.

When you need to compress down, on Android Video stretch and final resolution become landscape.

I have done this test for final compression resolution

https://github.com/Shobbak/react-native-compressor/blob/master/android/src/main/java/com/reactnativecompressor/Video/AutoVideoCompression/AutoVideoCompression.java#L39


   const actualWidth =1080
   const actualHeight = 1920
   const maxSize = 640
   
   
     const scale = actualWidth > actualHeight ? maxSize / actualWidth : maxSize / actualHeight;


     const resultWidth = Math.round(actualWidth * scale / 2) * 2;


     const resultHeight = Math.round(actualHeight * scale / 2) * 2;


     console.log({resultHeight,resultWidth}) // { resultHeight: 640, resultWidth: 360 }
     
    

Resolution is scaled perfect but when you pass to VideoSlimer it swaps width to height.

So final video become

 { resultHeight: 360, resultWidth: 640 }

@nomi9995 Try to record video in portrait mode probably at 18:9. There's a possibility that this new aspect ratio is not supported by https://github.com/zolad/VideoSlimmer

@numandev1
Copy link
Owner

@emmbyiringiro i fixed this issue. did you try new version?

@emmbyiringiro
Copy link
Author

emmbyiringiro commented Jan 4, 2022 via email

@numandev1
Copy link
Owner

@emmbyiringiro can you try 0.5.12?

@emmbyiringiro
Copy link
Author

emmbyiringiro commented Jan 4, 2022

There's a conflict from the previous version you need to solve before release. You were tired Lol you didn't catch them.

880e95f#diff-01ebdeeada01df00fb8aa5b4fd6408b7e5d5faa9c58a900e868f32e2a7adc669R17

@numandev1
Copy link
Owner

numandev1 commented Jan 5, 2022

@emmbyiringiro sorry I did cherry-pick and picked the wrong commit. can you try 0.5.13?

@numandev1
Copy link
Owner

@emmbyiringiro did you check 0.5.13 version?

@emmbyiringiro
Copy link
Author

Git conflict solved but there's another compile-time error.

[stderr] Note: Recompile with -Xlint:unchecked for details.
> Task :react-native-community_slider:bundleLibCompileToJarDebug
> Task :react-native-compressor:generateDebugBuildConfig
> Task :react-native-compressor:javaPreCompileDebug
> Task :react-native-compressor:compileDebugJavaWithJavac FAILED
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:15: error: cannot find symbol
[stderr]   static Map<String, VideoCompressTask> compressorExports = new HashMap<>();
[stderr]          ^
[stderr]   symbol:   class Map
[stderr]   location: class com.reactnativecompressor.Utils.Utils
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:25: error: cannot find symbol
[stderr]   public static void compressVideo(String srcPath, String destinationPath, int resultWidth, int resultHeight, float videoBitRate, String uuid, Promise promise, ReactApplicationContext reactContext){
[stderr]                                                                                                                                                ^
[stderr]   symbol:   class Promise
[stderr]   location: class com.reactnativecompressor.Utils.Utils
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:78: error: cannot find symbol
[stderr]                                 @Nullable WritableMap params) {
[stderr]                                  ^
[stderr]   symbol:   class Nullable
[stderr]   location: class com.reactnativecompressor.Utils.Utils
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:15: error: cannot find symbol
[stderr]   static Map<String, VideoCompressTask> compressorExports = new HashMap<>();
[stderr]                                                                 ^
[stderr]   symbol:   class HashMap
[stderr]   location: class com.reactnativecompressor.Utils.Utils
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:48: error: cannot find symbol
[stderr]           WritableMap params = Arguments.createMap();
[stderr]                                ^
[stderr]   symbol: variable Arguments
[stderr] /root/workingdir/build/node_modules/react-native-compressor/android/src/main/java/com/reactnativecompressor/Utils/Utils.java:49: error: cannot find symbol
[stderr]           WritableMap data = Arguments.createMap();
[stderr]                              ^
[stderr]   symbol: variable Arguments
[stderr] Note: Some input files use or override a deprecated API.
[stderr] Note: Recompile with -Xlint:deprecation for details.
[stderr] 6 errors
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':react-native-compressor:compileDebugJavaWithJavac'.
[stderr] > Compilation failed; see the compiler error output for details.
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 3m 8s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
591 actionable tasks: 591 executed
Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

I'm using Expo EAS BUILD service to compile native module

@numandev1
Copy link
Owner

@emmbyiringiro i will investigate this and fix it soon.

@numandev1
Copy link
Owner

@emmbyiringiro can you try 0.5.14 version and let me know?

@numandev1
Copy link
Owner

@emmbyiringiro as you verified me on linkedin. so i am closing this issue.
user having react-native<0.65 can use 0.5.14 version of compressor.

@timges timges mentioned this issue Feb 8, 2022
2 tasks
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

2 participants