Comments (6)
I solved the problem in a different way, I already knew that I needed the gm installed but I was not getting for several days save the image file, now with this solution below I got it correctly!
it was something related to strem.pipe - I had not thought of this solution before.
NOTE: You need to make the documentation clearer as it is very superficial about what procedures are needed - I will version readme.md
SOLUTION:
client.screencap(POINTER['id']).then(function(stream) { stream.pipe(fs.createWriteStream("./public/screencaps/"+POINTER['id']+".png")); });
from adbkit.
It's just a PNG stream, save it like any other stream in Node. You should be able to just:
var fs = require('fs')
client.screencap(device.id).then(function(stream) {
fs.writeFileSync('screenshot.png', stream) // Synchronous - bad!
})
If it doesn't work then there may be some kind of a bug in there.
Preferably you'd replace the synchronous call with a Promise-wrapped asynchronous version, but that's a task for you.
from adbkit.
Guys, I'm not able to use the screencap function - when I try to use stream on console.log I just see a LineTransform object and when I try to save, no images are received. Only one 15kb file is generated.
GENERATE THIS:
LineTransform {
savedR: null,
autoDetect: false,
transformNeeded: true,
skipBytes: 1,
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
paused: true,
emitClose: true,
autoDestroy: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
_events:
[Object: null prototype] {
prefinish: [Function: prefinish],
unpipe: [Function: onunpipe],
drain: [Function: pipeOnDrainFunctionResult],
error: [Function: onerror],
close:
{ [Function: bound onceWrapper] listener: [Function: onclose] },
finish:
{ [Function: bound onceWrapper] listener: [Function: onfinish] } },
_eventsCount: 6,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 1,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree:
{ next: null,
entry: null,
finish: [Function: bound onCorkedFinish] } },
writable: true,
allowHalfOpen: true,
_transformState:
{ afterTransform: [Function: bound afterTransform],
needTransform: true,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: 'buffer' } }
Could you give me some help?
from adbkit.
You need to actually read data from stream.
You are printing out a stream object, not its contents.
from adbkit.
thanks a lot @joaomirandasa it helped to solve my problem as well :)
from adbkit.
`
// here, I am hard coding the IP address of android device in hostid variable
// function to capture screenshot
function capture(){
client.screencap(hostid)
// returned promise is a PNG stream 'stream'
.then(function(stream) {
stream.pipe(fs.createWriteStream("./" + hostid + ".png"))
console.log('saving screenshot in the current directory..')
})
.catch(function(err){
console.error(err)
})
}
// call capture function with 2 seconds delay
setTimeout(capture , 2000);
`
from adbkit.
Related Issues (20)
- Can't use "bugreport xx.zip" with a mobile phone with adbkit HOT 4
- Add option to install APKs with all runtime permission granted automatically HOT 2
- Minicap and Minitouch in my personal project HOT 1
- Pushed file mode is not set successfully HOT 1
- sync.pull() HOT 1
- Please release a new version with #127 to npm HOT 3
- Error Unhandled rejection FailError: Failure: 'device still authorizing' HOT 2
- This project is no longer maintained HOT 1
- client .trackDevices() is not working HOT 2
- adb connect api issue
- sync mkdir
- install process
- Request node-forge version up
- use adbkit run shell auto stop
- @devicefarmer/adbkit@2
- "\"/system/bin/sh: echo 111: inaccessible or not found\\n\""
- I will run client.framebuffer is not working. HOT 1
- Calling cancel doesn't work on PullTransfer HOT 1
- Can this tool support the openharmony hdc
- wait for device without serial no
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adbkit.