在 MacOS 命令行上将多页 TIFF 文件夹拆分为帧并合并到电影中

在 MacOS 命令行上将多页 TIFF 文件夹拆分为帧并合并到电影中

我正在使用 FLIR Boson 热成像相机,其“视频”输出由“一秒长”的多页 TIFF 文件序列组成。

帧速率可变,但平均为 8.6 fps。因此,每个 TIFF 最多可包含 9 个单色 16 位图像(示例 TIFF 可在此处下载)。

我想将多页 TIFFS 批量分割成单独的图像 - 首先是为了处理,而且我也可以从它们创建无损视频(使用 FFMPEG)。

但是,我不知道如何提取时间戳完整的各个帧(根据FLIR TIFF 文档它在元数据中记录为Exif.Photo.DateTimeOriginal。但 EXIFTool 不会显示它——请参阅 的输出exiftool -a -G1 -s Boson_Capture.tiff

[ExifTool]      ExifToolVersion                 : 12.30
[System]        FileName                        : Boson_Capture.tiff
[System]        Directory                       : .
[System]        FileSize                        : 5.6 MiB
[System]        FileModifyDate                  : 2022:05:06 16:54:24-04:00
[System]        FileAccessDate                  : 2022:05:06 19:54:06-04:00
[System]        FileInodeChangeDate             : 2022:05:06 19:54:04-04:00
[System]        FilePermissions                 : -rw-------
[File]          FileType                        : TIFF
[File]          FileTypeExtension               : tif
[File]          MIMEType                        : image/tiff
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[IFD0]          ImageWidth                      : 640
[IFD0]          ImageHeight                     : 512
[IFD0]          BitsPerSample                   : 16
[IFD0]          Compression                     : Uncompressed
[IFD0]          PhotometricInterpretation       : BlackIsZero
[IFD0]          FillOrder                       : Normal
[IFD0]          StripOffsets                    : 8
[IFD0]          Orientation                     : Horizontal (normal)
[IFD0]          SamplesPerPixel                 : 1
[IFD0]          RowsPerStrip                    : 512
[IFD0]          StripByteCounts                 : 655360
[IFD0]          XResolution                     : 1
[IFD0]          YResolution                     : 1
[IFD0]          PlanarConfiguration             : Chunky
[IFD0]          ResolutionUnit                  : None
[IFD0]          PageNumber                      : 0 2
[IFD0]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD0]          SampleFormat                    : Unsigned
[IFD1]          ImageWidth                      : 640
[IFD1]          ImageHeight                     : 512
[IFD1]          BitsPerSample                   : 16
[IFD1]          Compression                     : Uncompressed
[IFD1]          PhotometricInterpretation       : BlackIsZero
[IFD1]          FillOrder                       : Normal
[IFD1]          StripOffsets                    : 655662
[IFD1]          Orientation                     : Horizontal (normal)
[IFD1]          SamplesPerPixel                 : 1
[IFD1]          RowsPerStrip                    : 512
[IFD1]          StripByteCounts                 : 655360
[IFD1]          XResolution                     : 1
[IFD1]          YResolution                     : 1
[IFD1]          PlanarConfiguration             : Chunky
[IFD1]          ResolutionUnit                  : None
[IFD1]          PageNumber                      : 1 3
[IFD1]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD1]          SampleFormat                    : Unsigned
[IFD2]          ImageWidth                      : 640
[IFD2]          ImageHeight                     : 512
[IFD2]          BitsPerSample                   : 16
[IFD2]          Compression                     : Uncompressed
[IFD2]          PhotometricInterpretation       : BlackIsZero
[IFD2]          FillOrder                       : Normal
[IFD2]          StripOffsets                    : 1311316
[IFD2]          Orientation                     : Horizontal (normal)
[IFD2]          SamplesPerPixel                 : 1
[IFD2]          RowsPerStrip                    : 512
[IFD2]          StripByteCounts                 : 655360
[IFD2]          XResolution                     : 1
[IFD2]          YResolution                     : 1
[IFD2]          PlanarConfiguration             : Chunky
[IFD2]          ResolutionUnit                  : None
[IFD2]          PageNumber                      : 2 4
[IFD2]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD2]          SampleFormat                    : Unsigned
[IFD3]          ImageWidth                      : 640
[IFD3]          ImageHeight                     : 512
[IFD3]          BitsPerSample                   : 16
[IFD3]          Compression                     : Uncompressed
[IFD3]          PhotometricInterpretation       : BlackIsZero
[IFD3]          FillOrder                       : Normal
[IFD3]          StripOffsets                    : 1966970
[IFD3]          Orientation                     : Horizontal (normal)
[IFD3]          SamplesPerPixel                 : 1
[IFD3]          RowsPerStrip                    : 512
[IFD3]          StripByteCounts                 : 655360
[IFD3]          XResolution                     : 1
[IFD3]          YResolution                     : 1
[IFD3]          PlanarConfiguration             : Chunky
[IFD3]          ResolutionUnit                  : None
[IFD3]          PageNumber                      : 3 5
[IFD3]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD3]          SampleFormat                    : Unsigned
[IFD4]          ImageWidth                      : 640
[IFD4]          ImageHeight                     : 512
[IFD4]          BitsPerSample                   : 16
[IFD4]          Compression                     : Uncompressed
[IFD4]          PhotometricInterpretation       : BlackIsZero
[IFD4]          FillOrder                       : Normal
[IFD4]          StripOffsets                    : 2622624
[IFD4]          Orientation                     : Horizontal (normal)
[IFD4]          SamplesPerPixel                 : 1
[IFD4]          RowsPerStrip                    : 512
[IFD4]          StripByteCounts                 : 655360
[IFD4]          XResolution                     : 1
[IFD4]          YResolution                     : 1
[IFD4]          PlanarConfiguration             : Chunky
[IFD4]          ResolutionUnit                  : None
[IFD4]          PageNumber                      : 4 6
[IFD4]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD4]          SampleFormat                    : Unsigned
[IFD5]          ImageWidth                      : 640
[IFD5]          ImageHeight                     : 512
[IFD5]          BitsPerSample                   : 16
[IFD5]          Compression                     : Uncompressed
[IFD5]          PhotometricInterpretation       : BlackIsZero
[IFD5]          FillOrder                       : Normal
[IFD5]          StripOffsets                    : 3278278
[IFD5]          Orientation                     : Horizontal (normal)
[IFD5]          SamplesPerPixel                 : 1
[IFD5]          RowsPerStrip                    : 512
[IFD5]          StripByteCounts                 : 655360
[IFD5]          XResolution                     : 1
[IFD5]          YResolution                     : 1
[IFD5]          PlanarConfiguration             : Chunky
[IFD5]          ResolutionUnit                  : None
[IFD5]          PageNumber                      : 5 7
[IFD5]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD5]          SampleFormat                    : Unsigned
[IFD6]          ImageWidth                      : 640
[IFD6]          ImageHeight                     : 512
[IFD6]          BitsPerSample                   : 16
[IFD6]          Compression                     : Uncompressed
[IFD6]          PhotometricInterpretation       : BlackIsZero
[IFD6]          FillOrder                       : Normal
[IFD6]          StripOffsets                    : 3933932
[IFD6]          Orientation                     : Horizontal (normal)
[IFD6]          SamplesPerPixel                 : 1
[IFD6]          RowsPerStrip                    : 512
[IFD6]          StripByteCounts                 : 655360
[IFD6]          XResolution                     : 1
[IFD6]          YResolution                     : 1
[IFD6]          PlanarConfiguration             : Chunky
[IFD6]          ResolutionUnit                  : None
[IFD6]          PageNumber                      : 6 8
[IFD6]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD6]          SampleFormat                    : Unsigned
[IFD7]          ImageWidth                      : 640
[IFD7]          ImageHeight                     : 512
[IFD7]          BitsPerSample                   : 16
[IFD7]          Compression                     : Uncompressed
[IFD7]          PhotometricInterpretation       : BlackIsZero
[IFD7]          FillOrder                       : Normal
[IFD7]          StripOffsets                    : 4589586
[IFD7]          Orientation                     : Horizontal (normal)
[IFD7]          SamplesPerPixel                 : 1
[IFD7]          RowsPerStrip                    : 512
[IFD7]          StripByteCounts                 : 655360
[IFD7]          XResolution                     : 1
[IFD7]          YResolution                     : 1
[IFD7]          PlanarConfiguration             : Chunky
[IFD7]          ResolutionUnit                  : None
[IFD7]          PageNumber                      : 7 9
[IFD7]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD7]          SampleFormat                    : Unsigned
[IFD8]          ImageWidth                      : 640
[IFD8]          ImageHeight                     : 512
[IFD8]          BitsPerSample                   : 16
[IFD8]          Compression                     : Uncompressed
[IFD8]          PhotometricInterpretation       : BlackIsZero
[IFD8]          FillOrder                       : Normal
[IFD8]          StripOffsets                    : 5245240
[IFD8]          Orientation                     : Horizontal (normal)
[IFD8]          SamplesPerPixel                 : 1
[IFD8]          RowsPerStrip                    : 512
[IFD8]          StripByteCounts                 : 655360
[IFD8]          XResolution                     : 1
[IFD8]          YResolution                     : 1
[IFD8]          PlanarConfiguration             : Chunky
[IFD8]          ResolutionUnit                  : None
[IFD8]          PageNumber                      : 8 8
[IFD8]          Software                        : 7CTiff - FLIR Systems, Indigo Operations
[IFD8]          SampleFormat                    : Unsigned
[Composite]     ImageSize                       : 640x512
[Composite]     Megapixels                      : 0.328

