-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ffmpeg-tool-rs | ||
|
||
一个关于ffmpeg的常用工具 | ||
|
||
## usage | ||
|
||
### 多个视频合并成一个 | ||
|
||
比如当前有2个视频`IMG_1767.MOV`以及`IMG_1768.MOV`,需要将这2个视频合并成一个视频, | ||
你需要指定`-r IMG_(.*).MOV`并且指定开始的id(`--reg-file-start=`)以及结束的id(`--reg-file-end=`) | ||
则执行下面的命令即可,会得到一个`IMG_.MOV`的合并后的视频文件。 | ||
|
||
``` | ||
ffmpeg-tool-rs combine -r IMG_\(\.\*\).MOV --reg-file-start=1767 --reg-file-end=1768 | ||
``` | ||
|
||
当然也可以指定生成后的文件名,需要跟上`--target_file_name=your_filename.MOV` | ||
|
||
|
||
### 下载视频 | ||
|
||
``` | ||
ffmpeg-tool-rs download --url=https://zmis.me/xxx.m3u8 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
|
||
pub fn now() -> u64 { | ||
let now = SystemTime::now(); | ||
return now.duration_since(UNIX_EPOCH) | ||
.expect("Time went backwards") | ||
.as_secs(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pub mod download { | ||
use std::fmt::{Error, format}; | ||
use std::process::Command; | ||
use crate::common::now; | ||
|
||
pub fn download(url: String, file_name: String) -> Result<bool, Error> { | ||
let mut binding = Command::new("ffmpeg"); | ||
let res = binding.arg("-i") | ||
.arg(url.to_owned()) | ||
.arg("-c") | ||
.arg("copy") | ||
.arg("-bsf:a") | ||
.arg("aac_adtstoasc") | ||
.arg(file_name.to_owned()).output().unwrap().status; | ||
if res.success() { | ||
Ok(true) | ||
} else { | ||
println!("{}", res.to_string()); | ||
Ok(false) | ||
} | ||
} | ||
|
||
pub fn get_file_name(file_name: String) -> String { | ||
let mut target = file_name; | ||
if target.is_empty() { | ||
target = format!("./{}.mp4", now()); | ||
} | ||
target | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters