ffmpeg -list_devices 和 -list_options 的意外退出代码 1

问题描述 投票:0回答:1

描述

如果我在 Windows 10 上使用 ffmpeg 4.2.2 运行文档中的

示例
中的以下任何命令,则请求的信息成功显示在控制台中,但是进程会退出并显示退出代码
1
,而不是预期的
0
(成功)。

ffmpeg -list_devices true -f dshow -i dummy

ffmpeg -list_options true -f dshow -i video="MyCamera"

据我所知,Windows 上的退出代码

1
意味着 “函数不正确”,所以我认为这种行为是意外的。

如果我将相机输入流式传输到磁盘,使用例如

ffmpeg -f dshow -i video="MyCamera" "myfile.mp4"
,然后停止使用q,退出代码为
0
,如预期。

问题

退出代码

1
是否构成
ffmpeg
的正常行为,还是我做错了什么?

相关性

当从命令行手动运行命令时,退出代码没有太大区别,只要显示请求的信息即可。

但是,以编程方式运行命令时,可能会引起麻烦。例如,使用 Python 的

subprocess.run(..., check=True)
,非零退出代码会导致 CalledProcessError

当然有办法解决这个问题,例如使用

check=False
,但要点是,如果
ffmpeg
的行为符合预期,即返回
0

,则不需要解决方法
ffmpeg directshow
1个回答
1
投票

退出代码

1
,同时列出带有
dshow
的设备是预期的输出,因为在这种情况下,代码使用
AVERROR_EXIT
立即退出,并且不会产生任何媒体输出。

if (ctx->list_devices) {
    av_log(avctx, AV_LOG_INFO, "DirectShow video devices (some may be both video and audio devices)\n");
    dshow_cycle_devices(avctx, devenum, VideoDevice, VideoSourceDevice, NULL, NULL);
    av_log(avctx, AV_LOG_INFO, "DirectShow audio devices\n");
    dshow_cycle_devices(avctx, devenum, AudioDevice, AudioSourceDevice, NULL, NULL);
    ret = AVERROR_EXIT;
    goto error;
}

您应该在日志中看到

dummy: Immediate exit requested

您当然可以轻松修改

libavdevice/dshow.c
并干净退出,但您必须编译自己的版本。

© www.soinside.com 2019 - 2024. All rights reserved.