python - 如何通过 Python 从 DPX 文件读取时间码

标签 python ffmpeg ffprobe timecodes

作为较大脚本的一部分,我需要能够从 DPX 文件读取时间码。我有 ffmpeg 和 ffprobe,但在使用这些程序方面我还是个初学者。

对于 MOV 文件,我能够将其拼凑在一起:

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

...但是 MOV 文件和 DPX 之间的元数据一定存在一些细微的差异。任何帮助将不胜感激。

如果我尝试......

ffprobe -v quiet -show_streams -show_format "/Render/MyFile/MyFile.0001016.dpx"

...然后我得到了很多有用的信息,包括分辨率和 FPS,但不是时间码(至少对于 DPX 文件而言)

[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]

最佳答案

如果您仍在寻找这个..使用 ImageMagick (imagemagick.org)

DPX header 是标准 SMPTE,您可以通过以下方式获取它:

magick识别-格式“%[dpx:television.time.code]”76890.dpx

在本例中它返回值: 01:00:21:16

关于python - 如何通过 Python 从 DPX 文件读取时间码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58021748/

相关文章:

python - 将 spark DataFrame 保存为 Hive 表的问题

python - 使用 Cython 生成 C 代码时出现“未知类型名称”错误

python - 可以在使用 Bokeh 的 IPython 笔记本 session 中在 output_notebook 和 output_file 之间切换吗?

ffmpeg complex_filter 淡出不起作用

python - 从多个视频文件中获取持续时间?

python - 无法在 Pandas 中读取 Excel 文件

ffmpeg hls_time 选项不适用于 h264_nvenc

使用 vbr @128 将 flv 转换为 mp3 的 ffmpeg 命令行

php - 无法为 FFmpeg 加载 FFProbe 驱动程序

ffmpeg 命令行将输出写入文本文件