linuxvideotimestampcommand-line-interfacempeg

How to find the recording time for a video from the linux command line


I have some mpegs from my camcorder and I'm trying to figure out when they were recorded.

So far, I have tried transcode:

 tcprobe -i M2U00249.MPG -H 10 -d258

Which resulted in:

[scan_pes.c] SCR=       0 (       0) unit=0 @ offset     0.0000 (sec)
[tcprobe] MPEG program stream (PS)
[tcprobe] summary for M2U00249.MPG, (*) = not default, 0 = not detected
import frame size: -g 720x480 [720x576] (*)
 aspect ratio: 16:9 (*)
   frame rate: -f 29.970 [25.000] frc=4 (*)
               PTS=0.2057, frame_time=33ms bitrate=9100 kbps
  audio track: -a 0 [0] -e 48000,16,5 [48000,16,2] -n 0x2000 [0x2000] (*)
               PTS=0.0895, bitrate=448 kbps
               -D 3 --av_fine_ms 16 (frames & ms) [0] [0]

MPlayer:

 mplayer -identify M2U00249.MPG

Which resulted in:

Playing M2U00249.MPG.
ID_VIDEO_ID=0
ID_AUDIO_ID=128
MPEG-PS file format detected.
VIDEO:  MPEG2  720x480  (aspect 3)  29.970 fps  9100.0 kbps (1137.5 kbyte/s)
ID_FILENAME=M2U00249.MPG
ID_DEMUXER=mpegps
ID_VIDEO_FORMAT=0x10000002
ID_VIDEO_BITRATE=9100000
ID_VIDEO_WIDTH=720
ID_VIDEO_HEIGHT=480
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=8192
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_START_TIME=0.09
ID_LENGTH=122.06
ID_SEEKABLE=1
ID_CHAPTERS=0

FFmpeg:

ffprobe -show_format -show_streams M2U00243.MPG

Which resulted in:

index=0
codec_name=mpeg2video
codec_long_name=MPEG-2 video
codec_type=video
codec_time_base=1001/60000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=480
has_b_frames=1
sample_aspect_ratio=32:27
display_aspect_ratio=16:9
pix_fmt=yuv420p
id=0x1e0
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/90000
start_time=0.178456
duration=282.682400
[/STREAM]
[STREAM]
index=1
codec_name=ac3
codec_long_name=ATSC A/52A (AC-3)
codec_type=audio
codec_time_base=0/1
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_rate=48000.000000
channels=6
bits_per_sample=0
id=0x80
r_frame_rate=0/0
avg_frame_rate=125/4
time_base=1/90000
start_time=0.079722
duration=282.720000
[/STREAM]
[FORMAT]
filename=M2U00243.MPG
nb_streams=2
format_name=mpeg
format_long_name=MPEG-PS format
start_time=0.079722
duration=282.781134
size=330334208.000000
bit_rate=9345296.000000
[/FORMAT]

None of these seems to have the time that the video was recorded. Is there something I'm missing or is the only way to get the recording time:

stat -c %y M2U00249.MPG

Solution

  • There is no required record of the absolute encode time in an MPEG program stream. Getting the last modified time from the file system is your best bet.