Questions tagged [seek]

Seeking is the act of moving around a file or file-like object.

Seeking is the act of moving around a file or file-like object.

ANSI C in section 2.3.12.10 specifies thatfseek has the argument structure:

int fseek(FILE *stream, long offset, int whence);

Where:

  • stream is the FILE object to seek (note that this does not have to physically be a file)
  • offset is how much, relative to the whence argument
  • whence is one of
    • SEEK_SET (offset is computed relative to the start of the file)
    • SEEK_CUR (offset is computed relative to the current position)
    • SEEK_END (offset is computed relative to the end of the file)

The majority of languages based upon C, and even many that aren't, have inherited something similar to fseek, but have probably put it somewhere else (ex. Python's file.seek). Check your language of choice's documentation for details.

513 questions
75
votes
12 answers

What is the most efficient way to get first and last line of a text file?

I have a text file which contains a time stamp on each line. My goal is to find the time range. All the times are in order so the first line will be the earliest time and the last line will be the latest time. I only need the very first and very…
pasbino
  • 753
  • 1
  • 5
  • 4
71
votes
4 answers

Memory Stream in Java

I am looking for a memory stream implementation in Java. The implementation should be roughly modeled after the .NET memory stream implementation. Basically I would like to have a class MemoryStream which has to factory methods: class MemoryStream…
Mostowski Collapse
  • 12,118
  • 3
  • 34
  • 78
59
votes
2 answers

Safe to have multiple processes writing to the same file at the same time? [CentOs 6, ext4]

I'm building a system where multiple slave processes are communicating via unix domain sockets, and they are writing to the same file at the same time. I have never studied filesystems or this specific filesystem (ext4), but it feels like there…
Fixee
  • 1,381
  • 2
  • 13
  • 21
50
votes
2 answers

seek to a point in html5 video

Is it possible to seek to a particular point in html5 video displayed in a web page? I mean ,can I input a particular time value (say 01:20:30:045 ) and have the player control (slider) move to that point and play from that point onwards? In older…
damon
  • 7,127
  • 15
  • 62
  • 105
35
votes
4 answers

How to delete only the content of file in python

I have a temporary file with some content and a python script generating some output to this file. I want this to repeat N times, so I need to reuse that file (actually array of files). I'm deleting the whole content, so the temp file will be empty…
bartimar
  • 2,824
  • 3
  • 24
  • 50
31
votes
3 answers

VideoView getCurrentPosition() irregularity on Acer Iconia A200

I have an application with a VideoView in it, I set a video to play in the VideoView. At some point while the video is playing it will get paused. Then after it is paused for some time it will begin to play the video again, but seek forward to the…
FoamyGuy
  • 45,328
  • 16
  • 118
  • 151
26
votes
4 answers

OpenCV Seek Function/Rewind

I've been trying to find/implement a seek and rewind function (for video (.avi)) using OpenCV in C++, but I cant find a way of doing it, other than going through the entire file once and saving each image. Is there any other way? Any help would be…
Cenoc
  • 10,072
  • 17
  • 51
  • 84
24
votes
3 answers

VideoView seekto() function extremely inconsistent

I am trying to Seek to a particular location in a video in Android and I am completely stuck because of the inconsistencies it is showing in its behaviour. Here's a list of things I ve done VideoView.Seekto goes to 5:19 for one video, 5:17 for one…
Vrashabh Irde
  • 13,719
  • 4
  • 48
  • 100
23
votes
6 answers

Stream wrapper to make Stream seekable?

I have a readonly System.IO.Stream implementation that is not seekable (and its Position always returns 0). I need to send it to a consumer that does some Seek operations (aka, sets the Position) on the stream. It's not a huge seek -- say +/- 100…
Brannon
  • 5,002
  • 2
  • 29
  • 73
22
votes
1 answer

How can I seek to frame No. X with ffmpeg?

I'm writing a video editor, and I need to seek to exact frame, knowing the frame number. Other posts on stackoverflow told me that ffmpeg may give me a few broken frames after seeking, which is not a problem for playback but a big problem for video…
Giumo
  • 309
  • 1
  • 3
  • 11
21
votes
6 answers

Android SeekBar to control MediaPlayer progress

I have a SeekBar, it displays correctly MediaPlayer progress. However, I have troubles with seeking - if I seek scroll box somewhere it just returns on the position where audio file is playing. public class EntityPageActivity extends Activity…
Ilya Blokh
  • 11,493
  • 10
  • 49
  • 80
21
votes
1 answer

Is it safe to open a file several times at once in Python?

I seem to recall cases in lower level languages that opening a file more than once in a program could result in a shared seek pointer. By messing around in Python a bit, this doesn't seem to be happening for me: $ cat file.txt first…
Ryan Haining
  • 30,835
  • 10
  • 95
  • 145
20
votes
2 answers

Seeking on a gz connection is unpredictable

I'm having trouble seeking around gzfiles in R. Here's an example: set.seed(123) m=data.frame(z=runif(10000),x=rnorm(10000)) write.csv(m,"m.csv") system("gzip m.csv") file.info("m.csv.gz")$size [1] 195975 That creates m.csv.gz, which R says it can…
Spacedman
  • 86,225
  • 12
  • 117
  • 197
17
votes
1 answer

Why does the C++ standard handle file seeking the way it does?

C++ uses the streamoff type to represent an offset within a (file) stream and is defined as follows in [stream.types]: using streamoff = implementation-defined ; The type streamoff is a synonym for one of the signed basic integral types of…
jceed2
  • 171
  • 3
16
votes
2 answers

Does FileInputStream.skip() do a seek?

I want to copy the last 10MB of a possibly large file into another file. Ideally I would use FileInputStream, skip() and then read(). However I'm unsure if the performance of skip() will be bad. Is skip() typically implemented using a file seek…
Mike Q
  • 21,350
  • 19
  • 80
  • 124
1
2 3
34 35