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

Error During Video Compression #1072

Open
abdlkdrisiktan opened this issue Nov 26, 2024 · 3 comments
Open

Error During Video Compression #1072

abdlkdrisiktan opened this issue Nov 26, 2024 · 3 comments
Labels
android Affect Android platform needs-more-details We need more details to understand what the problem is v6.0

Comments

@abdlkdrisiktan
Copy link

abdlkdrisiktan commented Nov 26, 2024

Hello,

I encounter an error while compressing a video on my Android device running version 13. Below is the configuration I use for compression:

"String[] command = {"-y", "-i", videoPath, "-r", "6", "-b:v", "100", "-an", outputPath};"

The process works fine on other devices but fails on Android 13. I cannot figure out the reason. The only error message I receive is as follows

13:44:41.475  E  [vost#0:0/h264_mediacodec @ 0x7361c8fb00] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
13:44:41.484  E  Command failed with state COMPLETED and rc 1.null

Expected behavior
The video compression process should complete successfully on Android 13 devices, just as it does on other devices. The output video should have the specified frame rate (6 fps), bit rate (100 kbps), and no audio, saved to the specified outputPath.

No errors or warnings should occur during the process.

Current behavior
On Android 13 devices, the video compression process fails with the following error message:

vost#0:0/h264_mediacodec @ 0x7361c8fb00] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Command failed with state COMPLETED and rc 1.null

Could you please help me understand and resolve this issue?

Thank you,

Environment

  • Platform: Android/`
  • Architecture: arm-v7a, arm-v7a-neon, arm64-v8a, x86, x86_64
  • Version: 6.0.2
  • Source branch: main,
  • Android Studio Koala | 2024.1.1
@tanersener tanersener added needs-more-details We need more details to understand what the problem is android Affect Android platform v6.0 labels Nov 26, 2024
@tanersener
Copy link
Collaborator

We’ve received similar feedback from other developers regarding the h264_mediacodec encoder, suggesting there might be a broader issue. I suggest trying an alternative encoder as a workaround.

@abdlkdrisiktan
Copy link
Author

abdlkdrisiktan commented Nov 27, 2024

I believe that the default configuration value in my application is "h264_mediacodec" based on your previous response.

Considering this, do I need to make a modification in my configuration like the following?

String[] command = {
    "-y", 
    "-i", videoPath, 
    "-r", "24", 
    "-b:v", "1000k", 
    "-c:v", "libx265", 
    "-an", 
    outputPath
};

Should I explicitly specify something like "-c:v", "libx265" or "-c:v", "libx264"?

I did some research online, but I am unsure about one thing: are libx264 and h264_mediacodec the same?

Lastly, I am using this process in mobile application development, and I am not certain whether libx265 is supported by all devices. Does libx265 work on all devices? The application has a large user base, and it is important for us to ensure compatibility with all of them.

Thank you @tanersener ,

@tanersener
Copy link
Collaborator

Selecting a video codec and an encoder for that codec is not a simple question to answer. Several factors need to be considered, such as the user scenario, the encoding objectives, and the encoder's licensing. Unfortunately, I cannot provide a specific recommendation.

My suggestion is to learn the specifics of the available codecs and encoders to make an informed decision. If you’re unable to find the necessary information, consider asking an AI tool to explain the differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Affect Android platform needs-more-details We need more details to understand what the problem is v6.0
Projects
None yet
Development

No branches or pull requests

2 participants