获取 com.drew.imaging.ImageProcessingException:MP4、MOV、QT 和 3GP 视频文件不支持文件格式

问题描述 投票:0回答:1

使用

metadata-extractor-2.19.0.jar
,此代码:

Metadata metadata = null;

try {
    metadata = ImageMetadataReader.readMetadata( pathSourceFile.toFile() );
} 
catch(ImageProcessingException ipe) {
    System.out.println("The following exception occured while attempting to read metadata from " + pathSourceFile.toString());
    ipe.printStackTrace(System.out);
    throw ipe;
}
当输入是 MP4、QT、MOV 或 3gp 文件时,

抛出

ImageProcessingException: File format is not supported
。这是一个例子:

The following exception occured while attempting to read metadata from C:\Test Input\Borg.mp4
com.drew.imaging.ImageProcessingException: File format is not supported
    at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:146)
    at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:162)
    at com.mbm.mediaorganizer.DirectoryNameBuilder.getTags(DirectoryNameBuilder.java:182)
    at com.mbm.mediaorganizer.DirectoryNameBuilder.getDirectoryName(DirectoryNameBuilder.java:61)
    at com.mbm.mediaorganizer.RelocateFileVisitor.relocateFile(RelocateFileVisitor.java:114)
    at com.mbm.mediaorganizer.RelocateFileVisitor.visitFile(RelocateFileVisitor.java:96)
    at com.mbm.mediaorganizer.RelocateFileVisitor.visitFile(RelocateFileVisitor.java:1)
    at java.base/java.nio.file.Files.walkFileTree(Files.java:2811)
    at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
    at com.mbm.mediaorganizer.MediaOrganizer.run(MediaOrganizer.java:126)
    at com.mbm.mediaorganizer.MediaOrganizer.main(MediaOrganizer.java:40)

这是 Mediainfo 关于 MP4 文件的说法:

General
Complete name                            : C:\Test Input\Borg.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41)
File size                                : 171 MiB
Duration                                 : 1 min 40 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 14.3 Mb/s
Encoded date                             : UTC 2017-07-28 20:50:07
Tagged date                              : UTC 2017-07-28 20:50:41
©TIM                                     : 00:00:00:00
©TSC                                     : 30000
©TSZ                                     : 1001

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 40 s
Bit rate mode                            : Variable
Bit rate                                 : 13.9 Mb/s
Maximum bit rate                         : 16.0 Mb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.224
Stream size                              : 167 MiB (98%)
Language                                 : English
Encoded date                             : UTC 2017-07-28 20:50:07
Tagged date                              : UTC 2017-07-28 20:50:07
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : mp4a-40-2
Duration                                 : 1 min 40 s
Source duration                          : 1 min 40 s
Bit rate mode                            : Variable
Bit rate                                 : 317 kb/s
Maximum bit rate                         : 349 kb/s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 3.80 MiB (2%)
Source stream size                       : 3.80 MiB (2%)
Language                                 : English
Encoded date                             : UTC 2017-07-28 20:50:07
Tagged date                              : UTC 2017-07-28 20:50:07

为什么我会得到

ImageProcessingException: File format is not supported

java metadata-extractor
1个回答
0
投票

您正在使用电影图像阅读器,对于 mp4,请使用 Mp4MetadataReader 等...

© www.soinside.com 2019 - 2024. All rights reserved.