Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 29th, 2012, 08:02 AM
Donovan4319 Donovan4319 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 4 Donovan4319 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 33 sec
Reputation Power: 0
AVI Stream to Blob

Hi All

I was wondering if it is possible to save a video stream directly into a BLOB field?

I can capture the video stream and write portions of it to a Memory stream, this then needs to be written to the Blob, but i need to somehow write multiple buffers to the one Blob field because I will only be buffering a very small amount at a time.

Is this even possible or should I just write the stream to file and then write the file to blob?

Reply With Quote
  #2  
Old October 17th, 2012, 04:10 AM
nagysz nagysz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 200 nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 11 h 19 m 28 sec
Reputation Power: 13
Quote:
Originally Posted by Donovan4319
Hi All

I was wondering if it is possible to save a video stream directly into a BLOB field?

I can capture the video stream and write portions of it to a Memory stream, this then needs to be written to the Blob, but i need to somehow write multiple buffers to the one Blob field because I will only be buffering a very small amount at a time.

Is this even possible or should I just write the stream to file and then write the file to blob?



No need to write to file, you can copy directly from stream to BLOB. The "how" depends on what language (and what components) are you using. I tried this in Delphi and PHP.

Reply With Quote
  #3  
Old October 18th, 2012, 08:51 AM
emailx45 emailx45 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 44 emailx45 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 7 m 32 sec
Reputation Power: 5
Thumbs up

See as you can READ and Write data (in files) em MemoryStream or FileStream, and, try to use in your code.

For red portion of data in BLOB (Binary type), you can "catch" by using the method SEEK and look the HELP by another funcions, procedure and methods by Stream access.

Read one file PDF using gtPDFDocument component and using MemoryStream and post to dataset
-------------------------------------------------
procedure TForm1.SavetoBlobClick(Sender: TObject);
var
blob: TBlobStream;
TempStrm: TMemoryStream;
begin
// Create a blob stream for writing
blob := YourDataset.CreateBlobStream(YourDataset.FieldByName('YOUR_BLOB_FIELD_NAME'),bmWrite);
try
// Move to the beginning of the blob stream for read operations
blob.Seek(0, soFromBeginning);
// Create a memory stream
TempStrm := TMemoryStream.Create;
// Load a PDF document
gtPDFDocument1.LoadFromFile('C:\Input.pdf');

// Steps for modifying the PDF omitted.

// Save the PDF document to the stream
gtPDFDocument1.SaveToStream(TempStrm);

// Move to the beginning of the memory stream for read operations
TempStrm.Position := 0;
// Copy the stream to the blob
try
blob.CopyFrom(TempStrm, TempStrm.Size)
finally
TempStrm.Free
end;
finally
blob.Free
end;
end;


Read one file to MemoryStream and post to dataset
---------------------------------
if (OpenPictureDialog1.Execute) then
begin
MemoryStream := TMemoryStream.Create;
MemoryStream.Position := 0;
MemoryStream.LoadFromFile( OpenPictureDialog1.FileName);
MemoryStream.Position := 0;

ClientDataSet1YOURBLOBFIELD.LoadFromStream(MemoryS tream);

ClientDataSet1.Post;
ClientDataSet1.ApplyUpdates(0);

MemoryStream.Free;

---------------------------------
procedure TfrmMain.btLoadMemoClick(Sender: TObject);
var
FileStream: TFileStream;
BlobStream: TStream;
begin
if (odBlob.Execute) then
begin
tVenues.Edit;
try
BlobStream := tVenues.CreateBlobStream(tVenues.FieldByName('Remarks'),bmWrite);
FileStream := TFileStream.Create(odBlob.FileName,fmOpenRead or fmShareDenyNone);
BlobStream.CopyFrom(FileStream,FileStream.Size);
FileStream.Free;
BlobStream.Free;
tVenues.Post;
except
tVenues.Cancel;
end;
end;
end;

procedure TfrmMain.btSaveMemoClick(Sender: TObject);
var
FileStream: TFileStream;
BlobStream: TStream;
begin
if (sdBlob.Execute) then
begin
FileStream := TFileStream.Create(sdBlob.FileName,fmCreate);
BlobStream := tVenues.CreateBlobStream(tVenues.FieldByName('Remarks'),bmRead);
FileStream.CopyFrom(BlobStream,BlobStream.Size);
BlobStream.Free;
FileStream.Free;
end;
end;

procedure TfrmMain.btLoadImageClick(Sender: TObject);
var
FileStream: TFileStream;
BlobStream: TStream;
begin
if (odBlob.Execute) then
begin
tVenues.Edit;
try
BlobStream := tVenues.CreateBlobStream(tVenues.FieldByName('Venue_Map'),bmWrite);
FileStream := TFileStream.Create(odBlob.FileName,fmOpenRead or fmShareDenyNone);
BlobStream.CopyFrom(FileStream,FileStream.Size);
FileStream.Free;
BlobStream.Free;
tVenues.Post;
except
tVenues.Cancel;
raise;
end;
end;
end;

procedure TfrmMain.btSaveImageClick(Sender: TObject);
var
FileStream: TFileStream;
BlobStream: TStream;
begin
if (sdBlob.Execute) then
begin
FileStream := TFileStream.Create(sdBlob.FileName,fmCreate);
BlobStream := tVenues.CreateBlobStream(tVenues.FieldByName('Venue_Map'),bmRead);
FileStream.CopyFrom(BlobStream,BlobStream.Size);
BlobStream.Free;
FileStream.Free;
end;
end;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > AVI Stream to Blob

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap