fix encoder
This commit is contained in:
parent
cabd109554
commit
da1f18b427
1 changed files with 24 additions and 21 deletions
45
src/main.rs
45
src/main.rs
|
@ -403,27 +403,30 @@ async fn main() {
|
||||||
.set_repeat(gif::Repeat::Finite(0))
|
.set_repeat(gif::Repeat::Finite(0))
|
||||||
.expect("encode: unable to set repeat");
|
.expect("encode: unable to set repeat");
|
||||||
println!("encode: encoding {n}...");
|
println!("encode: encoding {n}...");
|
||||||
for i in (n * (25 * 5) + 1)..=dir {
|
for i in (n * (25 * 5))..dir {
|
||||||
let decoder = Decoder::new(
|
{
|
||||||
File::open(format!("vid/{}.png", i))
|
let i = i + 1;
|
||||||
.expect(format!("encode: unable to read vid/{}.png", i).as_str()),
|
let decoder = Decoder::new(
|
||||||
);
|
File::open(format!("vid/{}.png", i))
|
||||||
let mut reader = decoder
|
.expect(format!("encode: unable to read vid/{}.png", i).as_str()),
|
||||||
.read_info()
|
);
|
||||||
.expect(format!("encode: invalid ffmpeg output in vid/{}.png", i).as_str());
|
let mut reader = decoder
|
||||||
let mut buf: Vec<u8> = vec![0; reader.output_buffer_size()];
|
.read_info()
|
||||||
let info = reader
|
.expect(format!("encode: invalid ffmpeg output in vid/{}.png", i).as_str());
|
||||||
.next_frame(&mut buf)
|
let mut buf: Vec<u8> = vec![0; reader.output_buffer_size()];
|
||||||
.expect(format!("encode: invalid ffmpeg output in vid/{}.png", i).as_str());
|
let info = reader
|
||||||
let bytes = &mut buf[..info.buffer_size()];
|
.next_frame(&mut buf)
|
||||||
let mut frame = gif::Frame::from_rgb(240, 180, bytes);
|
.expect(format!("encode: invalid ffmpeg output in vid/{}.png", i).as_str());
|
||||||
frame.delay = 4;
|
let bytes = &mut buf[..info.buffer_size()];
|
||||||
encoder
|
let mut frame = gif::Frame::from_rgb(240, 180, bytes);
|
||||||
.as_mut()
|
frame.delay = 4;
|
||||||
.unwrap()
|
encoder
|
||||||
.write_frame(&frame)
|
.as_mut()
|
||||||
.expect("encode: unable to encode frame to gif");
|
.unwrap()
|
||||||
if i / (25 * 5) != n + 1 {
|
.write_frame(&frame)
|
||||||
|
.expect("encode: unable to encode frame to gif");
|
||||||
|
}
|
||||||
|
if i / (25 * 5) != n {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue