#7
Post
by Andredron » Wed Jul 17, 2019 3:27 pm
Video optimization for Android (maximum performance mode)
Additional programs: ffmpeg
To begin with, at the Ren'Py level we set the parameter "config.hw_video = True" in options.rpy, which includes the hardware video rendering mode.
Next comes the optimization of the video itself.
Using the ffmpeg command line, here is an example of a serious optimization:
ffmpeg -i video.mp4 -vcodec libvpx -b: v 3000k -deadline realtime -cpu-used 2 -vf scale = iw / 1.5: -1 -acodec libopus "video2.webm"
The same, but in the bat file (mass production):
for %% a IN (* .mp4) DO ffmpeg -i "%% a" -vcodec libvpx -b: v 3000k -deadline realtime -cpu-used 2 -vf scale = iw / 1.5: -1 -acodec libopus "% % ~ na2.webm"
And parse all the contents:
-i - incoming video
-vcodec libvpx - video codec. Since we have an android, the most productive will be vp8, that is, libvpx.
-b: v 3000k is the bit rate or relative stream rate. To improve performance, we put either as in youtube (720p = 4000k, 1080p = 8000k), or less.
-deadline realtime - set the video processing mode. Real-time results vary greatly from device to device, but performance increases.
-cpu-used 2 - the complexity of the cpu-decoding video. It can be in the range of values from 0 to 5. Already from the 1st, a performance increase begins and up to 5 at the expense of quality damage.
-vf scale = iw / 1.5: -1 is an argument to scale 1920x1080 to 1280x720 and more along the same lines. Resolution plays a big role in decoding, so if you have a short story in FULL HD, then think twenty times if you want to make a separate version for android, so that the phones do not waste downscaling (video picture reduction)
-acodec libopus - audio codec. You can use libvorbis instead of libopus, but libopus will almost certainly weigh less, and it will provide less playback delay.
Well, the last write the output file - "video2.webm"
Android only full video on the entire screen displays.