#heic #jpeg #heif #motion-photo #samsung-motion-photo

sm_motion_photo

Extract video from Samsung Motion Photo. Supports JPEG, HEIF/HEIC

6 releases

0.1.5 Feb 14, 2021
0.1.4 Oct 27, 2020
0.1.2 May 6, 2020

#743 in Images

Download history 90/week @ 2024-07-27 136/week @ 2024-08-03 121/week @ 2024-08-10 32/week @ 2024-08-17 16/week @ 2024-08-24 52/week @ 2024-08-31 72/week @ 2024-09-07 29/week @ 2024-09-14 47/week @ 2024-09-21 60/week @ 2024-09-28 44/week @ 2024-10-05 104/week @ 2024-10-12 76/week @ 2024-10-19 39/week @ 2024-10-26 58/week @ 2024-11-02 30/week @ 2024-11-09

219 downloads per month

MIT license

9KB
103 lines

SM Motion Photo

Build Status codecov docs crates

This crate provides functions for extracting video from Motion Photos and getting meta-information from the video. It is a feature of Samsung phones, a JPEG file with a video file embedded.

This feature 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.

Supports photos saved in JPEG and HEIF (HEIC) format.

Usage

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

// open file
let photo_file = File::open("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("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());

Dependencies

~0.7–1MB
~17K SLoC