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. :)
Related
For my final project in school ( even though I'm not a programmer ) I have to make a program that reads barcodes. I have to use Common Vision Blox.
I got a live feedback from the camera and I'm able to snap it.
But I want to save this picture now, I tried using this method (Saving image to file), but there seems to be a fault. Probably because I don't actually know which reference to use. I'll add my program in pictures.
I would like to save the snap in JPEG or something, so that I call it further in the program to start the barcode recognition.
Hope you guys can help, thanks in advance!
The solution is actually quite simple: The object axCVimage1 has a method Save() and a method SaveImageByDialog(). Use whatever method suits your needs. For saving the current image to a jpg file, simply provide a file name that has the extension 'jpg'. If you need control over the compression ratio and quality, use the the method SaveLossyImage() instead.
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
I'm developing a Windows 8 Store App, I have this problem,
I want the user to add the videos from a file picker and i managed it,
the problem is I want to display the videos images in a GridView,
like snap shot of the video in a certain position, i tried the media element and it's not working
also an image and it doesn't make sense.
There might not be a pure C# solution to this problem. Perhaps SharpDX would let you do that, but I haven't tried and I don't know if it was done before. If you look at these two threads:
http://social.msdn.microsoft.com/Forums/fil-PH/wingameswithdirectx/thread/05731d4f-5b7f-4ed1-8e28-94604655139e
http://social.msdn.microsoft.com/Forums/en/wingameswithdirectx/thread/ffacd05c-6e9e-43bf-b691-99127240730c
-- you should see that there is a TransferVideoFrame method you can use to copy a frame from a video stream to a DirectX texture. The Media engine native C++ video playback sample shows how you can use it natively. If you search for TransferVideoFrame+SharpDX - you can find this sample that uses the SharpDX version of this method in C#. After you transfer that frame to a texture - you can either copy the contents of the texture to a WriteableBitmap using the Map and Unmap methods like here. You can also save it to a file either using BitmapEncoder a here or directly from the DirectX texture to a file using WIC or say SharpDX Toolkit as in here. You will probably want to build a cache of thumbnails to avoid having to process the videos every time you display the list, so saving to a file is something you should do anyway.
Your own solution that you quoted elsewhere that should work for at least some videos:
var thumb = await
storageFile.GetThumbnailAsync(
Windows.Storage.FileProperties.ThumbnailMode.PicturesView,
1000,
Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
I suggest using GetThumbnailAsync(), which works just as well. You don't even need to get the video properties or anything like that. If the StorageFile is loaded, this should work for a normal video of any format.
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
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).