我已经知道ffmpeg能够从unix套接字接收输入:
ffmpeg -i unix://path-to-socket ...
问题是,在我的服务器代码中将套接字类型更改为SOCK_DGRAM
而不是SOCK_STREAM
时,ffmpeg无法接收数据并打印错误:
unix://path-to-socket: Protocol wrong type for socket
查看socket documentation on ffmpeg's site可以应用以下选项:
与声明套接字类型无关。
是否可以将unix套接字配置为SOCK_DGRAM
?
谢谢,
乔伊。
答案 0 :(得分:1)
文档不完整。在ffmpeg/libavformat/unix.c
,
static const AVOption unix_options[] = {
{ "listen", "Open socket for listening", OFFSET(listen), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ED },
{ "timeout", "Timeout in ms", OFFSET(timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, ED },
{ "type", "Socket type", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = SOCK_STREAM }, INT_MIN, INT_MAX, ED, "type" },
{ "stream", "Stream (reliable stream-oriented)", 0, AV_OPT_TYPE_CONST, { .i64 = SOCK_STREAM }, INT_MIN, INT_MAX, ED, "type" },
{ "datagram", "Datagram (unreliable packet-oriented)", 0, AV_OPT_TYPE_CONST, { .i64 = SOCK_DGRAM }, INT_MIN, INT_MAX, ED, "type" },
{ "seqpacket", "Seqpacket (reliable packet-oriented", 0, AV_OPT_TYPE_CONST, { .i64 = SOCK_SEQPACKET }, INT_MIN, INT_MAX, ED, "type" },
{ NULL }
};
它处理stream=1
,datagram=1
,seqpacket=1
或type=#
,其中#
是所需套接字类型的整数值({{1} },SOCK_STREAM=1
,SOCK_DGRAM=2
)。