Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.03k stars 10.01k forks source link

Add keyframes and additional video encoder codec settings #4857

Open Uzver123 opened 1 month ago

Uzver123 commented 1 month ago

Please add additional video encoder settings especially the keyframe interval, right now ScrCpy records all-intra videos without any keyframe which is very wasteful in terms of bitrate because bitrate is split across every frame (not compressed at all, each frame same size).

I understand this is probably done to keep resources usage lower on the phone, but not always a desired method. really need ability to specify keyframe interval.

Also need ability to control ISO/exposure etc.

Would be nice if you could add command line to the video encoder so we can pass custom command line options to codec without need to request each individual one as feature.

rom1v commented 1 month ago

right now ScrCpy records all-intra videos without any keyframe

Hmm, no, it is set to 10 seconds: https://github.com/Genymobile/scrcpy/blob/206809a99affad9a7aa58fcf7593cea71f48954d/server/src/main/java/com/genymobile/scrcpy/SurfaceEncoder.java#L17

Would be nice if you could add command line to the video encoder so we can pass custom command line options to codec without need to request each individual one as feature.

This option already exists: --video-codec-options:

    --video-codec-options=key[:type]=value[,...]
        Set a list of comma-separated key:type=value options for the device
        video encoder.
        The possible values for 'type' are 'int' (default), 'long', 'float' and
        'string'.
        The list of possible codec options is available in the Android
        documentation:
        <https://d.android.com/reference/android/media/MediaFormat>

For example:

scrcpy --video-codec-options=i-frame-interval=1

or as a float (since Build.VERSION_CODES.N_MR1):

scrcpy --video-codec-options=i-frame-interval:float=1.5

cf https://developer.android.com/reference/android/media/MediaFormat#KEY_I_FRAME_INTERVAL

Uzver123 commented 1 month ago

Would be nice if you could add command line to the video encoder so we can pass custom command line options to codec without need to request each individual one as feature.

Tested, you correct keyframe is there its just every 20 seconds not 10 in my case and i never waited so long on my test.

This option already exists: --video-codec-options:

Oh nice

Is there way to disable auto focus and or set manual focus distance, i know this is probably not done trough the codec.