I have a C# app. I have 100 JPEGs (for an example).
I can easily encode this into a video file.
When it has finished encoding on the client app I FTP upload to my server.
It would be 'neater' if I could not write the video file to a disc but instead write it to a memory stream (or array of bytes) and upload via web service perhaps?
I have checked out the ffmpeg documentation but as a C# developer I do not find it natural to understand the C examples.
I guess my first question is it possible, and if so can anyone post an example code in C#? At the moment I am using the process class in C# to execute ffmpeg.
FFmpeg is a free software project that produces libraries and programs for handling and manipulating multimedia data. FFmpeg can handle the entire process of transcoding, video and image manipulation (resizing, denoising, etc.), packaging, streaming, and playback.
This is the input file. FFmpeg can input most container formats natively, including MP4, . ts, MOV, AVI, Y4M, MKV, and many others. This is the output file.
The use of –probesize and –analyzeduration help FFMPEG to recognize the audio and video stream parameters of a file, and while they are by no means necessary, their use can help reduce input processing errors, especially when moving across codecs.
ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.
Your process method is already good, just needs adjustments:
StartupInfo.RedirectStandardOutput = true
and StartupInfo.UseShellExecute = false
.pipe:
, which will make it write to the standard output. Also, since the format cannot be determined from the file name anymore, make sure you use the -f <format>
switch as well. Process.StandardOutput.BaseStream
(.BaseStream
, so the StreamReader
that is .StandardOutput
doesn't mess anything up) while the process is running into your memory stream.Process.StandardOutput.BaseStream
.I coded a thumbnailer a while back (BSD 2-clause), that has actual code that demonstrates this. Doesn't matter if it is an image or a video coming out of ffmpeg in the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With