FFmpegAndroid library rotates video after Compress

Bhavin Kevadiya :

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

Rasool Ghana :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=336654&siteId=1