if (!all_frames.empty()) {
// We already had this cached in the database, so no need to look in the file.
for (const DB::FrameOnDiskAndStreamIdx &frame : all_frames) {
- if (frame.stream_idx >= 0 && frame.stream_idx < MAX_STREAMS) {
+ if (frame.stream_idx < MAX_STREAMS) {
frames[frame.stream_idx].push_back(frame.frame);
start_pts = max(start_pts, frame.frame.pts);
}
FrameOnDisk frame;
frame.pts = hdr.pts();
frame.offset = ftell(fp);
+ if (frame.offset == -1) {
+ fprintf(stderr, "WARNING: %s: ftell() failed (%s).\n", filename, strerror(errno));
+ break;
+ }
frame.filename_idx = filename_idx;
frame.size = hdr.file_size();
filename, skipped_bytes);
}
- size_t size = ftell(fp);
+ off_t size = ftell(fp);
+ if (size == -1) {
+ fprintf(stderr, "WARNING: %s: ftell() failed (%s).\n", filename, strerror(errno));
+ return;
+ }
fclose(fp);
db->store_frame_file(basename, size, all_frames);