C# manipulating video - c#

i want to take a folder of pictures, and turn it into a slideshow video with music in the background.
i have no idea how to do this, or where to get help, cos this isnt the kind of thing you can search in google.
idk if there are api's for it, or if it can even be done in C#.
maybe ill have to move the project to C++ or something, but first i need to know where the hell to start.
thanks.

This is definitely the kind of thing you can search in Google. Try "creating avi files in C#" and pick one of the answers. I recommend this one from personal experience.
Creating an AVI file is actually pretty easy - you basically just set a frame rate and dump in a bunch of bitmap files, then add a WAV or MP3 file (or files) for the audio, and that's it.
The AVI file can then be played as is, or compressed into an MPEG or whatever (although you won't get much size compression with a slideshow-type video file, you also don't need it as much).

Related

How can I take snapshot from avi file with DirectX in C#?

I'm working on a video player project (or something like that), that can play .avi files.
I wanted to improve it with something "special", so I put a "Take snapshot" button (btnSnapshot) under the playback area, which is a Picture Box (picboxPlayback).
I'm using DirectX.AudioVideoPlayback, and the video file's owner is this Picture Box:
Microsoft.DirectX.AudioVideoPlayback.Video myVideo = new Microsoft.DirectX.AudioVideoPlayback.Video(SelectedVideoPath);
myVideo.Owner = picboxPlayback;
Then I've tried to write the code that takes the snapshot from the current frame and saves it to a JPEG image to a user-defined path, but I've stuck when I realized that "Video" does not have any "TakeSnapshot" or such methods.
I looked on internet for a quick and simple solution, but did'nt find anything, or what I found was so complicated that I did'nt understand it. (probably because I'm too beginner to DirectX)
I don't know if there's even a quick and simple way to do this, but I would be very grateful if you could help me. :)

encoding mp3 or other music files

a bit of background:
this summer, i set myself a programming project,
where i want to make an E-jay clone(a program with simple drag-drop blocks which are little bits of music and beat to make a track)
now i dont really know where to start on the whole encoding music bit.
for example:
how does a sound file work?
how do i transform a piece of a sound file into a universal piece of sound information
how do i create a sound file from scratch
how do i add pieces of sound to a previously newly created sound file
im sorry if i seem like one of those guys that cant use google n stuff. but i have no experience with sound or anything on that part.
programming language: C#
ultimate goal: be able to encode a new mp3 file using small sound files which are inserted on certain points in the file to ultimatly make music
any help is appreciated,
thank you for reading my question.
I think you should check NAudio site - it has lots of examples.
Do some research into the MPEG compression standard, as you'll need to know about decoding as well as encoding. If you are going to be ambitious, maybe look into other audio file types as well.
MP3 Links:
MP3 Format
ISO Draft on the MPEG standard

C# and Audio Generation/Playback

I’m making an audio synthesizer and I’m having issues figuring out what to use for audio playback. I’m using physics and math to calculate the source waveforms and then need to feed that waveform to something which can play it as sound. I need something that can 1) play the waveforms I calculate and 2) play multiple sounds simultaneously (like holding one key down on a piano while pressing other keys). I’ve done a fair bit of research into this and I can’t find something that does both of those things. As far as I know, I have 5 potential options:
DirectSound. It can take a waveform (a short[]) as a parameter and play it as sound, and can play multiple sounds simultaneously. But it won’t work with .NET 4.5.
System.Media.SoundPlayer. It works with .NET 4.5 and has better quality audio than Direct Sound, but it has to play sound from a .wav file and cannot play multiple sounds at once (nor can multiple instances of SoundPlayer). I ‘trick’ SoundPlayer into working by translating my waveform into .wav format in memory and then send SoundPlayer a MemoryStream of the in-memory .wav file. Could I potentially achieve control over the playback by altering the stream? I cannot append bytes to the stream (I tried) but I could potentially make the stream an arbitrary size and just re-write all the bytes in the stream with the next segment of audio data every time the end of the stream is reached.
System.Windows.Controls.MediaElement. I have not experimented with this yet, but from MSDNs documentation I don’t see a way to send it a waveform in memory without saving it to disk first and then reading it; I don’t think I can send it a stream.
System.Windows.Controls.MediaPlayer. I have not experimented with this either, but the documentation says it’s meant to be used as a companion to some kind of animation. I could potentially use this without doing any real (user-perceivable) animation to achieve my desired effect.
An open source solution. I’m hesitant to use an open source solution as I find they are typically poorly documented and not very maintainable, but I am open to ideas if there is one out there that is well documented and can do what I need.
Can anyone offer me any guidance on this or how to create flexible audio playback?
http://naudio.codeplex.com , without a doubt. Mark is a regular here on SO, the product is well alive, there are good code examples.
It works. We built some great stuff with it.

How to get sound portion of an MP4 (video file)?

I am developing a windows phone 7 application and it does video recording. I would like to get the sound portion of the video file (MP4) and do some enhancements on the sound. I believe sound is saved as AAC frames in MP4. (Right?) How can I extract sound of a videa MP4 file?
Since this is a video file, it can be huge file. So uploading to cloud and processing there is not a good option. Since this WP7 application I cannot use unmaged dlls :( Is there a way to do in pure C#? Any open source tools/samples?
Thanks!
MP4 is a container format and realistically the sound portion isn't always AAC. It could be MP3 or any other number of different audio formats. You may be thinking of M4A, which I believe requires either AAC or ALAC.
On the subject of audio extraction, it should be possible to extract the audio from an MP4 using just managed code. You'll have to read up on the MP4 format (here, for example - this question is also worth reading) and then search through the file for the location of the audio and then either copy it to its own buffer or do your manipulations in chunks. Even then, you'll have to be able to recognize when it isn't an audio format that your app won't support.
It's possible that there already exists a .net library that can do all of this but I don't know of any. It's probably not very popular because managed code is definitely not the best angle to approach this from, but considering this is Windows Phone, it is, as you noted, your only avenue of approach.
Good luck!

C# Move video files into folders based on their video frame size.

I have a hard drives dedicated to videos, and I wanted to write a program that would move all my video files into folders based on their video playback size.
I was thinking about having it organized like this.
/HD/1080p/(FileName)/(fileName).ext
/HD/720p/(FileName)/(fileName).ext
(I know that not all video files are 1080 or 720p because of crop, but within +-20 to 30px.)
/SD/(FileName)/(fileName).ext //anything less then 720p
I know you are able to right click on a video file and go to properties then details and see the frame width and frame height, but I'm not sure you can view this information in C#.
I don't know where to start and some information would be awesome. like:
Moving files with c#, renaming them, Viewing file details (frame sizes, file type, name, lenght, etc.) I plan on making a DB on this information but as of right now I just want to move the files into the correct folders.
I have been doing this manually and it's very tedious and time consuming.
Any help would be awesome, Thanks,
Throdne
The best for getting file info properties is to use MediaInfo.dll. There is also c# wrapper available to collect all data you need from video file.
You can obtain media ifo from mediainfo.sourceforge.net
This is multiplatform and can be used on Mono and Linux as well on Windows.
I've put also some information about MediaInfo on following thread: https://stackoverflow.com/questions/9561490...
Your best bet is using something like DirectShow which will handle multiple video formats there is a com+ object you can attach to but on source forge there is a wrapper around the
API
Info on sourceforge
once you have that figured out you can then go
here to figure out how to move files around

Categories