Struct sm_motion_photo::SmMotion[][src]

pub struct SmMotion {
    pub video_index: Option<usize>,
    // some fields omitted
}

Simple extractor of Motion Photo taken on Samsung phone (if it provides such feature and this feature is turned on) and saves it in MP4. It is available on Galaxy S20, S20+, S20 Ultra, Z Flip, Note10, Note10+, S10e, S10, S10+, Fold, Note9, S9, S9+, Note8, S8, S8+, S7, and S7 edge.

Example of usage:

use std::fs::File;
use sm_motion_photo::SmMotion;

// open file
let photo_file = File::open("tests/data/photo.jpg").unwrap();
let mut sm = SmMotion::with(&photo_file).unwrap();
println!("JPEG file contains video? {:?}", sm.has_video());
let mut video_file = File::create("tests/tmp/video.mp4").unwrap();
// dump mp4 from jpeg
sm.dump_video_file(&mut video_file).unwrap();
// get video duration (no dump needed)
println!("{:?}", sm.get_video_file_duration());
// get MP4 file context
println!("{:?}", sm.find_video_context());
// You can also save index and use it afterwards
let mut sm_cached = SmMotion::with_precalculated(&photo_file, 3366251).unwrap();
println!("{:?}", sm_cached.get_video_file_duration());

Fields

video_index: Option<usize>

Index where starts a video

Implementations

impl SmMotion[src]

pub fn with(file: &File) -> Option<SmMotion>[src]

First things first send here a file ref

pub fn with_precalculated(file: &File, index: usize) -> Option<SmMotion>[src]

Initialize SmMotion with a known video index. It's handful when you are caching the results of searching.

pub fn find_video_index(&mut self) -> Result<Option<usize>, &'static str>[src]

Look for starting MP4 index in Samsung Motion Photo JPEG (or HEIC/HEIF) file

pub fn has_video(&self) -> bool[src]

Check if a photo has a Motion Photo feature

pub fn find_video_context(&self) -> Option<MediaContext>[src]

Get video context from mp4parse.

pub fn get_video_file_duration(&self) -> Option<u64>[src]

Gen length of video file in photo in milliseconds

pub fn dump_video_file(&self, file: &mut File) -> Result<(), &str>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.