Skip to content

Get thumbnail as byte array from stdout#62

Open
Rob8000 wants to merge 2 commits into
AydinAdn:masterfrom
Rob8000:master
Open

Get thumbnail as byte array from stdout#62
Rob8000 wants to merge 2 commits into
AydinAdn:masterfrom
Rob8000:master

Conversation

@Rob8000

@Rob8000 Rob8000 commented Jan 28, 2017

Copy link
Copy Markdown

I've added a method GetThumbnail that doesn't have an outputFile parameter but instead returns a byte array. This byte array is the result of the thumbnail being piped out from FFmpeg.

} while (lastRead > 0);

this.thumbnailByteArray = ms.ToArray();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not try reading from baseStream all in one go?

byte[] buffer = new byte[baseStream.Length];
baseStream.Read(buffer, 0, buffer.Length);
this.thumbnailByteArray = buffer;

Only reason I could think as to why it wouldn't work is if baseStream.CanSeek is false.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd copied a code snippet. In light of your comments I've changed how the file stream is copied to the memory stream. Thanks.

@royben

royben commented Jun 16, 2017

Copy link
Copy Markdown

Correct me if I'm wrong, but according to your change, the image file will still be created on hard drive.
You are only copying the byte array from that file to memory ?

@Rob8000

Rob8000 commented Jun 17, 2017

Copy link
Copy Markdown
Author

Correct me if I'm wrong, but according to your change, the image file will still be created on hard drive.
You are only copying the byte array from that file to memory ?

No, a file isn't created on the hard drive.

@werddomain

Copy link
Copy Markdown

This can resolve the issue #110
I dont see this on the Nuget Library ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants