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.

537 questions
5
votes
1 answer

iOS MediaPlayer Seeking

I am able to use iOS MediaPlayer and play a movie by this way. But I need, seeking a sec of a movie. How can I do this, I play a movie by MediaPlayer like that: NSURL *videoURL = [NSURL fileURLWithPath:self.filename]; …
barisatbas
  • 570
  • 2
  • 9
  • 22
5
votes
1 answer

In Perl, why can't you use __DATA__ as a seekable filehandle?

Reading from DATA via the typical slurp works. Trying to use DATA as a filehandle on which I can do a seek does not work. Is anyone able to point me the to the obvious mistake I must be making? Code: #!/usr/bin/env perl use strict; use…
mpersico
  • 766
  • 7
  • 19
5
votes
1 answer

Implementation of io.ReadWriteSeeker in golang

Is there an implementation of io.ReadWriteSeeker to use in Golang? Since, bytes.Buffer does not implement Seek method, I need to find such an implementation to use as a buffer written by zipwriter and to be read with seeking. In addition I wont go…
Stefan Liu
  • 53
  • 1
  • 5
5
votes
2 answers

Reading system files with perl without issuing extra seek syscalls on open

I'm trying to use perl to parse some pseudo files from /proc and /sys linux pseudo filesystems (procfs and sysfs). Such files are unlike regular files - they are implemented by custom file operation handlers. Most of them have zero size for stat,…
osgx
  • 90,338
  • 53
  • 357
  • 513
5
votes
1 answer

Double seek vs undefined in JavaScript Map: TryGet wanted

JavaScript map has 2 methods get and has. Method get returns undefined if element does not exist or if value undefined was added to the map. So if I implement my method GetAlways or such, which will return existing or add new and return if not…
alpav
  • 2,972
  • 3
  • 37
  • 47
5
votes
1 answer

Android Precise seeking of video

I'm struggling with precise seeking using MediaExtractor's seekTo(). While I can seek to sync frames without problems, I would like to seek to specific time. This question led me to some ideas how to do this, but I'm not sure if they are valid.…
5
votes
1 answer

Seek from end of file in python 3

One of the changes in python 3 has been to remove the ability to seek from the end of the file in normal text mode. What is the generally accepted alternative to this? For example in python 2.7 I would enter file.seek(-3,2) I've read a bit about why…
Toby Bishop
  • 51
  • 1
  • 3
5
votes
2 answers

Peek on QTextStream

I would like to peek the next characters of a QTextStream reading a QFile, in order to create an efficient tokenizer. However, I don't find any satisfying solution to do so. QFile f("test.txt"); f.open(QIODevice::WriteOnly); f.write("Hello…
FabienRohrer
  • 1,794
  • 2
  • 15
  • 26
5
votes
1 answer

Slow MediaExtractor seekTo

I created a video player using MediaCodec and MediaExtractor, but when I try to change the media position using MediaExtractor seekTo method it is really slow (took 10 seconds to seek for a 1080P video) while the SDK MediaPlayer can seek in…
Mohsen Afshin
  • 13,273
  • 10
  • 65
  • 90
5
votes
3 answers

android mediaplyer seekTo inside onPrepared

my problem seems to happen only on android 4.2.2 I go this way idle state -> initialized state -> prepareAsync() -> and in onPrepared the seekTo is called, but on this android version the mediaplayer returns "Attempt to seek to past end of file:…
Lukas Hanacek
  • 1,364
  • 14
  • 25
5
votes
3 answers

C++ Seek a std::string::iterator to given position

Is it possible to seek a std::string::iterator safely to a given position? std::string::iterator has a offset access operator (operator []), but it exists in the category defined by some people as undefined behavior, like it + 3. cplusplus.com…
Tim
  • 5,521
  • 8
  • 36
  • 69
5
votes
4 answers

How do I do random access reads from (large) files using node.js?

Am I missing something or does node.js's standard file I/O module lack analogs of the usual file random access methods? seek() / fseek() tell() / ftell() How does one read random fixed-size records from large files in node without these?
hippietrail
  • 15,848
  • 18
  • 99
  • 158
5
votes
2 answers

seek to regex in a large file using python

I am trying to seek to a token ':path,' in a file, then read all the following (arbitrary digit count) numbers as a number (so for ':path,123' I seek to the , in file then read the integer 123). Then read the chars between the current seek position…
sillyMunky
  • 1,260
  • 8
  • 13
5
votes
1 answer

Seek time vs Sequential read

Let's assume that on a hard drive I have some very large data file of a sequence of characters: ABRDZ.... My question is as follows, if the head is positioned at the beginning of the file, and I need 5 characters every 1000 positions interval,…
DED
  • 143
  • 11
5
votes
1 answer

Event onSeek - Abbort the seeking process

is it possible to abbort the seek process? My urls expires after 10 seconds so i must request a new url when the user click on seek. onSeek: function(event) { getFreshUrl({videoId:'XXXXX', action:get}, function(data) { …
Peter
  • 11,413
  • 31
  • 100
  • 152