Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating the video player with most of the common controls and additionally i want to add the trimming options by getting the start time and end time from the user. According to that the video has to cut from the original file and save the trimmed video in the new output file. I did the trimming and merging using the ffmpeg by running the command prompt from my application. Is there any way to do it using the directshow!?
If it so what i have to do!?
I am using avi and mp4 container.

Thanks & regards,
SurjithKumar.J
Posted
Comments
Volynsky Alex 6-Jun-13 6:16am    
Hi J.Surjith Kumar!
Transcoding is the conversion of a digital media file, such as a video or audio file, from one format to another. This is usually done by decoding and then re-encoding the file. For example, you might convert a Windows Media file to MP4 so that it can be played on a portable device that supports MP4 format. Or, you might convert a high-definition video file to a lower resolution. In that case, the re-encoded file might use the same codec as the original file, but it would have a different encoding profile.
This quickstart uses the FileOpenPicker class to open a video file from the system. Then it uses the MediaTranscoder class to transcode the video file. Finally, it uses the FileSavePicker class to save the newly encoded file.
A code sample that shows the complete sequence of calls you can find here:
http://msdn.microsoft.com/en-us/library/windows/apps/hh868172.aspx
I hope this could help you

Regards,
Alex.
Volynsky Alex 6-Jun-13 6:49am    
Sometimes, users ask a question about video and audio trimming and then search the utilities that can do this. But what about programmatic implementation of this task? This article will show how it appears from the programmer's position :
http://www.codeproject.com/Articles/24482/DirectShow-Video-and-Audio-Trimming

Regards,
Alex.

Please see this CodeProject article: DirectShow Video and Audio Trimming[^].

I wouldn't personally use DirectShow. I would prefer using open-source library or utility FFmpeg or libavcodec: http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

This is the best library and utility set I ever knew. I could be used just by running the available utility (FFmpeg.exe), programmatically or not, using command-line interface.

Optionally, you can embed is as a library. It's apparently possible with C++, as the library is written on C. Same thing if you need .NET functionality: you can still use the unmanaged library, using it in your C++/CLI mixed-mode (managed + unmanaged) project. You can expose just the functionality you need, in managed "ref" classes; then you can use these classes referencing the resulting module as a usual .NET assembly.

With .NET and without C++/CLI, it can be more complex as it would require using P/Invoke. At the same time, you can find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].

After all, try to find some more: http://bit.ly/VpboUJ[^].

If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).

Good luck,
—SA
 
Share this answer
 
The easiest way to do trim in directshow without any additional filters implementation it's just to set interesting start stop positions via SetPositions method of IMediaSeeking interface before starting the graph.

Regards,
Maxim.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900