Don't try to write an audio frame if there aren't any planes

This commit is contained in:
viv 2021-08-01 00:08:18 -07:00
parent 3beb1a8519
commit 3cad3b1e29
1 changed files with 29 additions and 28 deletions

View File

@ -308,12 +308,12 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
}
}
// Assumption: if there is a video frame, there is an audio frame.
let mut aframe = frame::Audio::new(
format::Sample::I16(format::sample::Type::Packed),
self.audio_buf.len(),
ChannelLayout::STEREO
);
if aframe.planes() > 0 {
aframe.set_channels(2);
aframe.set_rate(44100);
aframe.set_pts(Some(frame));
@ -348,6 +348,7 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
}
}
}
}
},
None => println!("Video not ready during frame {}", self.frame)
}