1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
pub mod error; pub mod file; pub mod transcoder; pub use self::{ error::{ TranscodeError, TranscodeResult, }, file::File, transcoder::{ AudioQuality, MediaProfile, Transcoder, VideoQuality, }, }; pub use windows_media_transcoding_bindings as bindings; #[cfg(test)] mod test { use super::*; use std::path::Path; #[test] fn it_works() { let _ = std::fs::create_dir_all("test_output").is_ok(); futures::executor::block_on(it_works_async()).unwrap(); let output_path = Path::new("./test_output/oof1.mp4"); assert!(output_path.exists()); assert!(output_path.is_file()); let data = std::fs::read(output_path).unwrap(); assert!(!data.is_empty()); } async fn it_works_async() -> Result<(), TranscodeError> { let transcoder = Transcoder::new()?; let input_file = File::open("./test_data/oof.mp4").await?; let output_file = File::create("./test_output/oof1.mp4", Default::default()).await?; let target_profile = MediaProfile::create_hevc(VideoQuality::HD1080p)?; let prepared_transcode = transcoder .prepare_transcode(&input_file, &output_file, &target_profile) .await?; prepared_transcode .transcode_with_progress(|progress| { dbg!(progress); }) .await?; Ok(()) } }