【问题标题】:ffprobe returning video stream data twiceffprobe 两次返回视频流数据
【发布时间】:2015-11-15 21:22:11
【问题描述】:

我正在尝试从 ffprobe 返回特定值:

ffprobe -v error -select_streams V:0 -show_entries stream=index,width,height,sample_aspect_ratio,display_aspect_ratio:format=duration -of default=noprint_wrappers=1:nokey=1 test.MTS

输出中的流值是重复的:

0
1920
1080
1:1
16:9
0
1920
1080
1:1
16:9
116.640000

格式值不重复。 如果我剥离打印机值以查看发生了什么:

ffprobe -v error -select_streams V:0 -show_entries stream=index,width,height,sample_aspect_ratio,display_aspect_ratio:format=duration test.MTS

我看到一个名为 [PROGRAM] 的部分,其中重复了流 0:

[PROGRAM]
[STREAM]
index=0
width=1920
height=1080
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
[/STREAM]
[/PROGRAM]
[STREAM]
index=0
width=1920
height=1080
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
[/STREAM]
[FORMAT]
duration=116.640000
[/FORMAT]

有人可以帮我只返回一次视频流 0 值吗?

【问题讨论】:

  • Stack Overflow 不是一个通用的帮助站点,而是专门针对有关编程的问题。下次试试Super User ff* cli 使用问题。
  • @LordNeckbeard 虽然这完全正确,但 ffmpeg 和朋友可以说是“程序员常用的软件工具”,因为视频编码是一项通常自动化或脚本化的任务,而且这个工具在该领域无处不在。
  • @SirDarius 使用该逻辑,任何 cli 工具使用问题都可以被视为主题。
  • 我正在使用 vb 通过 ffprobe 和 ffmpeg 操作视频。我不想用不必要的细节混淆这个问题,所以我将我的问题浓缩为问题的本质。我在这里发帖是因为我认为其他程序员会以这种方式使用 ffprobe 将值返回给他们的代码。顺便说一句,我认为答案对程序员很有用。

标签: ffmpeg ffprobe


【解决方案1】:

常规的stream 没有唯一的部分名称。但是,您可以使用-show_entries program_stream 只选择节目流,或者只是丢弃额外的信息。见ffprobe -sections

【讨论】:

  • -show_entries program_stream=index,width,height,sample_aspect_ratio,display_aspect_ratio:format=duration 不了解程序,没仔细看。我会丢弃额外的数据。如果对您有帮助,它可以输出 JSON 或 XML。
  • 谢谢,我现在正在一步步解决。
  • this:ffprobe -v error -select_streams V:0 -show_entries program_stream=index,width,height,sample_aspect_ratio,display_aspect_ratio:format=duration -of default=noprint_wrappers=1:nokey=1 test.mts 为我提供了我需要的结果 :-) 我唯一担心的是——如果有人知道的话——我可能会遇到一个在程序中没有流的视频。跨度>
  • 是的,正如我所担心的那样;我指出的大多数视频都没有返回 program_stream
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-29
  • 2020-04-08
  • 2021-09-29
  • 2015-03-03
  • 2015-07-11
  • 2014-06-20
  • 1970-01-01
相关资源
最近更新 更多