Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect file contents from android to computer [duplicate]

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.

like image 557
parameter Avatar asked Jul 02 '14 21:07

parameter


2 Answers

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.

like image 65
R.Sicart Avatar answered Oct 20 '22 16:10

R.Sicart


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.

like image 1
scottt Avatar answered Oct 20 '22 16:10

scottt