我有一个包含两个流(视频和音频)的 webm 视频文件:
$ ffprobe -i input.webm -show_streams -v quiet
[STREAM]
index=0
codec_name=vp8
codec_long_name=On2 VP8
profile=0
codec_type=video
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=480
coded_width=720
coded_height=480
closed_captions=0
has_b_frames=0
sample_aspect_ratio=853:720
display_aspect_ratio=853:480
pix_fmt=yuv420p
level=-99
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=unspecified
field_order=progressive
refs=1
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
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
TAG:DURATION=00:00:13.036000000
[/STREAM]
[STREAM]
index=1
codec_name=vorbis
codec_long_name=Vorbis
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
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
TAG:DURATION=00:00:12.961000000
[/STREAM]
请注意,音频流比视频短。
我想要获取音频流的具体持续时间,并且只获取这个数字,因此我查询:
$ ffprobe -v quiet -i input.webm -select_streams a:0 -show_entries format=duration -of csv="p=0"
13.036000
哎呀!这给出了容器的持续时间(?)我想得到流的持续时间本身:
$ ffprobe -v quiet -i input.webm -select_streams a:0 -show_entries stream=duration -of csv="p=0"
N/A
嗯?不可用?我刚刚看到命令00:00:12.961000000
列表-show_streams
!这是怎么回事?