Reputation: 5136
I want to read first 1 MB from 14 GB of video file.
What I have tried so far?
fs.open('/tmp/foo.txt', 'r', function(status, fd) {
if (status) {
// debug(status.message)
return
}
var buffer = new Buffer(1024 * 1024);
fs.read(fd, buffer, 0, 1024 * 1024, 0, function(err, num, buffer) {
console.log(num, buffer)
})
I want to some portion of file so that I can extract metadata.
Upvotes: 0
Views: 871
Reputation: 145172
Create a read stream with a start and end.
var stream = fs.createReadStream('file', {
encoding: null,
start: 0,
end: 1024 * 1024
});
Upvotes: 1