So I wrote the following code to get things started:
MediaItem mediaItem = new MediaItem(@"D:\Videos\CANON\20090202\20090202000204.m2ts"); mediaItem.Sources[0].Clips.Add(new Clip(TimeSpan.FromSeconds(49), TimeSpan.FromSeconds(56))); mediaItem.Sources[0].Clips.Add(new Clip(TimeSpan.FromSeconds(159), TimeSpan.FromSeconds(167))); mediaItem.Sources[0].Clips.Add(new Clip(TimeSpan.FromSeconds(290), TimeSpan.FromSeconds(297))); Job job = new Job(); job.MediaItems.Add(mediaItem); job.OutputDirectory = @"C:\output"; job.Encode();
When I ran it the following exception was thrown:
EncodeErrorException was unhandledNow if you look at the timings that I entered for each of the Clips in the media’s ClipCollection you will clearly see that they are indeed each greater than the duration shown in the error message, so what gives!?
A clip's duration is smaller then the min clip duration 00:00:00.0170000.
The fix turned out to be quite simple – and obvious really – but I thought that I’d post the solution because there weren’t any clean hits that came up when I did my own search on the error message. To fix, you simple call Clear() on the ClipCollection before you start adding your own Clip’s to it like so:
MediaItem mediaItem = new MediaItem(@"D:\Videos\CANON\20090202\20090202000204.m2ts"); mediaItem.Sources[0].Clips.Clear(); ... Job job = new Job(); job.MediaItems.Add(mediaItem); job.OutputDirectory = @"C:\output"; job.Encode();
No comments:
Post a Comment