Click here to Skip to main content
Rate this: bad
good
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,
SurjithKumar.J
Posted 9-Apr-13 4:04am
Comments
Volynsky Alex at 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 at 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.
Rate this: bad
good
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: 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
  Permalink  
Rate this: bad
good
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.
 
Regards,
Maxim.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 450
1 Sergey Alexandrovich Kryukov 325
2 Shai Vashdi 318
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 9,109
1 OriginalGriff 5,290
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 5 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid