使用 ffmpeg 转换视频时复制 creation_date 元数据

使用 ffmpeg 转换视频时复制 creation_date 元数据

我想将一堆旧视频转换为 H.264 以节省空间,但无论我使用什么花哨的 -map_metadata 变体,ffmpeg 总是会删除创建日期。这对我来说显然是一个巨大的障碍。

转换视频时,ffmpeg 甚至会显示创建日期,但不会复制它。以下是 ffmpeg 转换一个视频的输出:

$ ffmpeg -i avi/test/21.1.08\ 081.AVI -pix_fmt yuv420p test.mov
ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvorbis --enable-libfaac --enable-libfdk-aac --enable-libopus --enable-libwebp --enable-nonfree --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'avi/test/21.1.08 081.AVI':
  Metadata:
    creation_time   : 2008-01-20 12:12:22
    encoder         : CanonMVI06
  Duration: 00:00:13.23, start: 0.000000, bitrate: 15161 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 14486 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
[swscaler @ 0x7fc952800600] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7fc95203da00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fc95203da00] profile High, level 3.0
[libx264 @ 0x7fc95203da00] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mov @ 0x7fc95203ce00] WARNING codec timebase is very high. If duration is too long,
file may not be playable by quicktime. Specify a shorter timebase
or choose different container.
Output #0, mov, to 'test.mov':
  Metadata:
    encoder         : Lavf56.25.101
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 640x480, q=-1--1, 30 fps, 1000k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.26.100 libx264
    Stream #0:1: Audio: aac (libfaac) (mp4a / 0x6134706D), 44100 Hz, mono, s16, 128 kb/s
    Metadata:
      encoder         : Lavc56.26.100 libfaac
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (libfaac))
Press [q] to stop, [?] for help
frame=   92 fps=0.0 q=29.0 size=     159kB time=00:00:03.90 bitrate= 333.0kbits/frame=  174 fps=173 q=29.0 size=     442kB time=00:00:05.89 bitrate= 613.6kbits/frame=  250 fps=165 q=29.0 size=     768kB time=00:00:08.89 bitrate= 707.3kbits/frame=  324 fps=161 q=29.0 size=    1099kB time=00:00:10.89 bitrate= 826.6kbits/frame=  397 fps=149 q=-1.0 Lsize=    1448kB time=00:00:13.23 bitrate= 896.2kbits/s    
video:1311kB audio:122kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.060318%
[libx264 @ 0x7fc95203da00] frame I:2     Avg QP:23.06  size: 15524
[libx264 @ 0x7fc95203da00] frame P:165   Avg QP:24.65  size:  6142
[libx264 @ 0x7fc95203da00] frame B:230   Avg QP:27.41  size:  1293
[libx264 @ 0x7fc95203da00] consecutive B-frames:  7.8% 23.2% 65.0%  4.0%
[libx264 @ 0x7fc95203da00] mb I  I16..4: 20.0% 74.5%  5.5%
[libx264 @ 0x7fc95203da00] mb P  I16..4:  4.0%  4.5%  0.7%  P16..4: 46.2% 13.5%  7.5%  0.0%  0.0%    skip:23.6%
[libx264 @ 0x7fc95203da00] mb B  I16..4:  0.1%  0.1%  0.1%  B16..8: 40.6%  3.2%  0.6%  direct: 0.8%  skip:54.5%  L0:43.7% L1:51.4% BI: 4.9%
[libx264 @ 0x7fc95203da00] 8x8 transform intra:51.4% inter:66.4%
[libx264 @ 0x7fc95203da00] coded y,uvDC,uvAC intra: 40.3% 63.6% 22.5% inter: 11.6% 17.6% 1.3%
[libx264 @ 0x7fc95203da00] i16 v,h,dc,p: 20% 23%  6% 51%
[libx264 @ 0x7fc95203da00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 17% 21%  4%  5%  8%  5%  6%  6%
[libx264 @ 0x7fc95203da00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 19% 14%  5%  8%  9%  8%  6%  6%
[libx264 @ 0x7fc95203da00] i8c dc,h,v,p: 56% 17% 23%  4%
[libx264 @ 0x7fc95203da00] Weighted P-Frames: Y:7.9% UV:2.4%
[libx264 @ 0x7fc95203da00] ref P L0: 60.0% 14.3% 16.9%  8.6%  0.2%
[libx264 @ 0x7fc95203da00] ref B L0: 73.8% 21.7%  4.5%
[libx264 @ 0x7fc95203da00] ref B L1: 89.1% 10.9%
[libx264 @ 0x7fc95203da00] kb/s:811.24

我如何让 ffmpeg 复制这些视频的创建日期?

答案1

ffmpeg 在从视频复制元数据时似乎出现了问题creation_time。不过,您可以像这样手动执行此操作:

ffmpeg -i avi/test/21.1.08\ 081.AVI -pix_fmt yuv420p -metadata creation_time='2008-01-20 12:12:22' test.mov

相关内容