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

Codec options #1325

Closed
wants to merge 2 commits into from
Closed

Codec options #1325

wants to merge 2 commits into from

Conversation

tzah4748
Copy link

Introduced options arguments for the Android MediaCodec library.

The original need:
There are some decoders like Broadway that can accept only H.264 Baseline profile streams.
This profile is considered the most generic and is available on most Android devices.
To allow selecting a profile new option has been added to client and server.

@tzah4748
Copy link
Author

tzah4748 commented May 3, 2020

@rom1v ping :)

@rom1v
Copy link
Collaborator

rom1v commented May 3, 2020

@tzah4748 Don't worry, I haven't forgotten, it the next task in my scrcpy TODO list :)

I just took a look, globally, it seems ok 👍

When I have some time, I will look in detail and test. Sorry for the delay.

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worked a bit on it tonight.

I did several changes (codec_options):

  • rebased on current dev
  • split the parsing from the Media format configuration (so that ScreenEncoder do not deal with the specific format of --codec-option)
  • changed the format from key=value[:type] to key[:type]=value (maybe it's just a personal preference, but it seems more logical to me)
  • improved parsing of codec options so that strings could contain anything, including commas (--codec-options 'some_key=a\,b for example, to set a,b to some_key), for completeness
  • added unit test

This feature works, but I initially assumed that setting only the profile without the level would work: #1226 (comment)
I should have tested: it does not.

# works
scrcpy --codec-options profile=1,level=4096
# does not work
scrcpy --codec-options profile=1

I have just read #1226 discussion again, I think I should have read your answers more carefully. You were right: an option --codec-profile is probably better.

So I think I will keep this branch (codec_options) unmerged for now, and I will reconsider your PR #1226 instead. I'm sorry and confused, I made you waste time 😕

I will try to find some time for that soon. For now, I need rest :)

Good night.

for (String pair : codecOptions.split(",")) {
String[] option = pair.split("=");
String key = option[0];
if(format.containsKey(key)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, contrary to what I said in a previous PR, this does not do what I expected (in fact it just test whether we already set the key, so in practice this is always false).

String value = valueAndType[0];
String type = valueAndType.length < 2 ? "" : valueAndType[1].toLowerCase();
if (type.contains("str")) {
format.setString(key, value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could not pass a String containing a ,.

@rom1v rom1v mentioned this pull request May 3, 2020
@rom1v rom1v closed this May 3, 2020
rom1v added a commit that referenced this pull request May 24, 2020
Add a command-line parameter to pass custom options to the device
encoder (as a comma-separated list of "key[:type]=value").

The list of possible codec options is available in the Android
documentation:
<https://d.android.com/reference/android/media/MediaFormat>

PR #1325 <#1325>
Refs #1226 <#1226>

Co-authored-by: Romain Vimont <rom@rom1v.com>
@rom1v rom1v reopened this May 24, 2020
@rom1v
Copy link
Collaborator

rom1v commented May 24, 2020

Merged into dev: 080a4ee

Thank you 👍

@rom1v rom1v closed this May 24, 2020
@ctjose13
Copy link

Can you explain what this function does?
I'm not an expert in codec and settings. but I would love to be able to give more quality to the window and send it to the OBS

@rom1v
Copy link
Collaborator

rom1v commented Jul 15, 2020

@kass507 To increase the quality, just increase the bitrate:

scrcpy -b20m

(This feature just passes raw parameters to MediaFormat, for advanced usage.)

@ctjose13
Copy link

@kass507 To increase the quality, just increase the bitrate:

scrcpy -b20m

This function only works when using low qualities. I have placed above 15 and no more than 12 passes.
And using the software that the factory team brings, it has reached 20 (Xiaomi Pocophone F1)

@maddinmcfly
Copy link

somehow the intel-encoder crashes all the time on my panasonic FZ-A2 and i use the google encoder for that. the intel one is way better. How can i install the broadway encoder to my panasonic tablet to test it?

@rom1v
Copy link
Collaborator

rom1v commented Feb 26, 2021

You can't "install" an encoder, it typically just implements an API to give instructions to an hardware component on your device.

@rom1v rom1v mentioned this pull request Oct 27, 2021
@rom1v rom1v mentioned this pull request Apr 6, 2023
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

Successfully merging this pull request may close these issues.

4 participants