ffmpeg not mandatory

This commit is contained in:
lifning 2021-12-10 15:53:02 -08:00
parent 2dd8556fe2
commit 82217ff117
2 changed files with 11 additions and 8 deletions

View File

@ -28,4 +28,4 @@ sdl2_comp = ["sdl2", "gl", "crossbeam-channel"]
[[example]]
name = "multifunction_emulator"
required-features = ["sdl2_comp", "ffmpeg_comp"]
required-features = ["sdl2_comp"]

View File

@ -1,5 +1,6 @@
extern crate crossbeam_channel;
extern crate ferretro_components;
#[cfg(feature = "ffmpeg_comp")]
extern crate ffmpeg_next as ffmpeg;
extern crate sdl2;
@ -7,14 +8,14 @@ use std::path::PathBuf;
use sdl2::video::FullscreenType;
use structopt::StructOpt;
use ferretro_components::base::ControlFlow;
use ferretro_components::prelude::*;
use ferretro_components::provided::{
ffmpeg::FfmpegComponent,
sdl2::*,
stdlib::*,
};
use ferretro_components::base::ControlFlow;
#[cfg(feature = "ffmpeg_comp")]
use ferretro_components::provided::ffmpeg::FfmpegComponent;
#[derive(StructOpt)]
struct Opt {
@ -31,8 +32,9 @@ struct Opt {
#[structopt(short, long, parse(from_os_str))]
system: Option<PathBuf>,
/// Recorded video to write.
#[structopt(short, long, parse(from_os_str))]
video: Option<PathBuf>,
#[cfg(feature = "ffmpeg_comp")]
#[structopt(long, parse(from_os_str))]
record_video: Option<PathBuf>,
/// Disable OpenGL context creation.
#[structopt(long)]
no_opengl: bool,
@ -68,10 +70,11 @@ pub fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// must register before opengl so it can have priority in queries about what N64 plugin to use
// (only supports software-rendered 2D frames currently)
if let Some(video) = opt.video {
#[cfg(feature = "ffmpeg_comp")]
if let Some(video_path) = opt.record_video {
ffmpeg::log::set_level(ffmpeg::log::Level::Info);
ffmpeg::init()?;
let ffmpeg_comp = FfmpegComponent::new(emu.libretro_core(), video);
let ffmpeg_comp = FfmpegComponent::new(emu.libretro_core(), video_path);
emu.register_component(ffmpeg_comp)?;
}