I'm using Windows 7 64 bit on my laptop and Android 5.0.1 on my Samsung Galaxy S4 device.
I'm trying to stream my device's screen via adb using following code:
adb shell screenrecord --output-format=h264 - | vlc -
I have vlc v2.2.4
But it doesn't show anything.
But if I use media player classic, which comes with k-lite mega codec pack v12.3.5 with the following code:
adb shell screenrecord --output-format=h264 - | "C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC64\mpc-hc64_nvo.exe" -
it's showing something like my screen, but image is totally broken.
And if I use adb shell screenrecord --output-format=h264 /sdcard/screenrecord.mp4
to record my devices screen, pull it from device and open it with media player classic, then it video is totally fine. However, vlc can't open even in this case.
What might be the problem? Why I can watch recorded videos, but cannot watch streamed video?
And one more follow-up question. I found adb-server's command to get device's screenshot. It's alternative to the adb shell screencap
command. I can use that command via QTcpSocket in Qt framework.
However, I couldn't find adb server alternative to adb shell screenrecord
. In this case I need to use QProcess to run commands and somehow forward output to QMediaPlayer. So far I couldn't succeed in it, cuz as I found QMediaPlayer::setMedia
accepts QMediaSource
or QIODevice
. I found that QProcess is inherited from QIODevice
and tried to supply it as an argument to QMediaPlayer:::setMedia
, but my program exited with error code 1. How can I forward QProcess
's output to QMediaPlayer
?
In order to support the interactive
adb shell
command theshell_service
usespty
. It helps to take care of all interactive user input like cursor key presses, etc. But the side effect of usingpty
is that it mangles binary output of the process. This is why capturing the output ofadb shell screenrecord
on the host side results in a corrupted file. Previously the only way to fix that was to post-process the file to remove those extra characters. But some time ago Google has added another version of theshell
command which does not have the interactive mode and therefore does not need to use thepty
. They called itexec-out
.So in order to capture a file without corruption you should use