据我所知,以下 ffmpeg 命令应将输入文件中的所有现有元数据复制到输出文件并修改输出文件中指定的元数据字段:
ffmpeg -i VID_20130502_220104.avi -metadata creation_time="2013-05-02 22:01:04" -codec copy VID_20130502_220104-2.avi
相反,它似乎从输出文件中删除了所有元数据。以下是一些命令的输出。我快疯了。我认为这应该有效,但为什么它不起作用呢?
请注意,我并没有试图更改文件属性日期。从我粘贴的日志中,您可以清楚地看到 ffmpeg 读取了输入文件中的“creation_time”,而 exiftool 读取了“原始日期/时间”和“创建日期”,它们都是“2011:01:01 00:00:00”,这与所有文件属性日期都不同。问题是,在输出文件中,ffmpeg 和 exiftool 都看不到这些元数据了,它们已经消失了。ffmpeg 似乎已经从输出文件中删除了元数据。
编辑创建时间的命令:
ffmpeg -i VID_20130502_220104.avi -metadata creation_time="2013-05-02 22:01:04" -codec copy VID_20130502_220104-2.avi
ffmpeg version 3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'VID_20130502_220104.avi':
Metadata:
encoder :
maker : NIKON
model : COOLPIX S4300
creation_time : 2011-01-01 00:00:00
Duration: 00:01:30.50, start: 0.000000, bitrate: 32135 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 31782 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, 1 channels, s16, 352 kb/s
[avi @ 000000000032ad40] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'VID_20130502_220104-2.avi':
Metadata:
creation_time : 2013-05-02 22:01:04
maker : NIKON
model : COOLPIX S4300
ISFT : Lavf57.41.100
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, q=2-31, 31782 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, 352 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 891 fps=0.0 q=-1.0 size= 116171kB time=00:00:29.69 bitrate=32043.1kbits/s speed=59.4x
frame= 1739 fps=1739 q=-1.0 size= 227191kB time=00:00:57.96 bitrate=32107.5kbits/s speed= 58x
frame= 2609 fps=1739 q=-1.0 size= 340940kB time=00:01:26.96 bitrate=32115.9kbits/s speed= 58x
frame= 2715 fps=1734 q=-1.0 Lsize= 355018kB time=00:01:30.49 bitrate=32136.3kbits/s speed=57.8x
video:350984kB audio:3897kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.038597%
使用 ffmpeg 检查输出文件元数据的命令:
ffmpeg -i VID_20130502_220104-2.avi
ffmpeg version 3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'VID_20130502_220104-2.avi':
Metadata:
encoder : Lavf57.41.100
Duration: 00:01:30.50, start: 0.000000, bitrate: 32136 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 31782 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, 1 channels, s16, 352 kb/s
At least one output file must be specified
使用 exiftool 检查输入文件元数据的命令:
exiftool.exe VID_20130502_220104.avi
ExifTool Version Number : 10.30
File Name : VID_20130502_220104.avi
Directory : .
File Size : 347 MB
File Modification Date/Time : 2013:05:13 16:33:52-04:00
File Access Date/Time : 2015:11:10 23:08:25-05:00
File Creation Date/Time : 2015:11:10 23:08:25-05:00
File Permissions : rw-rw-rw-
File Type : AVI
File Type Extension : avi
MIME Type : video/x-msvideo
Frame Rate : 30
Max Data Rate : 488.3 kB/s
Frame Count : 2715
Stream Count : 2
Stream Type : Video
Video Codec : mjpg
Video Frame Rate : 30
Video Frame Count : 2715
Quality : 10000
Sample Size : Variable
Image Width : 1280
Image Height : 720
Planes : 1
Bit Depth : 24
Compression : MJPG
Image Length : 2764800
Pixels Per Meter X : 0
Pixels Per Meter Y : 0
Num Colors : Use BitDepth
Num Important Colors : All
Audio Codec :
Audio Sample Rate : 22050
Audio Sample Count : 1995256
Encoding : Microsoft PCM
Num Channels : 1
Sample Rate : 22050
Avg Bytes Per Sec : 44100
Bits Per Sample : 16
Maker Note Type : NIKON
Maker Note Version : 0.1.0.0
Make : NIKON
Model : COOLPIX S4300
Software : V1.0
Equipment : NIKON DIGITAL CAMERA
Orientation : Horizontal (normal)
Exposure Time : 1/15
F Number : 3.5
Exposure Compensation : 0
Max Aperture Value : 3.2
Metering Mode : Multi-segment
Focal Length : 4.6 mm
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Date/Time Original : 2011:01:01 00:00:00
Create Date : 2011:01:01 00:00:00
Focus Mode : AF-S
Digital Zoom : 1
Color Mode : COLOR
Sharpness : AUTO
White Balance : NORMAL
Noise Reduction : OFF
Thumbnail Image : (Binary data 3082 bytes, use -b option to extract)
Aperture : 3.5
Duration : 0:01:30
Image Size : 1280x720
Megapixels : 0.922
Shutter Speed : 1/15
Focal Length : 4.6 mm
使用 exiftool 检查输出文件元数据的命令:
exiftool.exe VID_20130502_220104-2.avi
ExifTool Version Number : 10.30
File Name : VID_20130502_220104-2.avi
Directory : .
File Size : 347 MB
File Modification Date/Time : 2016:11:01 00:17:38-04:00
File Access Date/Time : 2016:11:01 00:17:36-04:00
File Creation Date/Time : 2016:11:01 00:15:18-04:00
File Permissions : rw-rw-rw-
File Type : AVI
File Type Extension : avi
MIME Type : video/x-msvideo
Frame Rate : 30
Max Data Rate : 3923 kB/s
Frame Count : 2715
Stream Count : 2
Stream Type : Video
Video Codec : MJPG
Video Frame Rate : 30
Video Frame Count : 2715
Quality : Default
Sample Size : Variable
Image Width : 1280
Image Height : 720
Planes : 1
Bit Depth : 24
Compression : MJPG
Image Length : 2764800
Pixels Per Meter X : 0
Pixels Per Meter Y : 0
Num Colors : Use BitDepth
Num Important Colors : All
Audio Codec : .
Audio Sample Rate : 22050
Audio Sample Count : 1995256
Encoding : Microsoft PCM
Num Channels : 1
Sample Rate : 22050
Avg Bytes Per Sec : 44100
Bits Per Sample : 16
Software : Lavf57.41.100
Duration : 0:01:30
Image Size : 1280x720
Megapixels : 0.922
答案1
我交叉发帖是因为我无法将问题转移到可能更相关的社区。抱歉。但这是给任何可能需要的人的答案:
适用
creation_time
于 MOV/MP4/MKV 文件。对于 AVI,语法是
ffmpeg -i old.avi -metadata ICRD="2013-05-02 22:01:04" -c copy new.avi
通常,为了明确要求 ffmpeg 保留所有元数据,您可以添加,
-map_metadata 0
但是对于 AVI,ffmpeg 尚未实现许多 RIFF 标签,尤其是供应商专有的标签,所以我不知道是否会全部复制过来。