diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2022-12-15 01:10:07 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2023-01-11 18:50:36 +0800 |
commit | 49b8f043ca3e39141929d8614876131be0a801a9 (patch) | |
tree | d78b62e0dab27fd8fb8c9eef8bd266ac94794e08 /libavformat/file.c | |
parent | 0d7c452d84e7ed228601b0285152f158ee2308fd (diff) | |
download | ffmpeg-49b8f043ca3e39141929d8614876131be0a801a9.tar.gz |
avformat/file: add fd option for pipe
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavformat/file.c')
-rw-r--r-- | libavformat/file.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/file.c b/libavformat/file.c index 6103c37b34..db619fcaac 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -92,6 +92,7 @@ static const AVOption file_options[] = { static const AVOption pipe_options[] = { { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "fd", "set file descriptor", offsetof(FileContext, fd), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -381,6 +382,8 @@ static int pipe_open(URLContext *h, const char *filename, int flags) FileContext *c = h->priv_data; int fd; char *final; + + if (c->fd < 0) { av_strstart(filename, "pipe:", &filename); fd = strtol(filename, &final, 10); @@ -391,10 +394,12 @@ static int pipe_open(URLContext *h, const char *filename, int flags) fd = 0; } } + c->fd = fd; + } + #if HAVE_SETMODE - setmode(fd, O_BINARY); + setmode(c->fd, O_BINARY); #endif - c->fd = fd; h->is_streamed = 1; return 0; } |