Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admin committed Oct 7, 2024
1 parent b737100 commit 3344d30
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "video-rs"
name = "rsmedia"
description = "High-level video toolkit based on ffmpeg."
keywords = ["video", "ffmpeg", "encoding", "decoding", "muxing"]
categories = ["multimedia", "multimedia::video"]
version = "0.9.0"
authors = ["Oddity.ai Developers <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2021"
authors = ["Oddity.ai Developers <[email protected]>"]
repository = "https://github.com/oddity-ai/video-rs"
license = "MIT OR Apache-2.0"
readme = "README.md"

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions examples/decode_frame.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::error::Error;
use video_rs::decode::Decoder;
use video_rs::Url;
use rsmedia::decode::Decoder;
use url::Url;
use image::{ImageBuffer, Rgb};
use tokio::task;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
video_rs::init().unwrap();
rsmedia::init()?;

let source = "https://img.qunliao.info/4oEGX68t_9505974551.mp4".parse::<Url>().unwrap();
let mut decoder = Decoder::new(source).expect("failed to create decoder");
Expand Down
6 changes: 3 additions & 3 deletions examples/encode_video.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::path::Path;
use ndarray::Array3;
use video_rs::encode::{Encoder, Settings};
use video_rs::time::Time;
use rsmedia::encode::{Encoder, Settings};
use rsmedia::time::Time;

fn main() {
video_rs::init().unwrap();
rsmedia::init().unwrap();

let settings = Settings::preset_h264_yuv420p(1280, 720, false);
let mut encoder =
Expand Down
2 changes: 1 addition & 1 deletion src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ unsafe extern "C" fn log_callback(
ffi::AV_LOG_VERBOSE | ffi::AV_LOG_DEBUG => {
tracing::debug!(target: "video", "{}", line)
}
AV_LOG_TRACE => tracing::trace!(target: "video", "{}", line),
ffi::AV_LOG_TRACE => tracing::trace!(target: "video", "{}", line),
_ => {}
};
}
Expand Down
8 changes: 3 additions & 5 deletions src/io.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
extern crate ffmpeg_next as ffmpeg;

use ffmpeg::codec::packet::Packet as AvPacket;
use ffmpeg::ffi::AV_TIME_BASE_Q;
use ffmpeg::format::context::{Input as AvInput, Output as AvOutput};
use ffmpeg::media::Type as AvMediaType;
use ffmpeg::Error as AvError;
use ffmpeg_next::ffi::av_seek_frame;

use crate::error::Error;
use crate::ffi;
Expand Down Expand Up @@ -146,9 +144,9 @@ impl Reader {
/// * `timestamp_milliseconds` - Number of millisecond from start of video to seek to.
pub fn seek(&mut self, timestamp_milliseconds: i64) -> Result<()> {
// Conversion factor from timestamp in milliseconds to `TIME_BASE` units.
const CONVERSION_FACTOR: i64 = (AV_TIME_BASE_Q.den / 1000) as i64;
const CONVERSION_FACTOR: i64 = (ffmpeg::ffi::AV_TIME_BASE_Q.den / 1000) as i64;
// One second left and right leeway when seeking.
const LEEWAY: i64 = AV_TIME_BASE_Q.den as i64;
const LEEWAY: i64 = ffmpeg::ffi::AV_TIME_BASE_Q.den as i64;

let timestamp = CONVERSION_FACTOR * timestamp_milliseconds;
let range = timestamp - LEEWAY..timestamp + LEEWAY;
Expand All @@ -165,7 +163,7 @@ impl Reader {
/// * `frame_number` - The frame number to seek to.
pub fn seek_to_frame(&mut self, frame_number: i64) -> Result<()> {
unsafe {
match av_seek_frame(self.input.as_mut_ptr(), -1, frame_number, 0) {
match ffmpeg::ffi::av_seek_frame(self.input.as_mut_ptr(), -1, frame_number, 0) {
0 => Ok(()),
e => Err(Error::BackendError(AvError::from(e))),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use error::Error;
pub use frame::Frame;
pub use init::init;
pub use io::{Reader, ReaderBuilder, Writer, WriterBuilder};
pub use location::{Location, Url};
pub use location::Location;
pub use mux::{Muxer, MuxerBuilder};
pub use options::Options;
pub use packet::Packet;
Expand Down
2 changes: 1 addition & 1 deletion src/location.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Re-export [`url::Url`] since it is an input type for callers of the API.
pub use url::Url;
use url::Url;

/// Represents a video file or stream location. Can be either a file resource (a path) or a network
/// resource (a URL).
Expand Down

0 comments on commit 3344d30

Please sign in to comment.