debug video error

This commit is contained in:
Brandon Thomas committed 2024-08-08 21:26:04 -04:00
1 parent bda8cb5e10
commit 9cb340b194
6 files changed
+271 -55

No files matched your search

Generated
+189 -35
View File
@@ -2524,6 +2524,12 @@ dependencies = [
"zune-inflate",
]
[[package]]
name = "extended"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
[[package]]
name = "fastrand"
version = "1.9.0"
@@ -4165,7 +4171,7 @@ dependencies = [
"errors",
"log",
"my-workspace-hack",
"symphonia",
"symphonia 0.5.0",
]
[[package]]
@@ -6996,7 +7002,7 @@ dependencies = [
"sqlx",
"strum",
"strum_macros",
"symphonia",
"symphonia 0.5.0",
"thumbnail_generator",
"time",
"tokens",
@@ -7120,19 +7126,38 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"lazy_static",
"symphonia-bundle-flac",
"symphonia-bundle-flac 0.5.0",
"symphonia-bundle-mp3",
"symphonia-codec-aac",
"symphonia-codec-alac",
"symphonia-codec-opus",
"symphonia-codec-pcm",
"symphonia-codec-vorbis",
"symphonia-core",
"symphonia-format-isomp4",
"symphonia-format-mkv",
"symphonia-format-ogg",
"symphonia-codec-pcm 0.5.0",
"symphonia-codec-vorbis 0.5.0",
"symphonia-core 0.5.0",
"symphonia-format-isomp4 0.5.0",
"symphonia-format-mkv 0.5.0",
"symphonia-format-ogg 0.5.0",
"symphonia-format-wav",
"symphonia-metadata",
"symphonia-metadata 0.5.0",
]
[[package]]
name = "symphonia"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9"
dependencies = [
"lazy_static",
"symphonia-bundle-flac 0.5.4",
"symphonia-codec-adpcm",
"symphonia-codec-pcm 0.5.4",
"symphonia-codec-vorbis 0.5.4",
"symphonia-core 0.5.4",
"symphonia-format-isomp4 0.5.4",
"symphonia-format-mkv 0.5.4",
"symphonia-format-ogg 0.5.4",
"symphonia-format-riff",
"symphonia-metadata 0.5.4",
]
[[package]]
@@ -7141,9 +7166,21 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-utils-xiph",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
"symphonia-utils-xiph 0.5.0",
]
[[package]]
name = "symphonia-bundle-flac"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72e34f34298a7308d4397a6c7fbf5b84c5d491231ce3dd379707ba673ab3bd97"
dependencies = [
"log",
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
"symphonia-utils-xiph 0.5.4",
]
[[package]]
@@ -7154,8 +7191,8 @@ dependencies = [
"bitflags 1.3.2",
"lazy_static",
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
]
[[package]]
@@ -7165,7 +7202,17 @@ source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1d
dependencies = [
"lazy_static",
"log",
"symphonia-core",
"symphonia-core 0.5.0",
]
[[package]]
name = "symphonia-codec-adpcm"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c94e1feac3327cd616e973d5be69ad36b3945f16b06f19c6773fc3ac0b426a0f"
dependencies = [
"log",
"symphonia-core 0.5.4",
]
[[package]]
@@ -7174,7 +7221,7 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-core 0.5.0",
]
[[package]]
@@ -7183,7 +7230,7 @@ version = "0.0.1"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-core 0.5.0",
]
[[package]]
@@ -7192,7 +7239,17 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-core 0.5.0",
]
[[package]]
name = "symphonia-codec-pcm"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f395a67057c2ebc5e84d7bb1be71cce1a7ba99f64e0f0f0e303a03f79116f89b"
dependencies = [
"log",
"symphonia-core 0.5.4",
]
[[package]]
@@ -7201,8 +7258,19 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-utils-xiph",
"symphonia-core 0.5.0",
"symphonia-utils-xiph 0.5.0",
]
[[package]]
name = "symphonia-codec-vorbis"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a98765fb46a0a6732b007f7e2870c2129b6f78d87db7987e6533c8f164a9f30"
dependencies = [
"log",
"symphonia-core 0.5.4",
"symphonia-utils-xiph 0.5.4",
]
[[package]]
@@ -7217,6 +7285,19 @@ dependencies = [
"log",
]
[[package]]
name = "symphonia-core"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "798306779e3dc7d5231bd5691f5a813496dc79d3f56bf82e25789f2094e022c3"
dependencies = [
"arrayvec",
"bitflags 1.3.2",
"bytemuck",
"lazy_static",
"log",
]
[[package]]
name = "symphonia-format-isomp4"
version = "0.5.0"
@@ -7224,9 +7305,22 @@ source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1d
dependencies = [
"encoding_rs",
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-utils-xiph",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
"symphonia-utils-xiph 0.5.0",
]
[[package]]
name = "symphonia-format-isomp4"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abfdf178d697e50ce1e5d9b982ba1b94c47218e03ec35022d9f0e071a16dc844"
dependencies = [
"encoding_rs",
"log",
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
"symphonia-utils-xiph 0.5.4",
]
[[package]]
@@ -7236,9 +7330,22 @@ source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1d
dependencies = [
"lazy_static",
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-utils-xiph",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
"symphonia-utils-xiph 0.5.0",
]
[[package]]
name = "symphonia-format-mkv"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bb43471a100f7882dc9937395bd5ebee8329298e766250b15b3875652fe3d6f"
dependencies = [
"lazy_static",
"log",
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
"symphonia-utils-xiph 0.5.4",
]
[[package]]
@@ -7247,9 +7354,33 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-utils-xiph",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
"symphonia-utils-xiph 0.5.0",
]
[[package]]
name = "symphonia-format-ogg"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ada3505789516bcf00fc1157c67729eded428b455c27ca370e41f4d785bfa931"
dependencies = [
"log",
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
"symphonia-utils-xiph 0.5.4",
]
[[package]]
name = "symphonia-format-riff"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f7be232f962f937f4b7115cbe62c330929345434c834359425e043bfd15f50"
dependencies = [
"extended",
"log",
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
]
[[package]]
@@ -7258,8 +7389,8 @@ version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"log",
"symphonia-core",
"symphonia-metadata",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
]
[[package]]
@@ -7270,7 +7401,19 @@ dependencies = [
"encoding_rs",
"lazy_static",
"log",
"symphonia-core",
"symphonia-core 0.5.0",
]
[[package]]
name = "symphonia-metadata"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc622b9841a10089c5b18e99eb904f4341615d5aa55bbf4eedde1be721a4023c"
dependencies = [
"encoding_rs",
"lazy_static",
"log",
"symphonia-core 0.5.4",
]
[[package]]
@@ -7278,8 +7421,18 @@ name = "symphonia-utils-xiph"
version = "0.5.0"
source = "git+https://github.com/pdeljanov/Symphonia.git?rev=e1a70095c4409478c1ded499fb8dd4afa540fb90#e1a70095c4409478c1ded499fb8dd4afa540fb90"
dependencies = [
"symphonia-core",
"symphonia-metadata",
"symphonia-core 0.5.0",
"symphonia-metadata 0.5.0",
]
[[package]]
name = "symphonia-utils-xiph"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "484472580fa49991afda5f6550ece662237b00c6f562c7d9638d1b086ed010fe"
dependencies = [
"symphonia-core 0.5.4",
"symphonia-metadata 0.5.4",
]
[[package]]
@@ -8226,6 +8379,7 @@ dependencies = [
"log",
"mp4",
"my-workspace-hack",
"symphonia 0.5.4",
"testing",
]
+5
View File
@@ -27,7 +27,12 @@ my-workspace-hack = { version = "0.1", path = "../../../my-workspace-hack" }
# External
ffprobe = "0.4.0"
log = "0.4.20"
symphonia = { version = "0.5.4", features = ["isomp4"] }
# TODO(bt,2024-08-08): We might drop `mp4` crate because it crashes on reading
# some videos with the message "avcc not found"
mp4 = "0.14.0"
[dev-dependencies]
testing = { path = "../../testing" }
@@ -69,19 +69,11 @@ pub fn get_mp4_info<T: Seek + Read>(reader: T, file_size: u64) -> AnyhowResult<M
pub mod tests {
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
use testing::test_file_path::test_file_path;
use crate::get_mp4_info::get_mp4_info;
fn test_file(path_from_repo_root: &str) -> PathBuf {
// https://doc.rust-lang.org/cargo/reference/environment-variables.html
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push(format!("../../../{}", path_from_repo_root));
path
}
#[test]
pub fn test_decode_mp4() {
let filename = test_file_path("test_data/video/mp4/golden_sun_garoh.mp4")
@@ -0,0 +1,61 @@
/*
use std::io::{Read, Seek};
use std::time::Duration;
use log::warn;
use mp4::TrackType;
use symphonia::core::codecs::{CODEC_TYPE_NULL, DecoderOptions};
use symphonia::core::formats::FormatOptions;
use symphonia::core::io::{MediaSource, MediaSourceStream};
use symphonia::core::meta::MetadataOptions;
use symphonia::core::probe::Hint;
use errors::{anyhow, AnyhowResult};
use crate::get_mp4_info::Mp4Info;
pub fn get_mp4_info_symphonia<T: Seek + Read>(media_source: Box<dyn MediaSource>) -> AnyhowResult<Mp4Info> {
let mss = MediaSourceStream::new(media_source, Default::default());
let mut hint = Hint::new();
hint.with_extension("mp4");
// Use the default options for metadata and format readers.
let meta_opts: MetadataOptions = Default::default();
let fmt_opts: FormatOptions = Default::default();
// Probe the media source.
let probed = symphonia::default::get_probe()
.format(&hint, mss, &fmt_opts, &meta_opts)
.expect("unsupported format");
// Get the instantiated format reader.
let mut format = probed.format;
format.metadata();
// Find the first audio track with a known (decodeable) codec.
let track = format
.tracks()
.iter()
.find(|t| t.codec_params.codec != CODEC_TYPE_NULL)
.ok_or_else(|| anyhow!("no supported audio tracks"))?;
// Use the default options for the decoder.
let dec_opts: DecoderOptions = Default::default();
// Create a decoder for the track.
let mut decoder = symphonia::default::get_codecs()
.make(&track.codec_params, &dec_opts)?;
// Store the track identifier, it will be used to filter packets.
let track_id = track.id;
Ok(Mp4Info {
framerate,
duration_millis: mp4.duration().as_millis(),
width,
height,
})
}
*/
+2 -1
View File
@@ -19,4 +19,5 @@
#![allow(non_snake_case)]
pub mod ffprobe_get_dimensions;
pub mod get_mp4_info;
pub mod get_mp4_info;
pub mod get_mp4_info_symphonia;
@@ -203,6 +203,20 @@ pub async fn upload_new_video_media_file_handler(
// ==================== FILE VALIDATION ==================== //
info!("temporary file location: {:?}", form.file.file.path());
match ffprobe_get_dimensions(form.file.file.path()) {
Err(err) => {
warn!("Error reading video dimensions with ffprobe: {:?}", err);
}
Ok(Some(dims)) => {
info!("Video dimensions: {}x{}", dims.width, dims.height);
}
Ok(None) => {
warn!("No video dimensions found");
}
}
let mut file_bytes = Vec::new();
form.file.file.read_to_end(&mut file_bytes)
.map_err(|e| {
@@ -229,17 +243,6 @@ pub async fn upload_new_video_media_file_handler(
// ==================== DURATION DETECTION ==================== //
match ffprobe_get_dimensions(form.file.file.path()) {
Err(err) => {
warn!("Error reading video dimensions with ffprobe: {:?}", err);
}
Ok(Some(dims)) => {
info!("Video dimensions: {}x{}", dims.width, dims.height);
}
Ok(None) => {
warn!("No video dimensions found");
}
}
let mp4_info = get_mp4_info_for_bytes(file_bytes.as_ref())
.map_err(|err| {