-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Encoding profile option #1226
Encoding profile option #1226
Conversation
@@ -431,6 +466,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) { | |||
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT}, | |||
{"window-borderless", no_argument, NULL, | |||
OPT_WINDOW_BORDERLESS}, | |||
{"codec-profile", required_argument, NULL, 'P'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an advanced option, I would prefer not to consume a "short" option (-P
) for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's totally fine, at first i had a bit of a problem understanding the code so i didn't know if it will work without a short version of the option, its ok to remove it -P and stay with --codec-profile only
Passing an invalid value will not start, and the level is selected only if
the profile is valid.
The possible levels of the codec are decided on runtime depending on the
screen size (i think, not sure) so i dont think its something you need to
pick anyway.
…On Thu, Mar 19, 2020 at 8:55 PM Romain Vimont ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/src/cli.c
<#1226 (comment)>:
> + bool ok = parse_integer_arg(optarg, &value, true, 0, 0x7FFFFFFF, "codec-profile");
+ if (!ok) {
+ return false;
+ }
+
+ switch (value) {
+ case 0: // Automatic
+ case 0x01: // AVCProfileBaseline
+ case 0x02: // AVCProfileMain
+ case 0x04: // AVCProfileExtended
+ case 0x08: // AVCProfileHigh
+ case 0x10: // AVCProfileHigh10
+ case 0x20: // AVCProfileHigh422
+ case 0x40: // AVCProfileHigh444
+ case 0x10000: // AVCProfileConstrainedBaseline
+ case 0x80000: // AVCProfileConstrainedHigh
(oh but then passing another value than the "valid" ones will cause
problems because level is selected automatically)
Maybe we could just pass --codec-profile=value and --codec-level=value?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEPZYSDXX5KXAV2AKYGLRIJTCNANCNFSM4LPQPYUA>
.
|
What if you don't set the level value at all on the |
I didn't test but maybe it will be choosen automatically? The level option
is only from api 23 and not 21 so its something that was added after the
profile
…On Thu, Mar 19, 2020, 10:09 PM Romain Vimont ***@***.***> wrote:
What if you don't set the level value at all on the MediaFormat (only the
profile)?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEP3K3DVBKJOBSCOIFZDRIJ3W3ANCNFSM4LPQPYUA>
.
|
If the level is chosen automatically when not set, then maybe an option |
And in case that the profile is found and the level isn't it will be
choosen automatically, seems right.
…On Fri, Mar 20, 2020, 11:03 AM Romain Vimont ***@***.***> wrote:
If the level is chosen automatically when not set, then maybe an option
--codec-profile accepting any integer and a --codec-level accepting any
integer (ignored if API < 23) would be better?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEP6UTMMV2YK6AFZQ7H3RIMWM3ANCNFSM4LPQPYUA>
.
|
Oh, maybe we could do it very generically: instead of adding codec options when people need them, we could just pass a string of For example:
The String would be passed as-is from the client to the server, and the server would parse it and set the media options. There is an additional detail: the type depends on the key. Some expect an integer value, some others a long, some others a string. Since almost all are integers, I suggest to use integer by default.
What do you think? |
And what if a person doesn't want to specify a level ? Just the profile?
I personally liked it better when it's separated even though they are
related.
…On Fri, Mar 20, 2020, 11:46 AM Romain Vimont ***@***.***> wrote:
Oh, maybe we could do it very generically: instead of adding codec options
when people need them, we could just pass a string of key=value.
For example:
scrcpy --codec-options profile=1,level=2
The String would be passed as-is from the client to the server, and the
server would parse it and set the media options.
There is an additional detail: the type depends on the key. Some expect an
integer value, some others a long, some others a string.
Since almost all are integers, I suggest to use integer by default.
Otherwise, we could specify the type:
--codec-options somekey:string=value
What do you think?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEPYOTL4NI3LXZR44LZDRIM3PHANCNFSM4LPQPYUA>
.
|
Yes, the idea is to pass anything you want from
Scrcpy would not even "understand" that it's a profile or a level, it just sets the value to the |
I don't think i understood what you meant but if you see it fit and more
logical that way its fine :)
…On Fri, Mar 20, 2020 at 12:28 PM Romain Vimont ***@***.***> wrote:
And what if a person doesn't want to specify a level ? Just the profile?
Yes, the idea is to pass anything you want from MediaFormat
<https://developer.android.com/reference/android/media/MediaFormat>.
scrcpy --codec-options key1:value1,key2=value2,...,keyn=valuen
Scrcpy would not even "understand" that it's a profile or a level, it just
sets the value to the MediaFormat instance.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEP5DFPJQ6ZQ7VKUQXRDRINAMZANCNFSM4LPQPYUA>
.
|
Instead of That way, one could pass any present and future codec options as they need. |
@tzah4748 Are you ok for implementing such a |
Yes i'll do it, it will take some time I am quite busy with other work for
now.
I'll commit the changes once ill get to it :)
…On Sat, Mar 21, 2020 at 11:08 PM Romain Vimont ***@***.***> wrote:
@tzah4748 <https://github.com/tzah4748> Are you ok for implementing such
a --codec-options parameter instead of a specific option --codec-profile?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI3FEP6MCKDH3M25ZPI3CCTRIUUDZANCNFSM4LPQPYUA>
.
|
@rom1v Opened a new PR with what we talked about. |
Reopen (see #1325 (review)) |
On my device (after fixing compilation errors), it does not work as is (of course, it works without
Computed max level is 65536 ( Therefore, I think using the max available level for the given profile is not a good strategy 😕 |
Oh I guess it requires changes from #1296? |
OK, thank you for your answer. 👍 If selecting a correct level based on the profile was straightforward, I would be in favor on doing it automatically. However, it seems complicated, so it would add complex code to maintain, and to modify when scrcpy will support other codecs, for a very advanced option. Therefore, I think I prefer that the user provide both profile and level (like #1325). |
@rom1v are you gonna do it yourself or you are waiting a new pull request? |
I have a working branch ( |
@rom1v That's great news! |
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>
Merged #1325 into |
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.