Throw new NotImplementedException("ConvertMediaExtractorSampleFlagsToMediaCodecBufferFlags") Īs far as I can tell is, it takes every frame of the video at the point of the first cut and put every following frame into a buffer until the point of the end cut. There is a possiblity to use FFMpeg, but you need to compile this specially for your platform. Private MediaCodecBufferFlags ConvertMediaExtractorSampleFlagsToMediaCodecBufferFlags(MediaExtractorSampleFlags mediaExtractorSampleFlag)Ĭase MediaExtractorSampleFlags.Encrypted: xamarin.android Share Improve this question Follow edited at 6:26 HansElsen 1,611 5 27 44 asked at 11:27 Jamie 353 7 19 Add a comment 1 Answer Sorted by: 0 Good news, because I just solved the problem. Private string GetOutputPath(string inputPath) then adding the "_trimmed" string between both Splits the string at the dot, separating the file name and the extension. Swallow the exception due to malformed source.Ĭonsole.WriteLine("The source video file is malformed") Muxer.WriteSampleData(indexDict, dstBuf, bufferInfo) If (bufferInfo.Size 0 & bufferInfo.PresentationTimeUs > (endMs * 1000))Ĭonsole.WriteLine("The current sample is over the trim end time.") īufferInfo.Flags = ConvertMediaExtractorSampleFlagsToMediaCodecBufferFlags(extractor.SampleFlags) MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo() īufferInfo.Size = extractor.ReadSampleData(dstBuf, offset) file or exceed the end time of the trimming.īyteBuffer dstBuf = ByteBuffer.Allocate(bufferSize) for copying each sample and stop when we get to the end of the source Copy the samples from MediaExtractor to MediaMuxer. Set up the tracks and retrieve the max buffer size for selectedĭictionary indexDict = new Dictionary(trackCount) įor (int i = 0 i bufferSize ? newSize : bufferSize Įxtractor.SeekTo(startMs * 1000, MediaExtractorSeekTo.ClosestSync) Muxer = new MediaMuxer(outputPath, MuxerOutputType.Mpeg4) String outputPath = GetOutputPath(inputPath) Set up MediaMuxer for the destination. MediaExtractor extractor = new MediaExtractor() Set up MediaExtractor to read from the source. I translated it to C# and so far it works flawlessly: public string Trim(int startMs, int endMs, string inputPath) NET wrapper can convert video file from C code, add watermark to video, transcode live streams, get video thumbnails, create video from images. I did indeed find an android java example on stackoverflow.
0 Comments
Leave a Reply. |