Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable video playback rate on Android

Tags:

android

video

I need to make a video player that can gradually change playback speed from 0 to roughly 200%. It has to be performing very fast, as it will be playing HD movies recorded at high framerates (60 FPS). Lower resolution can be used if impossible to support HD.

The code only needs to run on relatively high end Android tablets with hardware h264 decoder, and ICS (no Jelly Bean available for the target tablets).

I have not found any support for changing video playback rate in the Android system, and I suspect I need to dig pretty deep into the JNI to get there, but would like to ask here first if anyone has some code, suggestions or pointers that can help me.

like image 919
user1519658 Avatar asked Nov 05 '12 14:11

user1519658


People also ask

What is variable speed playback?

The capability of speeding up or slowing down the original speed of audio or video content.

Can you watch Netflix at 1.5 speed on TV?

To adjust the speed of a TV show or movie: Tap on a TV show or movie while it's playing. Select the speed icon and choose the playback speed.


2 Answers

I got android custom player from vitamio. In that, the media player have an option of setplayback speed. ie mMediaPlayer.setPlaybackSpeed(speed); Set video and audio playback speed Parameters: speed e.g. 0.8 or 2.0, default to 1.0, range in [0.5-2]

Please refer the link: http://www.vitamio.org/en/docs/news/2013/0529/19.html

like image 126
arshad Avatar answered Sep 22 '22 06:09

arshad


I have been looking into doing something similar, and here are some of my findings that may be useful to you:

  1. If you have downloaded the android ndk r7 or later, ndk->samples->native-media is a sample project that uses jni to execute a native android media player.
  2. This uses the OpenMAXAL.h library (that comes in the ndk): You will notice an interface called XA_IID_PLAYBACKRATE. Have at the decent reference card, but thin on samples. It sounds like it should do what we want though.
  3. The sample indicates a minSdkVersion = 14, so it should work on your ICS devices.
  4. I tested this on the only ICS+ device available to me, a 16GB ASUS Nexus7 running 4.2 (Jellybean), and I got the following outputs in my log of note (omitting my own debug statements)

    01-15 14:19:33.384: W/libOpenSLES(6037): class MediaPlayer interface 1 requested but unavailable MPH=75
    01-15 14:19:33.384: W/libOpenSLES(6037): Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED)
    01-15 14:19:33.384: A/libc(6037): jni/native-media-jni.c:409: Java_com_example_nativemedia_NativeMedia_createStreamingMediaPlayer: assertion "XA_RESULT_SUCCESS == res" failed
    01-15 14:19:33.384: A/libc(6037): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 6037 (ple.nativemedia)
    

    in the function that loads up a media stream (or file) and creates the native mediaplayer instance. These errors quite pointedly indicate that the feature either isn't supported on my device/decoder, my OS or my file type. I'm not actually sure which one (or combination) it is, but if it's the first one, it probably means there aren't very many devices out there that will support the feature you want. Maybe the Nexus7 is an outlier, but that's still a sizable chunk of the tablet space, unfortunately, and means we can't expect much consistency in other devices.

If anyone follows these notes and has success in getting things to run, do comment - I will keep hacking away at this and try to get this working, and will update with any progress.

like image 41
kOrc Avatar answered Sep 21 '22 06:09

kOrc