Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get thumbnail as byte array from stdout #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rob8000
Copy link

@Rob8000 Rob8000 commented Jan 28, 2017

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();
}

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
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
Copy link

royben commented Jun 16, 2017

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
Copy link
Author

Rob8000 commented Jun 17, 2017

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

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