[FFmpeg-cvslog] Revert "avformat/file: seek back to initial position for fd protocol"

Rémi Denis-Courmont git at videolan.org
Thu May 30 18:30:28 EEST 2024


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 27 18:19:42 2024 +0300| [add8c46215397541210a4e7bc0e401ef52843698] | committer: Rémi Denis-Courmont

Revert "avformat/file: seek back to initial position for fd protocol"

The generally expected behaviour is for software to append from the
current position, not to keep resetting. See also how shell works:
 # (foo && bar) > file
...would normally concatenate the output of both commands to file.

If foo seeks like lavf, bar would instead overwrite the output of
foo (possibly not completely).

This reverts commit 5c3d2177e7be7dde69a83b1b394f57976c164c84.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=add8c46215397541210a4e7bc0e401ef52843698
---

 libavformat/file.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/libavformat/file.c b/libavformat/file.c
index 0ed4cff266..3fc1e741f2 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -99,7 +99,6 @@ typedef struct FileContext {
 #if HAVE_DIRENT_H
     DIR *dir;
 #endif
-    int64_t initial_pos;
 } FileContext;
 
 static const AVOption file_options[] = {
@@ -220,12 +219,7 @@ static int fd_dup(URLContext *h, int oldfd)
 static int file_close(URLContext *h)
 {
     FileContext *c = h->priv_data;
-    int ret;
-
-    if (c->initial_pos >= 0 && !h->is_streamed)
-        lseek(c->fd, c->initial_pos, SEEK_SET);
-
-    ret = close(c->fd);
+    int ret = close(c->fd);
     return (ret == -1) ? AVERROR(errno) : 0;
 }
 
@@ -293,7 +287,6 @@ static int file_open(URLContext *h, const char *filename, int flags)
 
     av_strstart(filename, "file:", &filename);
 
-    c->initial_pos = -1;
     if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) {
         access = O_CREAT | O_RDWR;
         if (c->trunc)
@@ -505,11 +498,6 @@ static int fd_open(URLContext *h, const char *filename, int flags)
     if (c->fd == -1)
         return AVERROR(errno);
 
-    if (h->is_streamed)
-        c->initial_pos = -1;
-    else
-        c->initial_pos = lseek(c->fd, 0, SEEK_CUR);
-
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list