FFmpegAndroid library rotates video after Compress

后端 未结 1 727
半阙折子戏
半阙折子戏 2021-01-27 02:27

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

相关标签:
1条回答
  • 2021-01-27 02:51

    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
    
    0 讨论(0)
提交回复
热议问题