我尝试过的所有分割 TIFF 的方法(例如 ImageMagick、ImageJ)似乎也删除了元数据。有没有办法从命令行批量分割这些文件并保留时间戳?

答案1

您共享的文件不符合您链接的规范。


第 3.5 节规定“如果是多图像文件,第一个 IFD 将具有 FrameRate,其余的则没有”。这里的情况并非如此,每个 IFD 都有 18 个条目,并且 FrameRate 标签没有出现在任何一个条目中。


第 3.3.1 节规定“将会有值为 0x8769 和 0x8825 的私有标签指向自定义 IFD”。这两个都不存在。您可以看到,使用exiftool和 还可以列出所有标签,tiffdump并且两者都不显示这些标签:

tiffdump Boson_Capture.tiff
Boson_Capture.tiff:
Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 655368 (0xa0008) next 1311022 (0x14012e)
ImageWidth (256) SHORT (3) 1<640>
ImageLength (257) SHORT (3) 1<512>
BitsPerSample (258) SHORT (3) 1<16>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<1>
FillOrder (266) SHORT (3) 1<1>
StripOffsets (273) LONG (4) 1<8>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) SHORT (3) 1<512>
StripByteCounts (279) LONG (4) 1<655360>
XResolution (282) RATIONAL (5) 1<1>
YResolution (283) RATIONAL (5) 1<1>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<1>
PageNumber (297) SHORT (3) 2<0 2>
Software (305) ASCII (2) 56<7CTiff - FLIR Systems, I ...>
SampleFormat (339) SHORT (3) 1<1>

...其他 IFD 也是如此。


如果你完全放弃规范的正确性,并尝试在格式中找到任何看起来像日期的东西“EXIF 扩展部分”链接规范:

Exif.Photo.DateTimeOriginal value 
offset  value
-----------------------------
3630 32 30 31 31 3a 30 32 3a 31 30
     20 31 34 3a 31 31 3a 32 37 00 ascii "2011:02:10 14:11:27"

您可以使用strings类似grep这样的方法来搜索后跟冒号的 4 位数字年份:

strings Boson_Capture.tiff| grep -E "\d{4}:"

再次进行,但要进行偏移,以防它恰好跨越线边界:

tail -c +8 Boson_Capture.tiff | strings | grep -E "\d{4}:"

但你不会找到这样的东西。

相关内容