aos-AVP icon indicating copy to clipboard operation
aos-AVP copied to clipboard

Add playback speed control with audio

Open courville opened this issue 6 years ago • 7 comments

Add capability to speed up video with same audio pitch to watch more in less time.

courville avatar Aug 27 '18 16:08 courville

I hate to be the squeaky wheel here, but how are we doing on this front? I use this feature religiously on every media player I touch, so the lack of the feature here kinda threw me.

PacoBell avatar Jul 01 '20 03:07 PacoBell

Any update on this? This seems like a basic feature in most video players now.

sherpajosh avatar Dec 08 '20 12:12 sherpajosh

Looks like no progress

Thewisem avatar Oct 17 '21 17:10 Thewisem

@Thewisem yes but there is already an issue open no need to have duplicates. Playback speed is on my todo but no time for now to make progress.

courville avatar Oct 17 '21 17:10 courville

FYI implementation in progress. It works using audiotrack setspeed on playbackparams and scaling avos stream parser timestamps. What is still nok: subs are not yet at audioSpeed and on the fly adjustment of the playback speed causes crashes.

courville avatar Aug 25 '22 18:08 courville

Updated status:

  • on the fly playback speed modification KO (causes JNI error not in the audio_interface_audiotrack_java:audiotrack_change_audio_speed)
  • when using shield on samsung soundbar, playback speed has no effect (just player as well) but AudioTrack PlaybackParams are correctly set (setSpeed ok)

courville avatar Sep 01 '22 17:09 courville

Update: on the fly playback is fixed but requires seeking to flush all previous timestamps and causes jump to closest iframe. It could be enhanced by waiting for the next iframe before applying the seek to not cause the time jump effect. Method to achieve this is to be found.

For soundbar problem issue happens when playing multichannel content only and adb shell dumpsys media.audio_flinger reveals that two audio output are created for some reasons cf. logs.zip. Workaround would be to downmix to stereo when changing playback speed (TBD).

Buffer wise in avos_mp_video.c a 2x increase is performed stream_set_buffer_size(video->s, 48). TBD: make it dynamic. And VIDEO_MINDATA_SIZE in stream.h might need to be doubled but would probably cause extra wait at video start using streaming.

courville avatar Sep 10 '22 09:09 courville

The current code crashes with bluetooth headphones on pixel6 phone:

--------- beginning of crash
E/AndroidRuntime( 2550): FATAL EXCEPTION: main
E/AndroidRuntime( 2550): Process: org.courville.nova, PID: 2550
E/AndroidRuntime( 2550): java.lang.IllegalArgumentException: arguments out of range
E/AndroidRuntime( 2550): 	at android.media.AudioTrack.native_set_playback_params(Native Method)
E/AndroidRuntime( 2550): 	at android.media.AudioTrack.setPlaybackParams(AudioTrack.java:2746)
E/AndroidRuntime( 2550): 	at com.archos.medialib.AvosMediaPlayer.setAvSpeed(Native Method)
E/AndroidRuntime( 2550): 	at com.archos.mediacenter.video.player.Player.setAvSpeed(Player.java:914)
E/AndroidRuntime( 2550): 	at com.archos.mediacenter.video.player.PlayerService.setAudioSpeed(PlayerService.java:1471)
E/AndroidRuntime( 2550): 	at com.archos.mediacenter.video.player.PlayerActivity.onAudioSpeedChange(PlayerActivity.java:3162)
E/AndroidRuntime( 2550): 	at com.archos.mediacenter.video.player.AudioSpeedPickerDialog.handleMessage(AudioSpeedPickerDialog.java:84)
E/AndroidRuntime( 2550): 	at com.archos.mediacenter.video.player.AudioSpeedPickerDialog$1.handleMessage(AudioSpeedPickerDialog.java:48)
E/AndroidRuntime( 2550): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 2550): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime( 2550): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime( 2550): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime( 2550): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2550): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime( 2550): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

avos native part with logs:

D/avos_player( 8489): audiotrack_change_audio_speed(0xb40000733f018d40): audio_interface_audiotrack_java:audiotrack_change_audio_speed speed=1.250000
F/.courville.nova( 8489): runtime.cc:676]   native: #14 pc 00000000000ba474  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (???) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #15 pc 0000000000071208  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (stream_set_av_speed+88) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #16 pc 00000000000b3e04  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (avos_mp_video_setavspeed+12) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #17 pc 00000000000b2a78  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (???) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #18 pc 0000000000007700  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavosjni.so (Java_com_archos_medialib_AvosMediaPlayer_setAvSpeed+132) (BuildId: 341983a77e8e98f02f3953b11e34a76d2e587835)
F/.courville.nova( 8489): runtime.cc:676]   native: #03 pc 00000000000079f8  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavosjni.so (???) (BuildId: 341983a77e8e98f02f3953b11e34a76d2e587835)
F/.courville.nova( 8489): runtime.cc:676]   native: #03 pc 00000000000b2d30  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (???) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #12 pc 00000000000ba474  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (???) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #13 pc 0000000000071208  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (stream_set_av_speed+88) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #14 pc 00000000000b3e04  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (avos_mp_video_setavspeed+12) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #15 pc 00000000000b2a78  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavos.so (???) (BuildId: a2207d1a29ffdc82f3334575b0db6621c70b8bc6)
F/.courville.nova( 8489): runtime.cc:676]   native: #16 pc 0000000000007700  /data/app/~~CjnsR9uDcoz1keoYpP1LJw==/org.courville.nova-KtXVarh49QnOLL28Hnz_2Q==/lib/arm64/libavosjni.so (Java_com_archos_medialib_AvosMediaPlayer_setAvSpeed+132) (BuildId: 341983a77e8e98f02f3953b11e34a76d2e587835)

Issue occurs in AudioTrack setPlaybackParams. Using setAudioFallbackMode to mute (mode 2) instead of fail (mode 3), I get:

01-21 15:37:59.758  4975  4975 W AudioTrack: setPlaybackRate(1896) (1.750000, 1.000000) failed (buffer size)

Increasing buffer size to 6x instead of 4x (which should be 2x BTW) makes it work. Something is strange. @phhusson any idea on this one and what is the meaning of 1.0 in setPlaybackRate Android framework warning?

courville avatar Jan 21 '23 10:01 courville

So I guess it has not been implemented yet?

Silthion avatar Jan 02 '24 00:01 Silthion

It is released but not working in passthrough mode or with sound bar.

courville avatar Jan 03 '24 11:01 courville

Apologies for reviving a closed issue, but if this is released and mostly working, how do you actually use it??

I've enabled the experimental setting in Preferences, but still don't see an obvious way to change the speed for a video.

I've tried long pressing a video's tile to get extra options, but the only ones shown by default are "Play", "Mark Watched", "Remove from Library", "Get Info", "Delete" and the subtitle options.

kenny1983 avatar Jan 26 '24 18:01 kenny1983

@kenny1983 in nova settings (not under experimental settings) video section you have "Enable playback speed". If enabled a menu will appear on the audio options in the player itself and you can use 0.05x increments.

courville avatar Jan 26 '24 20:01 courville

OK cool, I was expecting it to be in a "Video Options" menu or the like rather than "Audio Options", but thanks for the super fast response and clarification 😁

kenny1983 avatar Jan 27 '24 04:01 kenny1983