Since 4.4 KitKat, Android has a shell utility screenrecord to record the Android device screen.
If I connect a physical device with the adb utility over USB, I can do the following:
adb shell screenrecord /sdcard/sample.mp4
adb pull /sdcard/sample.mp4
But if I do the above for an Android emulator, I will get an empty sample.mp4 file.
adb shell screenrecord /sdcard/sample.mp4
adb shell ls -l /sdcard/sample.mp4
-rw-rw---- root sdcard_r 0 2016-06-18 05:37 sample.mp4
If I execute screenrecord directly in a root console in emulator, I see the following:
root@flo:/system/bin # ./screenrecord /sdcard/sample.mp4
[1] + Stopped (signal) ./screenrecord /sdcard/sample.mp4
root@flo:/system/bin #
[1] + Illegal instruction ./screenrecord /sdcard/sample.mp4
Why does screenrecord not work for emulator?
Screenrecord uses MediaCodec API. https://developer.android.com/reference/android/media/MediaCodec.html
To be precise, Screenrecord directly calls the native interface of MediaCodec.
To the best of my knowledge, no emulator supports MediaCodec yet. They all support higher level interface MediaPlayer https://developer.android.com/reference/android/media/MediaPlayer.html.