I'll try to show how I actually implemented this feature successfully in the next sections. The simplified steps to revert the video are the followingġ.) Seek to the end of video file (MediaExtractor)Ģ.) Seek backwards frame by frame (MediaExtractor) and feed the frames to decoder (MediaCodec)ģ.) Re-encode the frames coming in backwards order again (MediaCodec)Ĥ.) Mux the frames into final video output file (MediaMuxer)Īs you'll see later, there are couple of problems with this approach. MediaExtractors offers the seekTo which was the key method to implement the algorithm for reverting video. This also made Surface initialization easier because I didn't need to use EGL for surface initialization and I just use the surface handed over from MediaCodec encoder. This time I didn't implement any special effects, so I didn't need to use OpenGL. I again used MediaExtractor to get the encoded frames from a video file and I used MediaCodec to encode the frames in reverse order. I used an approach similar to my previous posts. It allows you to connect 2 Android devices through USB OTG and perform many of the tasks that are normally only accessible from a developer machine via ADB directly from your Android phone/tablet. If you you're an Android enthusiast that likes to learn more about Android internals, I highly recommend to check out my Bugjaeger app. If you're interested in video processing using only Android's standard API's (especially MediaCodec), I also recommend to check out my other postsĪdding text or other textures to existing video You can find the sample project at github. I created a little test project that allows to reverse the video in background service. In this post I describe my experience implementing this feature. I know that it's possible to implement this feature using ffmpeg or some other external library, but I was curious how to do this using only the standard Android APIs. I'm planning to use MediaCodec and OpenGL ES also in my future video editing projects and one of the features that I've found would be cool to implement is reversing video, so that it can be played backwards. MediaCodec and OpenGL ES are the main parts that enabled video processing. I used some of these APIs already in my previous projects. Android natively offers APIs that enable video processing and various video effects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |