Create video from still images - c#

I am developing an application that I can get series of Images from IP camera.
Now I want make video from those image. Can anyone help me in creating a video of any format from still images using C#?

You could just use ffmpeg behind the scenes to do so.

Use ffmpeg, http://ffmpeg.org/
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.
Also...
FFmpeg is free software licensed under the LGPL or GPL depending on your choice of configuration options. If you use FFmpeg or its constituent libraries, you must adhere to the terms of the license in question. You can find basic compliance information and get licensing help on our license and legal considerations page.
From the documentation:
For creating a video from many images:
ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi

Related

How can I convert a regular WAV file to a 4bit WAV file using ffmpeg?

I have tried something along the lines of
C:\ffmpeg\ffmpeg -i "Blip_Select2.wav" -c:a wav -sample_fmt u8 "Blip_Select2_8bit.wav"
but I cannot figure out how to access a 4bit conversion.
I am using the audio for a c# project, 4 bit is sufficient and I prefer wav so I won't have to distribute a possibly restricted usage decoder with my files.
Just a heads up that -b 4 with sox seems to use MS ADPCM codec which encodes the difference between samples using 4 bits. If you want to produce a similar result using ffmpeg you can use:
ffmpeg -i sound.wav -codec:a adpcm_ms -f wav sound_4bit.wav
Ok, so I did manage to find a solution for this. It's a great command line utility similar to ffmpeg, called (Sound eXchange) SoX. It can be found here:
http://sox.sourceforge.net/
The command line that achieves converting to 4 bit wav is this:
sox "sound.wav" -b 4 "sound_4bit.wav"
It works perfectly and I did not notice any quality drop as the sampling rate is still 44100, while the size drops to 1/4.
An important note. This works well only if your audio is clean and not recorded too loud, such as correctly recorded voice speech (this is what I am using it for), but also works for music as long as it's not too loud.

FFmpeg autogen in combination with openh264

I'm using FFmpeg autogen to stream images captured from the PC in realtime (60 or 30 fps) to an Android application. Everything is working perfectly as I used the h.264 encoding example provided by FFmpeg autogen.
As far as I have understood FFmpeg autogen is under the LGPL licence and if you are using custom FFmpeg libs compiled under LGPL licence like for example ffmpeg-win32 you can dynamically link to the FFmpeg autogen library without violating the LGPL licence if your project is for example closed source.
So I thought everything would be okay but then I figured out the the h.264 coded is patented in the US and MPEG LA represents the patent holders of AVC/H.264 technologies. If you are using it for free videos you can use h.264 codecs without paying royalties. Nevertheless, my Windows program which is using the encoder is free but my Android application is not free so I guess I have to pay royalties.
I have a few questions regarding this issue:
Which encoder does the FFmpeg autogen use, because as far as I know x264 is under GPL licence. I assume that it will use some internal FFmpeg software encoder?
You can't use any built in standard encoder from FFmpeg (x264 etc.) in projects which don't offer their encoded video stream for free without the need of paying royalties, right?
After some researches I found openh264. This library is built by cisco and they will pay all the royalties but you are not allowed to bundle it with your application, it must be downloaded during the installation process. It also works with FFmpeg but how to I get it to work with FFmpeg autogen? Do I need a custom FFmpeg build which are using the openh264 lib from cisco?
I know this is not a lawyer forum but maybe someone has already dealt with all this issues or could at least answer the questions about FFmpeg autogen. I've searched a while now on the internet but unfortunately it seems that the licencing mechanism with h.264 is not so easy to understand.
I almost forgot about this question but I think I've understood everything now so I will answer it by myself. Maybe it is helpful for someone. In case something is not correct please feel free to correct me.
As far as I have understood FFmpeg autogen is under the LGPL licence
and if you are using custom FFmpeg libs compiled under LGPL licence
like for example ffmpeg-win32 you can dynamically link to the FFmpeg
autogen library without violating the LGPL licence if your project is
for example closed source.
This is indeed correct. FFmpeg autogen is under LGPL licence but if you are just using the provided FFmpeg libraries from zeranoe you are out of luck because all this builds are under GPL licence. This means even if FFmpeg autogen is under LGPL your project still has to be published under GPL as well because of the FFmpeg GPL libraries.
Luckily you can just compile your own custom version of FFmpeg under LGPL but you will miss some features like x264 (basically all features which are not appropriate for LGPL). Compiling a custom version of FFmpeg could be pretty complex, however I found a nice project on github which is called media-autobuild_suite. These scripts basically compile FFmpeg for you and offer many customization features for all kind of FFmpeg features like openh264 and many more. I posted some more details here.
So I thought everything would be okay but then I figured out the the
h.264 coded is patented in the US and MPEG LA represents the patent
holders of AVC/H.264 technologies. If you are using it for free videos
you can use h.264 codecs without paying royalties. Nevertheless, my
Windows program which is using the encoder is free but my Android
application is not free so I guess I have to pay royalties.
I contacted MPEG LA and it doesn't matter if your program is free if you want to be covered by the licence you have to contact MPEG LA and request a licence for your product. You don't have to pay anything though as long as your program will not be downloaded more than 100 000 times per year. You have to provide some reports once a year to MPEG LA which should contain all the information about the downloads. In case you have some questions just contact MPEG LA they are usually very responsive and will reply very fast.
Which encoder does the FFmpeg autogen use, because as far as I know x264 is under GPL licence. I assume that it will use some internal
FFmpeg software encoder?
FFmpeg autogen will use the x264 encoder if you are just using the zeranoe FFmpeg builds. But in general it depends how you have compiled FFmpeg. I compiled FFmpeg with openh264 in order to use openh264 encoder with FFmpeg autogen just load the encoder like this
ffmpeg.avcodec_find_encoder_by_name("libopenh264");
You can't use any built in standard encoder from FFmpeg (x264 etc.) in projects which don't offer their encoded video stream for free
without the need of paying royalties, right?
I don't know if this is correct for any other built in encoder in FFmpeg but you can't use x264 without requesting a licence from MPEG LA. Except openh264 because cisco will pay the royalties for you. Keep in mind that you can't bundle openh264 with your application because otherwise you are responsible to pay the royalties to MPEG LA and not cisco. You have to download openh264 during the installation process of your program or you can provide some download possibilities during the runtime of your program.
After some researches I found openh264. This library is built by cisco and they will pay all the royalties but you are not allowed to
bundle it with your application, it must be downloaded during the
installation process. It also works with FFmpeg but how to I get it to
work with FFmpeg autogen? Do I need a custom FFmpeg build which are
using the openh264 lib from cisco?
Yes, you have to download it during the installation process or during the runtime of your program and yes, you need a custom FFmpeg LGPL build with openh264. You can easily compile your own version of FFmpeg with media-autobuild_suite.
Just one more thing, if you are using FFmpeg under LGPL keep in mind that there are some conditions that you have to consider, you can find them here. That's all for now. I hope these are some useful information.

