捕获的帧在服务器中旋转 90 度

Captured frame is rotating 90 degree right in the Server

帧或图像是从 android 移动设备发送的视频中捕获的,已使用 Jcodec(<artifactId>jcodec</artifactId> and <artifactId>jcodec-javase</artifactId> Version 0.2.2) 来捕获java中的图像。一切正常,但显示照片时向右倾斜 90 度。我无法发现在捕获帧或显示帧时正在发生旋转!

在本地服务器 (tomcat7) 中工作正常(图像在 potrait 本身中)但是当我将代码推送到 AWS 时出现了这个问题,它有 tomcat8。下载后,来自 AWS 的图像 (JPEG) 的大小为 28kb,来自本地服务器的为 118kb。

我在这里分享我的代码任何人请告诉我哪里出了问题,任何解决这个问题的链接都会很棒。

帧捕获代码:

int frameNumber = 1;
Picture picture = FrameGrab.getFrameFromFile(file, frameNumber);
BufferedImage bufferedImage = AWTUtil.toBufferedImage(picture);
ImageIO.write(bufferedImage, "jpg", new File(id + File.separator + fileName + "_" + fileName + ".jpg"));

图片显示代码:

public ResponseEntity<Resource> getPhoto(@PathVariable(value = "id") Integer id) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.IMAGE_JPEG);
        String absolutePath = new File(".").getAbsolutePath();
        File file = new File(Paths.get(absolutePath).getParent() + "/" + id);
        if (null != file) {
            FilenameFilter beginswithm = new FilenameFilter() {
             public boolean accept(File directory, String filename) {
                return filename.startsWith("photo");
             }
           };
            File[] files = file.listFiles(beginswithm);
            if (null != files && files.length > 0) {
              Resource resource = null;
              for (final File f : files) {
              headers.set("Content-Disposition", "inline; filename=" + f.getName());
              resource = appContext.getResource("file:"
                              + Paths.get(absolutePath).getParent() + "/" + id + "/" + f.getName());                     
               return new ResponseEntity<>(resource, headers, HttpStatus.OK);
             }
          }
       }
        RecruiterResponseBean resBean = new RecruiterResponseBean();
        resBean.setStatusMessage(Constants.FAILED);
        resBean.setStatusCode(Constants.FAILED_CODE);
        return new ResponseEntity(resBean, HttpStatus.NOT_FOUND);
    }

在android中,您可以使用ExifInterface查看image/video是否有旋转。

ExifInterface exifInterface = new ExifInterface(mFile.getPath());
int orientation = exifInterface.getAttributeInt(TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
Matrix matrix = new Matrix();
switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_90:
        matrix.postRotate(90);
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        matrix.postRotate(180);
        break;
    case ExifInterface.ORIENTATION_ROTATE_270:
        matrix.postRotate(270);
        break;
    default:
        break;
}