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

ERROR: Could not initialize SDL video: No available video device #4361

Closed
2 tasks done
hamadzidani opened this issue Oct 18, 2023 · 15 comments
Closed
2 tasks done

ERROR: Could not initialize SDL video: No available video device #4361

hamadzidani opened this issue Oct 18, 2023 · 15 comments

Comments

@hamadzidani
Copy link

hamadzidani commented Oct 18, 2023

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Debian
  • scrcpy version: [e.g. 1.12.1]
  • installation method: Tried manual build, apt, snap
  • device model: Samsung A04
  • Android version: 13

Describe the bug

scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
ERROR: Could not initialize SDL video: No available video device
ERROR: Could not start adb server

I have installed all the prerequisites as required from the Readme.MD, additionally, I installed dev libraries of x11 and Xorg
The command scrcpy --version shows

scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.0.22 / 2.0.22
 - libavcodec: 58.134.100 / 58.134.100
 - libavformat: 58.76.100 / 58.76.100
 - libavutil: 56.70.100 / 56.70.100
 - libavdevice: 58.13.100 / 58.13.100
 - libusb: - / 1.0.25

I have set scrcpy --display=0 because scrcpy --list-displays shows

scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  R9WTA085GCE                     device  SM_A045F
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 3.2 MB/s (56995 bytes in 0.017s)
[server] INFO: List of displays:
    --display=0    (720x1600)

I also exported with export SDL_VIDEODRIVER=x11 which again the same error occurred

scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
ERROR: Could not initialize SDL video: x11 not available
ERROR: Could not start adb server

Not sure if this has anything to do with adb but adb --version is

Android Debug Bridge version 1.0.41
Version 28.0.2-debian
Installed as /usr/lib/android-sdk/platform-tools/adb

and adb devices

List of devices attached
R9WTA085GCE	device

I tried also over tcpip.

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

From which graphical environment do you start scrcpy?

@hamadzidani
Copy link
Author

hamadzidani commented Oct 18, 2023

From which graphical environment do you start scrcpy?

from Guake Terminal. I also start scrcpy from the desktop entry of docker applications. By the way, the Ubuntu flavor I'm running is called POP!_OS. And it was running a few months ago, I doubt some libraries might be updated or removed and then reinstalled under other versions. I remember I was installed Android Studio then I removed it along with Gradle and other SDKs.

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

echo $XDG_SESSION_TYPE

@hamadzidani
Copy link
Author

echo $XDG_SESSION_TYPE returns x11.

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

OK, and:

echo $DISPLAY

@hamadzidani
Copy link
Author

echo $DISPLAY returns :1

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

Is it correct?

export DISPLAY=:0
scrcpy

Does it work better?

@hamadzidani
Copy link
Author

hamadzidani commented Oct 18, 2023

unfortunately not. Tried with

export DISPLAY=:0
scrcpy

returns the same error

scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
ERROR: Could not initialize SDL: No available video device
ERROR: Could not start adb daemon

Then tried with

export DISPLAY=:1
scrcpy

The same error keeps throwing.

@hamadzidani
Copy link
Author

scrcpy --list-displays
scrcpy 2.1.1 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.1.4:5555                device  SM_A045F
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 1.2 MB/s (56995 bytes in 0.044s)
[server] INFO: List of displays:
    --display=0    (720x1600)

--display=0 means the Android interface display while

echo $DISPLAY
:1

is the display of the Linux system, right?

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

Yes, --display= is the Android display.

Install xeyes, then run:

DISPLAY=:0 xeyes
DISPLAY=:1 xeyes

Does it work?

@hamadzidani
Copy link
Author

hamadzidani commented Oct 18, 2023

the first command says Error: Can't open display: :0 while the latter one opens a small window that has eyes dynamic drawing following the mouse despite the display index being 0 for scrcpy.
If I understand this correctly, something odd with scrcpy which is not setting :1 as the default display.

I couldn't change the display id of scrcpy using scrcpy --display 1 because the previous command scrcpy --list-displays still shows --display=0 (720x1600).

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

while the latter one opens a small window that has eyes dynamic drawing following the mouse

OK, so DISPLAY=:1 is correct.

Forget about scrcpy --display=, this has nothing to do with your X11 display (it's when you plug an external monitor on your Android device or when you configure a virtual display).

Create a file sample.c and compile it:

#include <SDL2/SDL.h>

int main(void) {
    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
        fprintf(stderr, "SDL error: %s\n", SDL_GetError());
        return 1;
    }

    SDL_Quit();

    printf("ok\n");
    return 0;
}

Compile it:

gcc sample.c -lSDL -o sample

And run it:

./sample

What is the result?

@hamadzidani
Copy link
Author

hamadzidani commented Oct 18, 2023

SDL error: No available video device as expected; one should find how to change the default x server to 0 instead of 1

@rom1v
Copy link
Collaborator

rom1v commented Oct 18, 2023

How did you install SDL2? Are you sure it is compiled with x11 support?

@hamadzidani
Copy link
Author

hamadzidani commented Oct 18, 2023

sudo apt install libsdl2-2.0-0 and libsdl2-dev. I followed this answer and the first comment by recompiling SDL2 from the source code. After that, I encountered an Audio driver problem but resolved it with export SDL_AUDIODRIVER=dummy.

[UPDATE]:

I made a mistake by exporting: SDL_AUDIODRIVER=dummy (dummy has no sound output; as a muted audio driver); instead, one should export:
export SDL_AUDIODRIVER=alsa for Linux. But this should work only if ./configure detects alsa as an audio driver:
Audio drivers : disk dummy oss alsa(dynamic)
If alsa wasn't there, then one should install its dev libraries using sudo apt install libasound2-dev
Then proceed to:

./configure
make
sudo make install

to recompile the SDL from the source code.

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

No branches or pull requests

2 participants