magicsih / AndroidScreenCaster

Efficient, low-latency Android screen casting with H.264 and WebM encoding via TCP and UDP.
MIT License
198 stars 73 forks source link

casting android screen only shows the first couple frames #6

Closed LuGia1989 closed 2 years ago

LuGia1989 commented 6 years ago

Hello developer,

I'm trying to use your codes for one of our application in which we deploy your application on an Android Virtual Machine and trying to cast any application on the Virtual Machine remotely on a remote PC.
The whole application is kind of working; however, it is casting/displaying only the first couple of frames (h264 format) on the remote PC over the tcp network, then it hang up. We have been debugging for the last couple days without any luck.
Since you are the developer of these codes, can you provide me some helpful information where I can focus and fix this issue.
Very appreciate if you could help me on this issue.

Thanks

Tom

magicsih commented 5 years ago

Maybe, it's too late to reply. Did you figure it out?

moster67 commented 5 years ago

I also have this problem. It shows one frame and then it stops. This is from ffmpeg/ffplay console:

c:\ffmpeg\bin>ffplay -framerate 60 -i tcp://192.168.1.82:49152?listen ffplay version N-85091-g23ae3cc Copyright (c) 2003-2017 the FFmpeg developers built with gcc 6.3.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib libavutil 55. 57.100 / 55. 57.100 libavcodec 57. 88.100 / 57. 88.100 libavformat 57. 70.100 / 57. 70.100 libavdevice 57. 5.100 / 57. 5.100 libavfilter 6. 81.100 / 6. 81.100 libswscale 4. 5.100 / 4. 5.100 libswresample 2. 6.100 / 2. 6.100 libpostproc 54. 4.100 / 54. 4.100 Input #0, h264, from 'tcp://192.168.1.82:49152?listen': 0B f=0/0 Duration: N/A, bitrate: N/A Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 1280x720, 60 fps, 60 tbr, 1200k tbn, 120 tbc nan M-V: nan fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

And this is logcat:

