Getting .MOV file details in C# - c#

Hello I am working on video files and would like to learn video's length, frame width and height, and total bitrate. I have seen solutions for ID3 tags but they don't seem working for movies(.mov extension)

Find and download/buy ISO/IEC 14496-12 (MPEG-4 Part 12)
The mvhd and tkhd boxes (and possibly others... it's been a while!) will give you the information you're looking for. The MOV file format is quite easy to parse.

Provided that the file is playable within DirectShow, you can build a pipeline for this file and without running it check the pipeline properties to find out details like duration is resolution. This method is not specific to .MOV and works out well for other formats. In C# you typically interface to DirectShow via DirectShow.NET.
See related:
Grab frame from .mov file using DirectShow.net
Getting MP4 File Duration with DirectShow
how to get the duration from a mp4 media file by C#

In my opionion the best way is use of MediaInfo. It not requires any additional codecs installed etc.
See my answer in this post:
unable to load MediaInfo Library

Related

Getting video duration, frame rate and other properties in c#

Is there any easy way to get from original video detailed information as duration and frame rate??
I have to divide originalvideo to single frames and to do it I want to use NReco.VideoConverter but I in the API I could not find function which allows me to get video properties. If there is not possibility to do it, can you recommend me other useful .net wrapper to FFMpeg?
I saw of course Using FFmpeg in .net?
and Solid FFmpeg wrapper for C#/.NET but there are recommended wrappers which are quite old or have only basic functions. I look wrapper which allows me to get details from original video, divide it to single frames (i need to improve quality) and concat it to new one avi or other file of course with audio with possibility to change paramters(resolution, frame rate etc..)
Maybe this can help, it shows a way to get all metadata form a file using Windows Media Format SDK 11:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743789(v=vs.85).aspx

DirectShow .Net camera capture encode output?

recently i have started workin on project of my own which is capturing a camera output using DirectShow .Net. There are few problems that i don't know how ot solve
1) How can i encode the captured stream into H.264 format.I understand i should some how add filter in the filter graph. But i wasn't able to find where and how . Also i was not able to find if there is standart H.264 filter or should i download it form some where? If i need to download it can it just be a dll to wich i add reference or should it be installer?
2) Is there a way to save the captured output into a memory object, some kind of stream or it can only be written to file?
Best Regards,
Iordan
You're can use commercial software from VisioForge or Viscomsoft.
AForge potencial problem - no audio during capture, only video. Also output formats is a very limited. But - it's free and open source, if you're have any DirectShow experiense you can add audio support.
You will need to use something like FFMpeg or Handbrake. Check out http://vidcoder.codeplex.com/.
AForge also has some video editing abilities and you can also pass filters to it. There are also several FFMpeg C# wrappers you could use such as https://github.com/crazyender/FFMPEG.net
You should use AForge.net. All of the hard work is done for you already. Use VideoFileWriter http://www.aforgenet.com/framework/docs/html/4ee1742c-44d3-b250-d6aa-90cd2d606611.htm. I appears that the AForge framework uses FFMpeg under the hood as well (See AForge.Video.FFMPEG namespace). You just create a writer and pass it the bitmap/frame writer.WriteVideoFrame(bitmap);
You should fully investigate the video abstractions in AForge. You could save yourself considerable amounts of time.
Example: http://www.aforgenet.com/framework/samples/video.html
1) Yes, You should download encoder filter library. Most of decoders are supplied with free. But encoder is not. If you don't want to pay, you have to find open source Encoder.
And To use at the graphedit program, you should do dll register with that dll file. Or the installer program do this instead. And you also need to check container type like mp4, mkv... In other words you need mux filter to save that in a file. I think someone will link available urls. Sorry I don't have urls now.
2)What is that the means of capture? Is that Movie? or Image?
In case of Image, There are many sample projects and SampleGrabbers. You can save it to both of a file and memory.
In case of Movie, I'm sure your pc memory is not enougth to them with out encoding. Make memory stream and pass it to capture manager.
You can also make a filter in order to customize filter to your needs. All of information are included in Windows SDK samples.

bitmaps to avi file c# .Net

I have a list of Bitmaps, how can I convert it to avi file using c#.net. Or how can we convert a set of images to video file ?
I do not need AVI to "Set of images", but I need "Set of Images" to AVI.
i used avifile wrapper in the past, work nicely
I think you need to use third party libraries
There is AVI File Wrapper or you can use ffmpeg in .NET.
Old question, but I have two tips to achieve it. We're now 2013, but all answers are good from 2004 to 2013. These answers are useful as it seems programmers rarely take the time to work on new encoders solution, and we often rely on the same old DLL and wrappers.
Images to MPEG-1
Based on this code, http://www.codeproject.com/Articles/5834/A-C-MPEG1-Image-Compression-Class, you can write a C# Images to MPEG-1 class compatible on any platform using C#.
Images to AVI
Convert just an image with 24 bits color (try to use a gradient generator to have the maximum number of colors) to a full frame AVI using ffmpeg. Take an hexadecimal editor, check how the header of the AVI is, and how the single image has been placed in the AVI. Now do it with two images. Check the header. Refer to the specification to know which value use in the header. You'll see you can easily build a Images to AVI from scratch without any wrapper, and use it on any platform.
Both are codes from scratch.
You can check out a simple library for writing AVI files that I've coded to use in my projects.
https://sharpavi.codeplex.com/
The sources include a sample screencast app which can be easily adapted to get the bitmaps from files if you need it.

Programmatically get video duration

I'd need to get the video duration of a mp4 video (video format AVC)
I'm using DirectShowLib 2.1
I downloaded a couple of codecs but I'm still getting code -2147220891 (an error code that I don't know what it means) doing
graphBuilder.RenderFile(filePath, null);
Any idea how to get the duration of this kind of video?
-2147220891 is 0x80040265 in hex. A search for that error code revealed this thread
0x80040265 isn't really "unknown". Strictly, it is VFW_E_UNSUPPORTED_STREAM, which means that your AVI files contain at least one stream (e.g., the video) that you do not have the right codec for.
So it looks like you still haven't found the right codec.
Does the file play in Windows Media Player or VLC (for example)?
If you just need the duration of a file, you can try using IMediaDet. I have an example of usage here: http://wpfmediakit.codeplex.com/SourceControl/changeset/view/41623#245585

Video Conversion to WMV

A project I am currently working on at work requires the ability to convert videos from other formats to the WMV format. We need to be able to convert virtually any video format that is commonly used to a WMV format. I am looking for a solution allot like On2's flix engine converts other video types to .flv videos. I am aware of the encoder that windows offers, but it has a very limited list of video types that it can convert from. Please let me know if you have any suggestions or opinions, or recommendation of software I can use to do this. I need to be able to do the conversions in batch and I need to be able to do them programmatically with C#.
Have you had a look at ffmpeg?
It seems to be at the core of many open source video conversion utilities, so I imagine you could use it in the scenario you describe.
SUPER, the name is really covering the load!
Well, first you have to be able to decode the file format. You need to set this up with directshow, which is very hard to work with. You can take a look at the mediaportal project for a directshow file player written in C#. Instead of using the video renderer at the end of the directshow graph, you would reencode the video and audio and mux them into a .wmv file. This is a very involved project to get right. You essentially have to mimic a player's ability to play any format and handle failure.
I've been very satisfied using Quick Media Converter.

Categories

Resources