- // Insert the actual frames.
- int64_t rowid = sqlite3_last_insert_rowid(db);
-
- ret = sqlite3_prepare_v2(db, "INSERT INTO frame (file, stream_idx, pts, offset, size) VALUES (?, ?, ?, ?, ?)", -1, &stmt, 0);
- if (ret != SQLITE_OK) {
- fprintf(stderr, "INSERT prepare: %s\n", sqlite3_errmsg(db));
- exit(1);
- }
-
- sqlite3_bind_int64(stmt, 1, rowid);
-
- for (const FrameOnDiskAndStreamIdx &frame : frames) {
- sqlite3_bind_int64(stmt, 2, frame.stream_idx);
- sqlite3_bind_int64(stmt, 3, frame.frame.pts);
- sqlite3_bind_int64(stmt, 4, frame.frame.offset);
- sqlite3_bind_int(stmt, 5, frame.frame.size);
-
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_ROW) {
- fprintf(stderr, "INSERT step: %s\n", sqlite3_errmsg(db));
- exit(1);
- }
-
- ret = sqlite3_reset(stmt);
- if (ret != SQLITE_OK) {
- fprintf(stderr, "INSERT reset: %s\n", sqlite3_errmsg(db));
- exit(1);
- }
- }
-
- ret = sqlite3_finalize(stmt);
- if (ret != SQLITE_OK) {
- fprintf(stderr, "INSERT finalize: %s\n", sqlite3_errmsg(db));
- exit(1);
- }
-