How do I add many videos programmatically into one video?

I have 1000 videos in MPEG4 H.264 AAC format. They are named 1.mp4, 2.mp5, ..., 1000.mp5. How can I add them programmatically in order into one big video? I suppose I need a video editor that supports a scripting language. I found AviSynth which might be a possibility. I would love to hear your suggestions.
(I am on Windows7 or Linux Mint.)
Probably can be done on Mac using QuickTime Pro and Automator. QuickTime will combine the videos into one. Automator can be used to add all files in a directory into one video in Quicktime.
Bogdan provided the following link: http://trac.ffmpeg.org/wiki/How%20to%20concatenate%20(join,%20merge)%20media%20files. This program works like a charm (on Linux).

Using ffmpeg with C#

First:
well i'm tired of asking the same question, i do know that i can ask about Coding techniques, not just specific problematic points.
Background:
my project is to make a Desktop Recorder, i tried WM Encoder it works but double click don't work at most cases "ex: can't open My Computer! i have to press Enter!", i made a search and it turned out that WM Encoder is the problem and it's matter of waiting a new version to solve this problem of double click.
Now:
this is my previous questions relate to my problem
Re size and compress jpeg
sort files from folder in String[] Array
create a video from a list of JPEG files
Combine images into a movie
So:
How to save list of images in one video using ffmpeg in step by step?
i got this ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi but i have no idea how to use it in my project or where i m going to put this code.

Convert sequence of image files into single video file [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
bitmaps to avi file c# .Net
I am bit struck with an idea to convert the sequence image files into a single video file. I am using dotnet as a platform.How should i proceed. No clear idea...
And more to that need to add audio(mp3) speech while the image sequenceare displayed...
The general idea here is you want to pass your raw images through an encoder and encode the file that way. The encoder will take care of generating all your keyframes and intermediary (P and B) frames as well as generating any necessary decoding metadata that needs to be stored. On top of that running it through an encoding tool such as ffmpeg will also take care of saving the video file in a known container format and properly structuring your video headers. All of this is complicated and tedious to do by hand, not to mention error prone.
Whether you use ffmpeg or some other encoder it's up to you. I suggest using ffmpeg because it has the necessary functionality you need. If you want to do this all in code, ffmpeg is open source and you can wrap the pieces you need in a .net shell and call things that way. Though, keep in mind ffmpeg's licenses if you are developing a distributable application.
This should get you started: Making movies from image files using ffmpeg/mencoder
To add audio check this: https://stackoverflow.com/questions/1329333/how-can-i-add-audio-mp3-to-a-flv-just-video-with-ffmpeg
Now if you want to synchronize the audio and video (lets say the image sequence is people talking and the audio is their speech) you have a much more difficult problem on your hands. At this point you need to properly multiplex audio and video frames based on their durations. FFMpeg probably won't do that well since it will set each image in your video sequence to play at the same duration, which doesn't usually correlate properly with audio frames.

Categories