Slow motion/Fast Motion Videos made with Ffmpeg not getting played in Android 9.0 Pie
I have some videos on which i have applied slow/fast motion using below command(for slow) -
public String slowMo(String starttime, String endtime, String input, String output) {
return "-i " + input + " -preset ultrafast -filter_complex " +
"[0:v]trim=0:" + starttime + ",setpts=PTS-STARTPTS[v1];" +
"[0:v]trim=" + starttime + ":" + endtime + ",setpts=PTS-STARTPTS[v2];" +
"[0:v]trim=start=" + endtime + ",setpts=PTS-STARTPTS[v3];" +
"[0:a]atrim=0:" + starttime + ",asetpts=PTS-STARTPTS[a1];" +
"[0:a]atrim=" + starttime + ":" + endtime + ",asetpts=PTS-STARTPTS[a2];" +
"[0:a]atrim=start=" + endtime + ",asetpts=PTS-STARTPTS[a3];" +
"[v2]setpts=PTS/0.75[slowv];" +
"[a2]atempo=0.75[slowa];" +
"[v1][a1][slowv][slowa][v3][a3]concat=n=3:v=1:a=1[v][a]" +
" -map [v] -map [a] -x264opts keyint=20:min-keyint=20:scenecut=-1 " + output;
}
Videos made using above command are getting played in native player on Android 9.0 but not in your mediaplayer. I have checked in Oreo and Nougat they are working fine. Getting below in logcat.-
2018-11-20 12:24:05.045 8934-1174/com.opkix.android D/MediaPlayer: LAGGING -59369
2018-11-20 12:24:05.055 8934-1174/com.opkix.android D/MediaPlayer: LAGGING -32149
2018-11-20 12:24:05.090 8934-8934/com.opkix.android D/MediaPlayer: onInfo
2018-11-20 12:24:05.141 8934-8934/com.opkix.android D/MediaPlayer: onInfo
2018-11-20 12:24:17.047 8934-1198/com.opkix.android W/AudioTrack: releaseBuffer() track 0xeb261400 disabled due to previous underrun, restarting
2018-11-20 12:24:18.903 8934-1198/com.opkix.android W/AudioTrack: releaseBuffer() track 0xeb261400 disabled due to previous underrun, restarting
2018-11-20 12:24:20.893 8934-1198/com.opkix.android W/AudioTrack: releaseBuffer() track 0xeb261400 disabled due to previous underrun, restarting
20
Here is sample video. You can check in demo apk its not playing getting stuck. https://www.dropbox.com/s/o5lq721zvlwpwd7/emp_20181120_120024.mp4?dl=0
command=new String[]{"-i",orignal_path,"-filter_complex", "[0:v]trim=0:"+startMs+",setpts=PT" + "S-STARTPTS[v1];[0:v]trim="+startMs+":"+endMS+",setpts=2*(PTS-STARTPTS)[v2];[0:v]trim="+endMS+",setpts=PTS-STARTPTS[v3];[0:a]atrim=0:"+startMs+",asetpts=PTS-STARTPTS[a1];[0:a]atrim="+startMs+":"+endMS+",asetpts=PTS-STARTPTS,atempo=0.5[a2];[0:a]atrim="+endMS+",asetpts=PTS-STARTPTS[a3];[v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1", "-preset","superfast","-profile:v","baseline",dest.getAbsolutePath()};