FFmpegAndroid library rotates video after Compress

情到浓时终转凉″ 提交于 2021-02-05 08:11:07

问题


execFFmpegBinary(new String[]{"-y", "-i", path, "-s", "160x120", "-r", "25", "-vcodec", "mpeg4", "-b:v", "150k", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath});

video auto rotate after compress..

is there any solution?

here is lib Link


回答1:


it might be the autorotate issue in FFMPEG and you have to disable autorotate:

ffmpeg -noautorotate -i input.mp4 output.mp4

if this solution doesn't solve your problem, you can get the input video rotation with Android APIs like this:

MediaMetadataRetriever m = new MediaMetadataRetriever();
m.setDataSource(inputVideoFilePath);
String rotation;
if (Build.VERSION.SDK_INT >= 17) {
     rotation = m.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
}

after finding input file's rotation, you have to rotate the output file accordingly as below :

ffmpeg -noautorotate -i input.mp4 -filter:v "rotation*PI/180" output.mp4


来源:https://stackoverflow.com/questions/60752666/ffmpegandroid-library-rotates-video-after-compress

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