Skip to content
Snippets Groups Projects
Verified Commit 3ce91376 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Remove unnecessary metadata file

parent c28c69bf
No related branches found
No related tags found
No related merge requests found
#![allow(dead_code)]
pub mod spritesheet;
pub mod stream_metadata;
use std::path::Path;
......@@ -62,14 +61,6 @@ pub fn extract(
local_codec.name()?
);
let mut metadata = stream_metadata::StreamMetadata::new(
avformat_context
.input_format()?
.determine_mime(local_codec.name()?)?,
duration,
codec_parameters.bit_rate() / 1000,
);
let mut output_frame =
AVFrame::new().map_err(|error| format_err!("Could not create output frame: {}", error))?;
......@@ -110,7 +101,6 @@ pub fn extract(
if !spritesheet_manager.initialized() {
spritesheet_manager
.initialize(frame.width() as u32, frame.height() as u32);
metadata.set_frame_size(frame.width(), frame.height());
output_frame
.init(
spritesheet_manager.sprite_width() as i32,
......@@ -147,9 +137,5 @@ pub fn extract(
spritesheet_manager.save()?;
}
metadata
.save(output_folder.join("media.json"))
.map_err(|error| format_err!("Could not write stream metadata: {}", error))?;
Ok(())
}
use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use serde::{Deserialize, Serialize};
use media_time::MediaTime;
#[derive(Serialize, Deserialize)]
pub struct StreamMetadata {
content_type: String,
duration: i64,
bitrate: i64,
aspect_ratio: f32,
width: i32,
height: i32,
}
impl StreamMetadata {
pub fn new(content_type: impl AsRef<str>, duration: MediaTime, bitrate: i64) -> StreamMetadata {
StreamMetadata {
content_type: String::from(content_type.as_ref()),
duration: duration.seconds(),
bitrate,
aspect_ratio: 0.0,
width: 0,
height: 0,
}
}
pub fn set_frame_size(&mut self, width: i32, height: i32) {
self.width = width;
self.height = height;
self.aspect_ratio = (width as f64 / height as f64) as f32;
}
pub fn save(&self, path: impl AsRef<Path>) -> Result<(), std::io::Error> {
serde_json::to_writer(BufWriter::new(File::create(path)?), self)?;
Ok(())
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment