binarywriter

Faster way to write image to Process.StandardInput.BaseStream

微笑、不失礼 提交于 2019-12-03 13:42:12
问题 Im trying to send a lot of desktop captured images to an encoders (FFmpeg) stdin. The following code example works. the CaptureScreen() function provides an image in 5-10 ms. If I save the image in a MemoryStream it takes almost no time. But I can only save 1 image every 45 ms to proc.StandardInput.BaseStream. public void Start(string bitrate, string buffer, string fps, string rtmp, string resolution, string preset) { proc.StartInfo.FileName = myPath + "\\ffmpeg.exe"; proc.StartInfo.Arguments

Faster way to write image to Process.StandardInput.BaseStream

有些话、适合烂在心里 提交于 2019-12-03 03:40:28
Im trying to send a lot of desktop captured images to an encoders (FFmpeg) stdin. The following code example works. the CaptureScreen() function provides an image in 5-10 ms. If I save the image in a MemoryStream it takes almost no time. But I can only save 1 image every 45 ms to proc.StandardInput.BaseStream. public void Start(string bitrate, string buffer, string fps, string rtmp, string resolution, string preset) { proc.StartInfo.FileName = myPath + "\\ffmpeg.exe"; proc.StartInfo.Arguments = "-f image2pipe -i pipe:.bmp -vcodec libx264 -preset " + preset + " -maxrate " + bitrate + "k

Using BinaryWriter on an Object

你离开我真会死。 提交于 2019-12-01 20:36:48
My application is a small C# database, and I'm using BinaryWriter to save the database to a file which is working fine with the basic types such as bool, uint32 etc. Although I've got a variable that is of type Object (allowing the user to store any data type), however as my application doesn't (nor needs to) know the real type of this variable, I'm unsure how to write it using BinaryWriter . Is there a way I could perhaps grab the memory of the variable and save that? Would that be reliable? Edit: The answer provided by ba_friend has two functions for de/serialising an Object to a byte array,

Create .wav from multiple sine waves and play all at once [closed]

南楼画角 提交于 2019-12-01 14:49:00
I'm wondering if there is a way to adapt the code shown here so that I can basically make an array of beeps and play them all at once. I tried making global MemoryStream and BinaryWriter to use, calculating everything ahead of time for the size but it was even slower than 1 beep at a time and didn't seem to work. After that, I tried writing the MemoryStream to a byte array but that did the same as making globals for the stream/writer. How can I edit the code to get the MemoryStream to hold multiple beeps and play them all at once? Here is a modification to create the song from beeps: void Main

Create .wav from multiple sine waves and play all at once [closed]

北城以北 提交于 2019-12-01 13:32:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I'm wondering if there is a way to adapt the code shown here so that I can basically make an array of beeps and play them all at once. I tried making global MemoryStream and BinaryWriter to use, calculating everything ahead of time for the size but it was even slower than 1 beep at a time and didn't seem to work.

Display JPEG using Response.BinaryWrite

*爱你&永不变心* 提交于 2019-12-01 11:14:07
I'm displaying an image like this: <img src='counter.asp'> counter.asp is doing a hit-counter do determine how often the image was displayed (I'll replace it with a modrewrite URL). The problem: in the counter.asp script I need to send the actual .jpg image to the browser. How could this be done? I suppose I need to load the image through FSO, and then send it using Response.BinaryWrite - any ideas? FSO cannot load a binary file, only text. You will need to use a 3th party component. To read and output binary you can simply use the ADODB.Stream object. See the ADODB.Stream MSDN Library: http:/

Display JPEG using Response.BinaryWrite

若如初见. 提交于 2019-12-01 08:01:16
问题 I'm displaying an image like this: <img src='counter.asp'> counter.asp is doing a hit-counter do determine how often the image was displayed (I'll replace it with a modrewrite URL). The problem: in the counter.asp script I need to send the actual .jpg image to the browser. How could this be done? I suppose I need to load the image through FSO, and then send it using Response.BinaryWrite - any ideas? 回答1: FSO cannot load a binary file, only text. You will need to use a 3th party component. 回答2

C# and .NET: How to serialize a structure into a byte[] array, using BinaryWriter? [closed]

自古美人都是妖i 提交于 2019-11-29 11:24:21
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . How to serialize a rather complex structure into a byte[] array, using BinaryWriter? Update: For this to work, every structure (and sub-structure?) must be decorated with the [Serializable] attribute. I do not need to implement the ISerializable interface, as this is designed to

Why a BinaryWriter closes the outer Stream on disposal, and how to prevent that? (.NET C#)

旧时模样 提交于 2019-11-27 23:26:24
I have one method that receives a Stream to write on it using a BinaryWriter. But when I dispose this BinaryWriter it also closes the stream. Can I leave it undisposed so I can leave my stream open? Just do not call Dispose, use Flush instead, its safe. Dave Van den Eynde As of .NET 4.5, the BinaryWriter class has a new constructor that takes a boolean parameter to indicate whether to leave the stream open or not. Ref: http://msdn.microsoft.com/en-us/library/gg712841.aspx public BinaryWriter( Stream output, Encoding encoding, bool leaveOpen ) Marc Gravell In the case of BinaryWriter , that isn

Why does BinaryWriter prepend gibberish to the start of a stream? How do you avoid it?

跟風遠走 提交于 2019-11-27 04:50:37
I'm debugging some issues with writing pieces of an object to a file and I've gotten down to the base case of just opening the file and writing "TEST" in it. I'm doing this by something like: static FileStream fs; static BinaryWriter w; fs = new FileStream(filename, FileMode.Create); w = new BinaryWriter(fs); w.Write("test"); w.Close(); fs.Close(); Unfortunately, this ends up prepending a box to the front of the file and it looks like so: TEST, with a fun box on the front. Why is this, and how can I avoid it? Edit: It does not seem to be displaying the box here, but it's the unicode character