save duration millis

This commit is contained in:
Brandon Thomas committed 2021-05-25 01:50:02 -04:00
1 parent 6036934dd9
commit 6afe1c168b
4 files changed
+19 -5

No files matched your search

@@ -190,6 +190,7 @@ CREATE TABLE w2l_templates (
frame_height INT(10) NOT NULL DEFAULT 0,
frame_count INT(10) NOT NULL DEFAULT 0,
fps FLOAT NOT NULL DEFAULT 0.0,
duration_millis INT(1) NOT NULL DEFAULT 0,
-- Where the file was originally downloaded (if it was downloaded)
original_download_url VARCHAR(512) DEFAULT NULL,
+9 -1
View File
@@ -271,7 +271,9 @@ def main(tempdir):
is_video = False
frame_w = 0
frame_h = 0
fps = 0
frame_count = 0
fps = 0.0
duration_millis = 0.0
if not os.path.isfile(args.image_or_video_filename):
raise ValueError('--image_or_video_filename argument must be a valid path to video/image file')
@@ -282,6 +284,7 @@ def main(tempdir):
fps = args.fps
frame_h, frame_w = full_frames[0].shape[:-1]
is_video = False
frame_count = len(full_frames)
else:
video_stream = cv2.VideoCapture(args.image_or_video_filename)
@@ -313,8 +316,12 @@ def main(tempdir):
if len(full_frames) < 2:
is_video = False
frame_count = len(full_frames)
else:
is_video = True
frame_count = len(full_frames)
duration_seconds = frame_count / fps
duration_millis = int(duration_seconds * 1000)
print("Number of frames available for inference: "+str(len(full_frames)), flush=True)
print("Frame dimensions: {}x{}".format(frame_w, frame_h), flush=True)
@@ -339,6 +346,7 @@ def main(tempdir):
if is_video:
metadata['fps'] = fps
metadata['duration_millis'] = duration_millis
with open(args.output_metadata_filename, 'w') as json_file:
json.dump(metadata, json_file)
+6 -3
View File
@@ -120,7 +120,8 @@ pub async fn insert_w2l_template(pool: &MySqlPool,
frame_width: u32,
frame_height: u32,
frame_count: u64,
fps: f32)
fps: f32,
duration_millis: u64)
-> AnyhowResult<u64>
{
let model_token = random_token(32);
@@ -149,7 +150,8 @@ SET
frame_width = ?,
frame_height = ?,
frame_count = ?,
fps = ?
fps = ?,
duration_millis = ?
"#,
model_token,
template_type,
@@ -166,7 +168,8 @@ SET
frame_width,
frame_height,
frame_count,
fps
fps,
duration_millis
)
.execute(pool)
.await;
+3 -1
View File
@@ -227,6 +227,7 @@ struct FileMetadata {
pub height: u32,
pub num_frames: u64,
pub fps: Option<f32>,
pub duration_millis: Option<u64>,
}
fn read_metadata_file(filename: &str) -> AnyhowResult<FileMetadata> {
@@ -381,7 +382,8 @@ async fn process_job(downloader: &Downloader, job: &W2lTemplateUploadJobRecord)
file_metadata.width,
file_metadata.height,
file_metadata.num_frames,
file_metadata.fps.unwrap_or(0.0f32))
file_metadata.fps.unwrap_or(0.0f32),
file_metadata.duration_millis.unwrap_or(0))
.await?;
info!("Job {} complete success! Downloaded, processed, and uploaded. Saved model record: {}",