I'm executing an adb shell call to create a new image file with ffmpeg. Currently, I save the outputted jpg of the ffmpeg conversion to the device, and then pull the file to the computer using adb pull. I'm wondering if I can cut out having to save it on the android first, and just save it directly to the computer instead.
Here is the code (essentially) I am trying to run:
adb shell "screencap | /data/local/tmp/tools/./ffmpeg -f rawvideo -vcodec mjpeg -q:v 5 -" > C:/Users/User/Desktop/new.jpg
Unfortunately, when I run this, it copies not only the output data of the ffmpeg call, but everything that would have been printed to the adb standard output. So I am left with a jpg file that has all of my image data, but with a bunch of words at the top (the output of the adb shell call).
Thank you.
If you know the beginning string of your jpg file you can pipe it to sed before redirecting to the file:
adb shell "screencap | /data/local/tmp/tools/./ffmpeg -f rawvideo -vcodec mjpeg -q:v 5 - | sed -n ‘/PATTERN/,$p’" > C:/Users/User/Desktop/new.jpg
Sed will match from pattern to the end of file and print only these lines to your jpg file.
If you have a grep utility for your either your Android device or your Windows host, you could pipe the output through a grep -v
command and suppress the extraneous lines. To minimize the number of patterns that you'd need to supply to grep, you could set the ffmpeg logging option to quiet via -loglevel quiet
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With