feat: reinit muxer
This commit is contained in:
@ -20,9 +20,7 @@ pub struct Transcoder {
|
||||
|
||||
impl Transcoder {
|
||||
pub unsafe fn new(input: &str, output: &str) -> Result<Self> {
|
||||
let muxer = Muxer::builder()
|
||||
.with_output_path(output, None)?
|
||||
.build()?;
|
||||
let muxer = Muxer::builder().with_output_path(output, None)?.build()?;
|
||||
|
||||
Ok(Self {
|
||||
demuxer: Demuxer::new(input)?,
|
||||
@ -54,8 +52,8 @@ impl Transcoder {
|
||||
// Setup scaler if the size/format is different from what the codec expects
|
||||
if in_stream.stream_type == StreamType::Video
|
||||
&& (in_stream.width != (*out_ctx).width as usize
|
||||
|| in_stream.height != (*out_ctx).height as usize
|
||||
|| in_stream.format != (*out_ctx).pix_fmt as isize)
|
||||
|| in_stream.height != (*out_ctx).height as usize
|
||||
|| in_stream.format != (*out_ctx).pix_fmt as isize)
|
||||
{
|
||||
self.scalers.insert(src_index, Scaler::new());
|
||||
}
|
||||
@ -63,7 +61,7 @@ impl Transcoder {
|
||||
// Setup resampler for audio
|
||||
if in_stream.stream_type == StreamType::Audio
|
||||
&& (in_stream.format != (*out_ctx).sample_fmt as isize
|
||||
|| in_stream.sample_rate != (*out_ctx).sample_rate as usize)
|
||||
|| in_stream.sample_rate != (*out_ctx).sample_rate as usize)
|
||||
{
|
||||
let r = Resample::new(
|
||||
(*out_ctx).sample_fmt,
|
||||
@ -158,7 +156,7 @@ impl Transcoder {
|
||||
while !self.next()? {
|
||||
// nothing here
|
||||
}
|
||||
self.muxer.close()?;
|
||||
self.muxer.reset()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user