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

Encoder Options? #328

Closed
vernzimm opened this issue Nov 9, 2018 · 10 comments
Closed

Encoder Options? #328

vernzimm opened this issue Nov 9, 2018 · 10 comments
Labels

Comments

@vernzimm
Copy link

vernzimm commented Nov 9, 2018

Is it possible to view and/or edit the encoder settings beyond bitrate and fps? It seems like there is more available on the encoder (i.e. compression, format, color format, etc) from looking at the logs. I can't find anything related to this in adb. Really, I am trying to get a bit better quality. For instance, it appears to pass limited dynamic range (blacks appear gray), and the compression is pretty harsh. I have tried with bitrate at 100M etc, but it caps somewhere after 8M. I would rather have a smaller WxH with less compression for the same bitrate.

Just curious to know your thoughts about if it is possible. Here is some of the log relating to encoder. Thanks for this project 👍

  • OMX-VENC: Video encode perflock acquired,handle=43409
  • OMX-VENC: Component_init : OMX.qcom.video.encoder.avc : return = 0x0
  • OMX-VENC: set_parameter: metamode is valid for input port only
  • ACodec : [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
  • ACodec : [OMX.qcom.video.encoder.avc] setupVideoEncoder mime(video/avc) colorFormat(7f000789)
  • ACodec : do not know color format 0x7fa30c04 = 2141391876
  • ACodec : do not know color format 0x7f000789 = 2130708361
  • ACodec : width height(1080x1920) stride(1080) sliceHeight(1920)
  • OMX-VENC: ERROR: Unsupported H.264 level= 0
  • ACodec : bitrate(8000000) framerate(60.000000) compressionFormat(7)
  • OMX-VENC: ERROR: Unsupported H.264 level= 0
  • ACodec : setupAVCEncoderParameters with [profile: Baseline] [level: Level1]
  • ACodec : [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
  • ACodec : setupVideoEncoder succeeded
  • ACodec : do not know color format 0x7f000789 = 2130708361
  • OMX-VENC: Does not handle dataspace request
  • OMX-VENC: get_config (dataspace changed): ColorSpace: Recommend 601-limited for RGBA8888
  • OMX-VENC: open Color conv forW: 1080, H: 1920
  • ACodec : dataspace changed to 0x10c10000 (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) (R:2(Limited), S:1(BT709), T:3(SMPTE_170M))
@rom1v
Copy link
Collaborator

rom1v commented Nov 9, 2018

Is it possible to view and/or edit the encoder settings beyond bitrate and fps?

Bitrate and definition (width × height), not framerate (fps).

Framerate is not configurable: a new frame is produced every time the surface is updated on the device (KEY_FRAME_RATE in that case, except maybe for computing the I_FRAME_INTERVAL in number of frames).

For instance, it appears to pass limited dynamic range (blacks appear gray), and the compression is pretty harsh.

Fast (realtime) encoding cannot achieve the quality of slow encoding 😄

It seems like there is more available on the encoder (i.e. compression, format, color format, etc)

I'm not sure other codec parameters deserve to be exposed in scrcpy, but maybe I'm wrong.

I have tried with bitrate at 100M etc, but it caps somewhere after 8M.

Yes.

I would rather have a smaller WxH with less compression for the same bitrate.

Then do that.

scrcpy -m 800
scrcpy -m 1024

@rom1v rom1v added the question label Nov 9, 2018
@vernzimm
Copy link
Author

For instance, it appears to pass limited dynamic range (blacks appear gray), and the compression is pretty harsh.

Fast (realtime) encoding cannot achieve the quality of slow encoding 😄

It seems like there is more available on the encoder (i.e. compression, format, color format, etc)

I'm not sure other codec parameters deserve to be exposed in scrcpy, but maybe I'm wrong.

There is a lot of stuff in here...
https://developer.android.com/reference/android/media/MediaFormat
https://developer.android.com/reference/android/media/MediaCodec

I don't know how much of that is available to you, but for instance, it does include the full/limited color range mode...
https://developer.android.com/reference/android/media/MediaFormat.html#COLOR_RANGE_FULL
and encoder quality...
https://developer.android.com/reference/android/media/MediaFormat.html#KEY_QUALITY

I can't find a static list of encoders... it always seems to say use MediaCodecInfo to get what is available. Possibly different devices or different chip-sets have these hard-coded?

The other option could be... (and I'm speaking with 0% confidence on this, no idea if it's possible haha)
https://github.com/Khang-NT/ffmpeg-binary-android

@rom1v
Copy link
Collaborator

rom1v commented Nov 10, 2018

I don't know how much of that is available to you, but for instance, it does include the full/limited color range mode...
https://developer.android.com/reference/android/media/MediaFormat.html#COLOR_RANGE_FULL

The default is "limited color range". It will not impact what you called "pretty harsh compression" 😉

and encoder quality... https://developer.android.com/reference/android/media/MediaFormat.html#KEY_QUALITY

This key has been added very recently (in API 28) to target a specific "quality" instead of a target bitrate.

The other option could be... (and I'm speaking with 0% confidence on this, no idea if it's possible haha) https://github.com/Khang-NT/ffmpeg-binary-android

We don't need the FFmpeg binary on Android, and not even a FFmpeg lib, since we use MediaCodec, the "native" Android API, which typically uses hardware acceleration, and does not require shipping additional stuff.

@vernzimm
Copy link
Author

The default is "limited color range". It will not impact what you called "pretty harsh compression" 😉

True, it will not impact compression, but it was the first thing I noticed, that the color range was not reaching full black and white. It makes everything look muddy and grey. I think it would have a significant impact on image quality and doesn't involve the encoder/compression/bitrate issue at all. I wish I knew how to do it so I could test it :(

This key has been added very recently (in API 28) to target a specific "quality" instead of a target bitrate.

That is an interesting concept, but I see what you're saying. It would function essentially like the bitrate, the only difference being static quality, variable bitrate instead of static bitrate, variable quality. If the bitrate is limited arbitrarily, then it won't provide any benefit. 🤷‍♂️

We don't need the FFmpeg binary on Android, and not even a FFmpeg lib, since we use MediaCodec, the "native" Android API, which typically uses hardware acceleration, and does not require shipping additional stuff.

I understand what you're saying about MediaCodec. The only reason I suggested it is if it offered more configuration, but yes, very likely it would be slower or offer very marginal improvement with a significant increase in size/complexity.

@luisscripts
Copy link

Also, is it possible to change encoder? I have this
device https://www.devicespecifications.com/en/model/98bd2cec with cooked Lollipop 5.1.1, and i only have 2 video encoders available, OMX.google.mpeg4.encoder and OMX.google.h263.encoder. Would it be possible to use any of these?

@rom1v
Copy link
Collaborator

rom1v commented Jan 23, 2019

@luisscripts It would require to support these codecs on the client. For now, everything is hardcoded for H.264. It will probably support AV1 or HEVC once devices have hardware encoders for them, but probably not old-generation codecs like H.263.

@luisscripts
Copy link

Thanks for the reply! Oddly though, with a Kitkat cooked ROM in the same device i have H.264 Encoder/Decoder, even being able to record video through adb. I guess the Lollipop ROM doesn't have the needed driver for it, as it is cooked...
Nevertheless, excellent piece of software, keep up the good work!

@cagnulein
Copy link

is it possible to add a black & white option from command line parameter?

@rom1v
Copy link
Collaborator

rom1v commented Apr 9, 2020

Ref: #1226 (comment)

@rom1v
Copy link
Collaborator

rom1v commented Oct 27, 2021

Closed by #1325.

@rom1v rom1v closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants