Skip to content

Commit

Permalink
Cleanups to libav support
Browse files Browse the repository at this point in the history
  • Loading branch information
emarsden committed Sep 3, 2023
1 parent cc786ac commit e8a16ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{is_audio_adaptation, is_video_adaptation, is_subtitle_adaptation};
use crate::{subtitle_type, content_protection_type, SubtitleType};
#[cfg(not(feature = "libav"))]
use crate::ffmpeg::concat_output_files;
#[allow(unused_imports)]
use crate::media::video_containers_concatable;


Expand Down
14 changes: 8 additions & 6 deletions src/libav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use std::cmp::{min, max};
use fs_err as fs;
use fs::File;
use std::path::Path;
use log::info;
use std::io::{BufReader, BufWriter};
use log::{info, trace};
use ac_ffmpeg::codec::CodecParameters;
use ac_ffmpeg::packet::Packet;
use ac_ffmpeg::time::Timestamp;
Expand All @@ -34,6 +35,7 @@ use ac_ffmpeg::format::muxer::Muxer;
use ac_ffmpeg::format::muxer::OutputFormat;
use crate::DashMpdError;
use crate::fetch::DashDownloader;
use crate::media::{audio_container_type, video_container_type};



Expand Down Expand Up @@ -216,7 +218,7 @@ pub fn mux_audio_video(


pub fn copy_video_to_container(
downloader: &DashDownloader,
_downloader: &DashDownloader,
output_path: &Path,
video_path: &Path) -> Result<(), DashMpdError>
{
Expand All @@ -243,7 +245,7 @@ pub fn copy_video_to_container(


pub fn copy_audio_to_container(
downloader: &DashDownloader,
_downloader: &DashDownloader,
output_path: &Path,
audio_path: &Path) -> Result<(), DashMpdError>
{
Expand All @@ -255,13 +257,13 @@ pub fn copy_audio_to_container(
// If the audio stream is already in the desired container format, we can just copy it to the
// output file.
if audio_container_type(audio_path)?.eq(container) {
let tmpfile_video = File::open(video_path)
let tmpfile_audio = File::open(audio_path)
.map_err(|e| DashMpdError::Io(e, String::from("opening temporary audio output file")))?;
let mut video = BufReader::new(tmpfile_video);
let mut audio = BufReader::new(tmpfile_audio);
let output_file = File::create(output_path)
.map_err(|e| DashMpdError::Io(e, String::from("creating output file for audio")))?;
let mut sink = BufWriter::new(output_file);
io::copy(&mut video, &mut sink)
io::copy(&mut audio, &mut sink)
.map_err(|e| DashMpdError::Io(e, String::from("copying audio stream to output file")))?;
return Ok(());
}
Expand Down
7 changes: 6 additions & 1 deletion src/media.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/// Common code for media handling.
// Common code for media handling.
//
// This file contains functions used both by the external subprocess muxing in ffmpeg.rs and the
// libav muxing in libav.rs.


// When building with the libav feature, several functions here are unused.

#![allow(dead_code)]


use std::path::{Path, PathBuf};
use file_format::FileFormat;
use log::warn;
Expand Down

0 comments on commit e8a16ae

Please sign in to comment.