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

Add AV1 decoder in release builds #5644

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Add AV1 decoder in release builds #5644

merged 2 commits into from
Dec 9, 2024

Conversation

rom1v
Copy link
Collaborator

@rom1v rom1v commented Dec 9, 2024

Recent devices have an AV1 encoder (and it works quite well).

On Linux, when building using system libraries, it was already working. But no AV1 decoder was included in release builds.

This PR adds dav1d support to decode AV1 streams.

With my Pixel 8, I can run:

scrcpy --video-codec=av1

I only tested on Linux. Please test on Windows and macOS.

Fixes #4744


Note: @muvaf, could you please check the first commit Remove broken macOS flags related to #5517 (comment).


Binaries:

rom1v added 2 commits December 9, 2024 19:07
Due to a typo (a space was missing before the second '-L'), the
resulting LDFLAGS value was broken:

    "-L/opt/homebrew/opt/zlib/lib-L/opt/homebrew/opt/libiconv/lib"

This proves that the flag was useless. Remove it.

Refs #5517 comment <#5517 (comment)>
PR #5644 <#5644>
Scrcpy supports AV1, but no decoder was provided in binary releases.

Include dav1d:
 - <https://www.videolan.org/projects/dav1d.html>
 - <https://code.videolan.org/videolan/dav1d>

Fixes #4744 <#4744>
PR #5644 <#5644>
@muvaf
Copy link
Contributor

muvaf commented Dec 9, 2024

Both 3.0.2 and the build in the zip file work. Here is what I see when I run otool -L:

> otool -L scrcpy-macos-aarch64-dav1d/scrcpy
scrcpy-macos-aarch64-dav1d/scrcpy:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2503.1.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
	/System/Library/Frameworks/CoreHaptics.framework/Versions/A/CoreHaptics (compatibility version 1.0.0, current version 1.0.0, weak)
	/System/Library/Frameworks/GameController.framework/Versions/A/GameController (compatibility version 1.0.0, current version 11.5.1, weak)
	/System/Library/Frameworks/ForceFeedback.framework/Versions/A/ForceFeedback (compatibility version 1.0.0, current version 1.0.2)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 170.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 343.19.0, weak)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 61123.121.1)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.60.105)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1774.5.3)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2503.1.0)
> otool -L scrcpy-macos-aarch64-v3.0.2/scrcpy
scrcpy-macos-aarch64-v3.0.2/scrcpy:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2503.1.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
	/System/Library/Frameworks/CoreHaptics.framework/Versions/A/CoreHaptics (compatibility version 1.0.0, current version 1.0.0, weak)
	/System/Library/Frameworks/GameController.framework/Versions/A/GameController (compatibility version 1.0.0, current version 11.5.1, weak)
	/System/Library/Frameworks/ForceFeedback.framework/Versions/A/ForceFeedback (compatibility version 1.0.0, current version 1.0.2)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 170.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 343.19.0, weak)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 61123.121.1)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.60.105)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1774.5.3)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2503.1.0)

So it looks like this build relies on /usr/lib/libiconv.2.dylib while 3.0.2 does not.

@muvaf
Copy link
Contributor

muvaf commented Dec 9, 2024

FWIW, I don't have a new Android so I couldn't test the encoder change.

@rom1v rom1v merged commit aca6d30 into dev Dec 9, 2024
@rom1v
Copy link
Collaborator Author

rom1v commented Dec 9, 2024

Thank you for your test 👍

I was able to test on Windows, it also works. 🚀

@LeeBinder
Copy link

Nokia 6.1 (2018) - https://www.gsmarena.com/nokia_6_1-8972.php - with crDroid 11 (Android 15) Beta:

/Users/lee:$/Users/lee/scrcpy-macos-x86_64-dav1d/scrcpy --video-codec=av1
scrcpy 3.0.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  PL2GAR9842318434                device  Nokia_6_1
/Users/lee/scrcpy-macos-x86_64-dav1d/scrcpy-server: 1 file pushed, 0 skipped. 20.6 MB/s (90648 bytes in 0.004s)
[server] INFO: Device: [HMD Global] Nokia Nokia 6.1 (Android 15)
INFO: Renderer: metal
INFO: Texture: 1080x1920
[server] ERROR: Audio capture error
java.io.IOException: Could not read audio: 0
	at com.genymobile.scrcpy.audio.AudioEncoder.inputThread(AudioEncoder.java:107)
	at com.genymobile.scrcpy.audio.AudioEncoder.lambda$encode$1$com-genymobile-scrcpy-audio-AudioEncoder(AudioEncoder.java:209)
	at com.genymobile.scrcpy.audio.AudioEncoder$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
	at java.lang.Thread.run(Thread.java:1012)
/Users/lee:$otool -L /Users/lee/scrcpy-macos-x86_64-dav1d/scrcpy
/Users/lee/scrcpy-macos-x86_64-dav1d/scrcpy:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
	/System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2202.0.0)
	/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
	/System/Library/Frameworks/CoreHaptics.framework/Versions/A/CoreHaptics (compatibility version 1.0.0, current version 1.0.0, weak)
	/System/Library/Frameworks/GameController.framework/Versions/A/GameController (compatibility version 1.0.0, current version 11.2.3, weak)
	/System/Library/Frameworks/ForceFeedback.framework/Versions/A/ForceFeedback (compatibility version 1.0.0, current version 1.0.2)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 24.0.0)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 170.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0, weak)
	/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 341.35.0, weak)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 61040.61.1)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.30.104)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1774.2.3)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2202.0.0)
/Users/lee:$

@rom1v
Copy link
Collaborator Author

rom1v commented Dec 9, 2024

@LeeBinder both with 3.0.2 and these new binaries? (it does not seem related to the change)

And with scrcpy --no-audio --video-codec=av1?

(Does your device have an AV1 encoder? scrcpy --list-encoders)

@LeeBinder
Copy link

$scrcpy --list-encoders
scrcpy 3.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  PL2GAR9842318434                device  Nokia_6_1
/Applications/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 18.3 MB/s (90640 bytes in 0.005s)
[server] INFO: Device: [HMD Global] Nokia Nokia 6.1 (Android 15)
[server] INFO: List of video encoders:
    --video-codec=h264 --video-encoder=OMX.qcom.video.encoder.avc     (hw) [vendor]
    --video-codec=h264 --video-encoder=c2.android.avc.encoder         (sw)
    --video-codec=h264 --video-encoder=OMX.google.h264.encoder        (sw) (alias for c2.android.avc.encoder)
    --video-codec=h265 --video-encoder=OMX.qcom.video.encoder.hevc    (hw) [vendor]
    --video-codec=h265 --video-encoder=c2.android.hevc.encoder        (sw)
    --video-codec=av1 --video-encoder=c2.android.av1.encoder          (sw)
[server] INFO: List of audio encoders:
    --audio-codec=opus --audio-encoder=c2.android.opus.encoder        (sw)
    --audio-codec=aac --audio-encoder=c2.android.aac.encoder          (sw)
    --audio-codec=aac --audio-encoder=OMX.google.aac.encoder          (sw) (alias for c2.android.aac.encoder)
    --audio-codec=flac --audio-encoder=c2.android.flac.encoder        (sw)
    --audio-codec=flac --audio-encoder=OMX.google.flac.encoder        (sw) (alias for c2.android.flac.encoder)
$scrcpy --no-audio --video-codec=av1
scrcpy 3.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  PL2GAR9842318434                device  Nokia_6_1
/Applications/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 54.4 MB/s (90640 bytes in 0.002s)
[server] INFO: Device: [HMD Global] Nokia Nokia 6.1 (Android 15)
INFO: Renderer: metal
INFO: Texture: 1080x1920

@HaYToKoRaZ
Copy link

4090 win 11 dont work

@rom1v
Copy link
Collaborator Author

rom1v commented Dec 11, 2024

@HaYToKoRaZ What do you mean? What's the error?

@LeeBinder
Copy link

LeeBinder commented Dec 11, 2024

your equanimity and patience with his "bug report" is admirable

@aoy2024
Copy link

aoy2024 commented Dec 13, 2024

After using AV1, I feel that the bandwidth and system resource occupation have been reduced, and it is a little smoother, which is good

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.

5 participants