From de77f007cf7d169dfd703650d6b36be2213a5630 Mon Sep 17 00:00:00 2001 From: xufulong <839789740@qq.com> Date: Sun, 24 Oct 2021 00:27:34 +0800 Subject: [PATCH] update doc --- README.md | 3 - doc/FFmpeg_command_line.md | 161 ++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 08a7e8c..1b8a458 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,3 @@ When it finishes probing, the result of metadata will display on screen.
### Preview thumbnail when seeking: ![preview](https://github.com/xufuji456/FFmpegAndroid/blob/master/gif/preview.gif) -*** -

- diff --git a/doc/FFmpeg_command_line.md b/doc/FFmpeg_command_line.md index 1499328..88c6d73 100644 --- a/doc/FFmpeg_command_line.md +++ b/doc/FFmpeg_command_line.md @@ -7,71 +7,70 @@ ffprobe用于检测多媒体流格式;ffplay用于播放视频,包括本地与 # 一、ffmpeg命令行 ## 1、命令行参数介绍 Print help / information / capabilities:
---help topic show help
--version show version
--formats show available formats
--muxers show available muxers
--demuxers show available demuxers
--devices show available devices
--codecs show available codecs
--decoders show available decoders
--encoders show available encoders
--bsfs show available bit stream filters
--protocols show available protocols
--filters show available filters
--pix_fmts show available pixel formats
--sample_fmts show available audio sample formats
--hwaccels show available HW acceleration methods
+--help topic |show help
+-version |show version
+-formats |show available formats
+-muxers |show available muxers
+-demuxers |show available demuxers
+-devices |show available devices
+-codecs |show available codecs
+-decoders |show available decoders
+-encoders |show available encoders
+-bsfs |show available bit stream filters
+-protocols |show available protocols
+-filters |show available filters
+-pix_fmts |show available pixel formats
+-sample_fmts |show available audio sample formats
+-hwaccels |show available HW acceleration methods
Global options (affect whole program instead of just one file:
--v loglevel set logging level
--y overwrite output files
--n never overwrite output files
--filter_threads number of non-complex filter threads
--stats print progress report during encoding
--vol volume change audio volume (256=normal)
+-v loglevel |set logging level
+-y |overwrite output files
+-n |never overwrite output files
+-filter_threads |number of non-complex filter threads
+-stats |print progress report during encoding
+-vol volume |change audio volume (256=normal)
Per-file main options:
--f fmt force format
--c codec codec name
--codec codec codec name
--t duration record or transcode "duration" seconds of audio/video
--to time_stop record or transcode stop time
--fs limit_size set the limit file size in bytes
--ss time_off set the start time offset
--sseof time_off set the start time offset relative to EOF
--frames number set the number of frames to output
+-f fmt |force format
+-c codec |codec name
+-codec codec |codec name
+-t duration |record or transcode "duration" seconds of audio/video
+-to time_stop |record or transcode stop time
+-fs limit_size |set the limit file size in bytes
+-ss time_off |set the start time offset
+-sseof time_off |set the start time offset relative to EOF
+-frames number |set the number of frames to output
-filter filter_graph set stream filtergraph
--discard discard
--disposition disposition
+-discard |discard
+-disposition |disposition
Video options:
--vframes number set the number of video frames to output
--r rate set frame rate (Hz value, fraction or abbreviation)
--s size set frame size (WxH or abbreviation)
--aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
--bits_per_raw_sample number set the number of bits per raw sample
--vn disable video
--vcodec codec force video codec ('copy' to copy stream)
--timecode hh:mm:ss[:;.]ff set initial TimeCode value.
--vf filter_graph set video filters
--ab bitrate audio bitrate (please use -b:a)
--b bitrate video bitrate (please use -b:v)
+-vframes number |set the number of video frames to output
+-r rate |set frame rate (Hz value, fraction or abbreviation)
+-s size |set frame size (WxH or abbreviation)
+-aspect aspect |set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
+-vn |disable video
+-vcodec codec |force video codec ('copy' to copy stream)
+-timecode hh:mm:ss |set initial TimeCode value.
+-vf filter_graph |set video filters
+-ab bitrate |audio bitrate (please use -b:a)
+-b bitrate |video bitrate (please use -b:v)
Audio options:
--aframes number set the number of audio frames to output
--aq quality set audio quality (codec-specific)
--ar rate set audio sampling rate (in Hz)
--ac channels set number of audio channels
--an disable audio
--acodec codec force audio codec ('copy' to copy stream)
--vol volume change audio volume (256=normal)
--af filter_graph set audio filters
+-aframes number |set the number of audio frames to output
+-aq quality |set audio quality (codec-specific)
+-ar rate |set audio sampling rate (in Hz)
+-ac channels |set number of audio channels
+-an |disable audio
+-acodec codec |force audio codec ('copy' to copy stream)
+-vol volume |change audio volume (256=normal)
+-af filter_graph |set audio filters
Subtitle options:
--s size set frame size
--sn disable subtitle
--scodec codec force subtitle codec ('copy' to copy stream)
+-s size |set frame size
+-sn |disable subtitle
+-scodec codec |force subtitle codec ('copy' to copy stream)
命令行整体格式:以ffmpeg开头,参数之间用空格隔开,每个参数key以"-"开头,后面跟着参数value,输出文件放在命令行最后。
@@ -139,29 +138,29 @@ ffmpeg -ss 10 -i input.mp4 -f image2 -vframes 1 -an screenshot.jpg
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=10:20 pic_watermark.mp4
如果要灵活设置左上角、右上角、左下角、右下角位置,可以使用case语句,其中main_w代表视频宽度,
main_h代表视频高度,overlay_w代表水印宽度,overlay_h代表水印高度:
- -public static String obtainOverlay(int offsetX, int offsetY, int location) {
- switch (location) {
- case 2:
- return "overlay='(main_w-overlay_w)-" + offsetX + ":" + offsetY + "'";
- case 3:
- return "overlay='" + offsetX + ":(main_h-overlay_h)-" + offsetY + "'";
- case 4:
- return "overlay='(main_w-overlay_w)-" + offsetX + ":(main_h-overlay_h)-" + offsetY + "'";
- case 1:
- default:
- return "overlay=" + offsetX + ":" + offsetY;
- }
-}
- -public static String[] addWaterMarkImg(String inputPath, String imgPath, int location,
- int offsetXY, String outputPath) {
- String overlay = obtainOverlay(offsetXY, offsetXY, location);
- String waterMarkCmd = "ffmpeg -i %s -i %s -filter_complex %s -preset:v superfast %s";
- waterMarkCmd = String.format(waterMarkCmd, inputPath, imgPath, overlay, outputPath);
- return waterMarkCmd.split(" ");
-}
- +``` +public static String obtainOverlay(int offsetX, int offsetY, int location) { + switch (location) { + case 2: + return "overlay='(main_w-overlay_w)-" + offsetX + ":" + offsetY + "'"; + case 3: + return "overlay='" + offsetX + ":(main_h-overlay_h)-" + offsetY + "'"; + case 4: + return "overlay='(main_w-overlay_w)-" + offsetX + ":(main_h-overlay_h)-" + offsetY + "'"; + case 1: + default: + return "overlay=" + offsetX + ":" + offsetY; + } +} + +public static String[] addWaterMarkImg(String inputPath, String imgPath, int location, + int offsetXY, String outputPath) { + String overlay = obtainOverlay(offsetXY, offsetXY, location); + String waterMarkCmd = "ffmpeg -i %s -i %s -filter_complex %s -preset:v superfast %s"; + waterMarkCmd = String.format(waterMarkCmd, inputPath, imgPath, overlay, outputPath); + return waterMarkCmd.split(" "); +} +``` ### 3.5 GIF水印 使用-ignore_loop 0代表GIF循环显示,其他操作与图片水印一致:
ffmpeg -i input.mp4 -ignore_loop 0 -i logo.gif -filter_complex overlay=10:20 gif_mark.mp4
@@ -189,12 +188,8 @@ ffmpeg -ss 20 -accurate_seek -t 10 -i input.mp4 -an -r 5 %3d.jpg
使用setpts设置视频速度,atempo设置音频速度:
ffmpeg -i in.mp4 -filter_complex [0:v]setpts=%.2f*PTS[v];[0:a]atempo=%.2f[a] -map [v] -map [a] out.mp4
-### 3.12 插入封面 -其中-disposition:v:1 attached_pic代表封面:
-ffmpeg -i in.mp4 -i photo.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
- -### 3.13 旋转视频 -ffmpeg -i in.mp4 -c copy -metadata:s:v:0 rotate=90 out.mp4
+### 3.12 旋转视频 +ffmpeg -i in.mp4 -c copy -metadata:s:\v:0 rotate=90 out.mp4
# 二、ffplay命令行 ffplay主要用于播放视频,也可以播放网络流,示例如下: