Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change AVI creation date with ffmpeg?

Tags:

ffmpeg

As far as I can tell the following ffmpeg command should copy all existing metadata in the input file to the output file and modify the specified field in the output file:

ffmpeg -i VID_20130502_220104.avi -metadata creation_time="2013-05-02 22:01:04" -codec copy VID_20130502_220104-2.avi

Instead, it seems to strip all metadata from the output file. Here is the output of a few commands. I am going nuts. I think this should work, but why is it not?

Command to edit the creation time:

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%

Command to inspect the output file metadata with 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

Command to inspect the input file metadata with 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

Command to inspect the output file metadata with 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
like image 636
brock Avatar asked Nov 01 '16 04:11

brock


Video Answer


1 Answers

The creation_time works for MOV/MP4/MKV files.

For AVI, the syntax is

ffmpeg -i old.avi -metadata ICRD="2013-05-02 22:01:04" -c copy new.avi

Usually, to expressly ask ffmpeg to retain all metadata, you would add -map_metadata 0 but with AVIs, ffmpeg hasn't implemented many of the RIFF tags, especially the vendor-proprietary ones, so I don't know if all will get copied over.

like image 139
Gyan Avatar answered Nov 07 '22 07:11

Gyan