
- #Ffmpeg android test beginner how to#
- #Ffmpeg android test beginner code#
- #Ffmpeg android test beginner free#
Keep in mind that before using MediaExtractor, you should first find and select the video track inside of your input video file.
#Ffmpeg android test beginner code#
In this post I'll skip some of the initialization code for MediaExtractor and MediaCodec because I already showed it in my previous posts. I'll show how I tried to solve this issue in the next section. It seeks only to a sync sample (or key frame in MediaCodec terminology - a sync frame seems to be a special key frame that also contains video configuration change parameters). MediaExtractor doesn't seek to any kind of sample. The second problem is related to how video encoding and seeking works. This allowed me to seek backwards by popping the exact seek times from this pre-loaded list. So I decided to first go frame by frame by using the MediaExtractor.advance() method, check if current frame is a key frame, and store the exact presentation times of all keyframes in a list. It's possible that I've misread the documentation or made some other mistake, but that approach wasn't working and extractor was behaving the same way as if I would use the SEEK_TO_CLOSEST_SYNC. My expectation was that if I use the SEEK_TO_PREVIOUS_SYNC flag and I decrement the current timestamp slightly, MediaExtractor will automatically find the previous timestamp. My first problem with seeking was that seeking didn't work reliably, if I didn't know the exact timestamp of the sample upfront. The seekTo accepts a timestamp in micro seconds and a flag that specifies the seek mode. MediaExtractor allows to seek to specific sample at a given presentation timestamp.
#Ffmpeg android test beginner free#
If you see some additional issues with my approach, or there's something that could be implemented more efficiently, feel free to comment or send pull requests directly to my github project.


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.
#Ffmpeg android test beginner how to#
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. home/test.c is same result.Android natively offers APIs that enable video processing and various video effects. tmp directory exist, and permission is right. test.o /tmp/test.c arm-eabi-gcc.exe: /tmp/test.c: No such file or directoryĭifference is only file path.

android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-gcc -fPIC -DANDROID -c -o. android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-gcc -fPIC -DANDROID -c -o /tmp/ /tmp/Īrm-eabi-gcc.exe: /tmp/: No such file or directory configure result error! (below config.err file) check_cc
