Click here to Skip to main content
13,598,099 members
Rate this:
Please Sign up or sign in to vote.
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,
Posted 9-Apr-13 4:04am
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:
I hope this could help you

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 :

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^],[^],[^],[^].

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:[^],[^],[^].

After all, try to find some more:[^].

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,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.180621.3 | Last Updated 5 Jun 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100