As part of a larger script, I need to be able to read the timecode off of a DPX file. I have ffmpeg and ffprobe, but I'm a beginner when it comes to using those programs.
For MOV files, I was able to cobble this together:
def GetStartingTimecodeFromMOV(Filename): cmd = "ffprobe -v quiet -print_format json -show_streams -show_format" args = shlex.split(cmd) args.append(Filename) String = subprocess.check_output(args).decode('utf-8') for Line in String.split("\n"): if Line.count("timecode"): Timecode = Line.split("\"")[3] return Timecode
...but their must be some subtle difference in the metadata between a MOV file and a DPX. Any help would be appreciated.
If I try....
ffprobe -v quiet -show_streams -show_format "/Render/MyFile/MyFile.0001016.dpx"
...then I get a lot of useful info, including resolution and FPS, but not timecode (at least for a DPX file)
[STREAM]
index=0
codec_name=dpx
codec_long_name=DPX (Digital Picture Exchange) image
profile=unknown
codec_type=video
codec_time_base=0/1
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=1920
height=1600
coded_width=1920
coded_height=1600
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=6:5
pix_fmt=rgb48be
level=-99
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=unspecified
field_order=unknown
timecode=N/A
refs=1
id=N/A
r_frame_rate=25/1
avg_frame_rate=0/0
time_base=1/25
start_pts=N/A
start_time=N/A
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=16
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=/Render/MyFile/MyFile.0001016.dpx
nb_streams=1
nb_programs=0
format_name=dpx_pipe
format_long_name=piped dpx sequence
start_time=N/A
duration=N/A
size=18440192
bit_rate=N/A
probe_score=51
[/FORMAT]
If you are still looking for this.. use ImageMagick (imagemagick.org)
The DPX header is standard SMPTE, you can fetch it with:
magick identify -format "%[dpx:television.time.code]" 76890.dpx
In this case it returned the value: 01:00:21:16