Reading .MTS file date and timestamp

While cutting a video from the many hundreds of gigabytes from our 1/4-HD-camcorder, we wanted to display date and time when the video was recorded. Our video camera records AVCHD video files that get a .MTS (MPEG-2 Transport Stream) extension.

Unfortunately, neither mplayer nor VLC display this meta information, only Totem manages to show it. Also, using a video player to extract meta data for some hundreds of video files isn't exactly pleasant.

file and extract also didn't give me any date information. Thanks to a comment in AVCHD timecodes revealed , I got to know that exiftool is able to extract the meta data from .MTS files:

$ exiftool 00045.MTS
ExifTool Version Number         : 8.60
File Name                       : 00045.MTS
Directory                       : bis 2012-11-16
File Size                       : 122 MB
File Modification Date/Time     : 2012:11:08 19:28:12+01:00
File Permissions                : rw-------
File Type                       : M2TS
MIME Type                       : video/m2ts
Video Stream Type               : H.264 Video
Audio Stream Type               : A52/AC-3 Audio
Audio Bitrate                   : 256 kbps
Surround Mode                   : Not indicated
Audio Channels                  : 2
Image Width                     : 1920
Image Height                    : 1080
Date/Time Original              : 2012:11:08 19:27:26+01:00
Aperture Setting                : Auto
Gain                            : 18 dB
Exposure Program                : Program AE
White Balance                   : Auto
Focus                           : Auto (0.9)
Image Stabilization             : On (0x3f)
Exposure Time                   : 1/60
F Number                        : 1.8
Make                            : Sony
Camera Model Name               : HDR-CX305E
Audio Sample Rate               : 48000
Duration                        : 0:00:45
Aperture                        : 1.8
Image Size                      : 1920x1080
Shutter Speed                   : 1/60

Getting the timestamps of all video files into a text file was trivial now:

$ for i in */*.MTS; do\
 echo -n "$i " >> dates;\
 exiftool "$i"|grep Original|cut -b35- >> dates;\

Written by Christian Weiske.

Comments? Please send an e-mail.