2019-03-13 20:01:38.146 30330-30330/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.github.magicsih.androidscreencaster 2019-03-13 20:01:38.549 30330-30353/? D/libGLESv1: STS_GLApi : DTS, ODTC are not allowed for Package : com.github.magicsih.androidscreencaster 2019-03-13 20:01:38.611 30330-30330/? I/MainActivity: ComponentInfo{com.github.magicsih.androidscreencaster/com.github.magicsih.androidscreencaster.service.ScreenCastService} service is connected. 2019-03-13 20:01:38.632 30330-30330/? V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@9fe30fd nm : com.github.magicsih.androidscreencaster ic=com.android.internal.widget.EditableInputConnection@4d621f2 2019-03-13 20:01:38.662 30330-30330/? V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@b06043 nm : com.github.magicsih.androidscreencaster ic=com.android.internal.widget.EditableInputConnection@f3f96c0 2019-03-13 20:01:42.704 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: ViewPostIme pointer 0 2019-03-13 20:01:42.803 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: ViewPostIme pointer 1 2019-03-13 20:01:42.873 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: setView = android.widget.PopupWindow$PopupDecorView{99c0d08 V.E...... ......I. 0,0-0,0} TM=true MM=false 2019-03-13 20:01:42.887 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: dispatchAttachedToWindow 2019-03-13 20:01:42.916 30330-30330/com.github.magicsih.androidscreencaster V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0 2019-03-13 20:01:42.921 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: Relayout returned: old=[0,0][0,0] new=[0,975][960,1551] result=0x7 surface={valid=true 513528193024} changed=true 2019-03-13 20:01:42.927 30330-30353/com.github.magicsih.androidscreencaster D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface *, egl_color_buffer_format , EGLBoolean) returns 0x3000, [1152x768]-format:1 2019-03-13 20:01:42.927 30330-30353/com.github.magicsih.androidscreencaster D/OpenGLRenderer: eglCreateWindowSurface = 0x7791c70850 2019-03-13 20:01:42.968 30330-30330/com.github.magicsih.androidscreencaster D/AbsListView: in onLayout changed 2019-03-13 20:01:43.011 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: MSG_WINDOW_FOCUS_CHANGED 1 2019-03-13 20:01:43.013 30330-30330/com.github.magicsih.androidscreencaster V/InputMethodManager: Not IME target window, ignoring 2019-03-13 20:01:43.055 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: MSG_RESIZED_REPORT: frame=Rect(0, 975 - 960, 1551) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 2019-03-13 20:01:43.079 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 2019-03-13 20:01:44.335 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: ViewPostIme pointer 0 2019-03-13 20:01:44.435 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: ViewPostIme pointer 1 2019-03-13 20:01:44.436 30330-30330/com.github.magicsih.androidscreencaster D/AbsListView: onTouchUp() mTouchMode : 0 2019-03-13 20:01:44.537 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: Relayout returned: old=[0,975][960,1551] new=[0,975][960,1551] result=0x1 surface={valid=true 513528193024} changed=false 2019-03-13 20:01:44.580 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 2019-03-13 20:01:44.609 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: MSG_WINDOW_FOCUS_CHANGED 0 2019-03-13 20:01:44.630 30330-30353/com.github.magicsih.androidscreencaster I/OpenGLRenderer: prepareTree mLayerUpdateQueue is not empty, size = 1 2019-03-13 20:01:44.630 30330-30353/com.github.magicsih.androidscreencaster I/OpenGLRenderer: name = PopupWindow$PopupBackgroundView, size (960, 576) 2019-03-13 20:01:44.912 30330-30353/com.github.magicsih.androidscreencaster D/OpenGLRenderer: eglDestroySurface = 0x7791c70850 2019-03-13 20:01:44.913 30330-30353/com.github.magicsih.androidscreencaster D/OpenGLRenderer: endAllActiveAnimators on 0x779b6dac00 (DropDownListView) with handle 0x778d47c540 2019-03-13 20:01:44.913 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@1c722ab[PopupWindow:1f65b1c]: dispatchDetachedFromWindow 2019-03-13 20:01:44.913 30330-30330/com.github.magicsih.androidscreencaster D/InputEventReceiver: channel 'd72f770 PopupWindow:1f65b1c (client)' ~ Disposing input event receiver. 2019-03-13 20:01:44.914 30330-30330/com.github.magicsih.androidscreencaster D/InputEventReceiver: channel 'd72f770 PopupWindow:1f65b1c (client)' ~NativeInputEventReceiver. 2019-03-13 20:01:47.558 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: ViewPostIme pointer 0 2019-03-13 20:01:47.631 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: ViewPostIme pointer 1 2019-03-13 20:01:47.643 30330-30330/com.github.magicsih.androidscreencaster D/MainActivity: Start button clicked. 2019-03-13 20:01:47.645 30330-30330/com.github.magicsih.androidscreencaster D/MainActivity: Requesting confirmation 2019-03-13 20:01:47.688 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 2019-03-13 20:01:47.717 30330-30335/com.github.magicsih.androidscreencaster I/zygote64: Do full code cache collection, code=117KB, data=105KB 2019-03-13 20:01:47.717 30330-30335/com.github.magicsih.androidscreencaster I/zygote64: After code cache collection, code=117KB, data=80KB 2019-03-13 20:01:50.388 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 2019-03-13 20:01:50.409 30330-30330/com.github.magicsih.androidscreencaster V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@2ba0c9b nm : com.github.magicsih.androidscreencaster ic=com.android.internal.widget.EditableInputConnection@3f0c838 2019-03-13 20:01:50.409 30330-30330/com.github.magicsih.androidscreencaster I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus 2019-03-13 20:01:50.419 30330-30330/com.github.magicsih.androidscreencaster D/MainActivity: Starting screen capture 2019-03-13 20:01:50.419 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: Starting cast service 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: tcp://192.168.1.82:49152 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: VideoFormat:video/avc 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: Bitrate:4096000 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: ScreenWidth:1280 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: ScreenHeight:720 2019-03-13 20:01:50.420 30330-30330/com.github.magicsih.androidscreencaster I/MainActivity: ScreenDpi:320 2019-03-13 20:01:56.364 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 2019-03-13 20:01:56.419 30330-30353/com.github.magicsih.androidscreencaster D/OpenGLRenderer: eglDestroySurface = 0x7791c6efa0 2019-03-13 20:01:56.432 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x5 surface={valid=false 0} changed=true 2019-03-13 20:01:56.478 30330-30330/com.github.magicsih.androidscreencaster D/ViewRootImpl@827107e[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=false 0} changed=false

I am using a Samsung S7 (with Oreo). FFLay runs on my Win10 computer. FFplay has been approved in the firewall.

Any ideas?

moster67 commented 5 years ago

At the end it worked. I just needed to be patient. However, is it normal that it takes nearly 2 minutes (sometimes more) before screenrecording starts and being displayed by FFPlay? Once it is connected, there is very little lag except for videos.

devggaurav commented 5 years ago

This FFPlay is too slow at starting ,it takes ages to start, can we use something else ? or can we see casting on a particular URL in browser ?

giegiey commented 4 years ago

Why get this error.

C:\Users\CLT-Server>ffplay -framerate 60 -i tcp://192.168.1.22:49152?listen ffplay version N-95216-ge6625ca41f Copyright (c) 2003-2019 the FFmpeg developers

built with gcc 9.2.1 (GCC) 20190918 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfi g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libb luray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enab le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --e nable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable -libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 - -enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --en able-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcode c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 - -enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 35.100 / 56. 35.100 libavcodec 58. 59.101 / 58. 59.101 libavformat 58. 33.100 / 58. 33.100 libavdevice 58. 9.100 / 58. 9.100 libavfilter 7. 61.100 / 7. 61.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 tcp://192.168.1.22:49152?listen: Unknown error0KB sq= 0B f=0/0