How to Compress video file in android

↘锁芯ラ 提交于 2019-12-01 03:24:31

问题


I want to compress video file before uploading to server.I gone through this link How to compress a video to maximum level android, but i did not get an answer. Can anyone help me ??


回答1:


Give this a try

mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));     
mediaRecorder.setVideoEncodingBitRate(690000 );



回答2:


We can compress video using ffmpeg in android.

For integrating FFmpeg in android we can use precompiled libraries like ffmpeg-android.

You can use below command to compress video

String[] command = {"-y", "-i", inputFileAbsolutePath, "-s", "160x120", "-r", "25", "-vcodec", "mpeg4", "-b:v", "150k", "-b:a", "48000", "-ac", "2", "-ar", "22050", outputFileAbsolutePath};

Here,

-y

Overwrite output files without asking.

-i

ffmpeg reads from an arbitrary number of input “files” specified by the -i option

-s

video output size

-r

Set frame rate

-vcodec

Set the video codec.

-b:v

Set the video bitrate

-b:a

Set the audio bitrate

-ac

Set the number of audio channels.

-ar

sets the sampling rate for audio streams if encoded

For detailed explanation and code on using ffmpeg in android to edit videos,check out below ffmpeg video editor tutorial link on my blog which includes compressing video using ffmpeg-

https://androidlearnersite.wordpress.com/2017/03/17/ffmpeg-video-editor/




回答3:


You have to use ffmpeg lib to compress your video:-

ffmpeg -i input.mp4 -acodec mp2 output.mp4


来源:https://stackoverflow.com/questions/24324852/how-to-compress-video-file-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!