ffmpeg 常用命令汇总
ffmpeg -filter指令

5.
视频旋转:用于旋转视频,可以指定角度。 例子:-filter:v "rotate=90"
6.
7.
视频加水印:用于在视频中添加水印。 例子:-filter_complex "overlay=10:10"
8.
9.
视频转换格式:用于将视频转换为其他格式。 例子:-filter:v "format=yuv420p"
1ห้องสมุดไป่ตู้.
11.
视频加速/减速:用于调整视频的播放速度。 例子:-filter:v "setpts=0.5*PTS"
12.
13.
音频混音:用于将多个音频混合成一个。 例子:-filter_complex "[0:a][1:a]amerge=inputs=2[aout]"
14.
这些只是常用的一些-filter指令,FFmpeg还有许多其他强大的过滤器和处理器,可以满足不同的需求。
在FFmpeg中,-filter指令用于对媒体进行各种过滤和处理操作。下面是一些常用的-filter指令:
1.
视频裁剪:用于裁剪视频中的一部分,可以指定起始时间和持续时间。 例子:-filter:v "trim=start=10:duration=5"
2.
3.
视频缩放:用于调整视频的大小,可以指定宽度和高度。 例子:-filter:v "scale=640:360"
FFMPEG常用命令-格式转换-持续更新中

FFMPEG常⽤命令-格式转换-持续更新中---恢复内容开始---ffmpeg是⼀个强⼤的⼯具,在⼯作中各种格式转换,编码,提取视频中的帧需要⽤到,记录下⼯作中常⽤的⼀些ffmpeg命令,持续更新中...将输⼊的infile视频⽂件通过avc编码成h264的视频流ffmpeg -i infile.mp4 -an -vcodec libx264 -crf 23 outfile.h264-i input file -an disable audio -vcodec 指定编码类型 -crf 采⽤cf的编码⽅式并设定level为23(CRF和QP的区别详见)将输⼊的handshake视频⽂件转码成dest1视频⽂件ffmpeg -i handshake.avi -c:v libx264 -preset slow -qp 37 -c:a copy dest1.mp4-i input file -c:v 和-codec:v以及-vcodec是⼀个意思,设置video的codec⽅式-preset 设置⼀些编码参数,有很多levelultrafastsuperfastveryfastfasterfastmedium – default presetslowslowerveryslowplacebo(⼀般不⽤)可以省略,默认是"medium",越慢质量越⾼-qp 设置固定的量化参数 -c:a 等同于-acodec和-codec:a 设置audio的codec⽅式是copy将⼀个⽂件夹的所有视频每隔⼀定帧数提取出图⽚for %%i in (*.mov) do (ffmpeg -i %%i -vf "select=not(mod(n\,50))" -vsync vfr "%%~ni_%%03d.bmp")for %%i in (*.mov) 遍历⽂件夹中所有mov为后缀的⽂件-i input video -vf 等同于-filter:v 具体信息参见 select选择哪些输⼊帧会输出,这边选择的是所有整除50的需要输出第0,50,100... -vsync 设置视频的同步⽅式这⾥的vfr是指传timestamp,如果两帧相同的timestamp需要丢掉最后"%%~ni_%%03d.bmp"是指输出的bmp的名字是输⼊的video的名字后⾯加上001 002 003等从⼀个input raw 视频中抽取出每⼀帧ffmpeg -f rawvideo -framerate 25 -s 1280x720 -pixel_format yuv420p -i in.yuv -c copy -f segment -segment_time 0.01 frames%d.yuv-f 指定输⼊的format为rawvideo -framerate设置帧率 -s 设置输⼊视频的分辨率 -pixel_format设置输⼊视频的格式 -i 输⼊的raw视频 -c 设置输⼊到输出的codec⽅式,这⾥为copy,不需要编解码 -f 指定输出格式,把输⼊的video分成好多个⼩段,只要后⾯设置的segment_time(0.01)⽐⼀帧的时间短(这⾥是1/25=0.04),就会把⼀帧分成⼀段,然后存⼊到yuv中---恢复内容结束---ffmpeg是⼀个强⼤的⼯具,在⼯作者各种格式转换,编码,提取视频中的帧需要⽤到,记录下⼯作中常⽤的⼀些ffmpeg命令,持续更新中...将输⼊的infile视频⽂件通过avc编码成h264的视频流ffmpeg -i infile.mp4 -an -vcodec libx264 -crf 23 outfile.h264-i input file -an disable audio -vcodec 指定编码类型 -crf 采⽤cf的编码⽅式并设定level为23(CRF和QP的区别详见)将输⼊的handshake视频⽂件转码成dest1视频⽂件ffmpeg -i handshake.avi -c:v libx264 -preset slow -qp 37 -c:a copy dest1.mp4-i input file -c:v 和-codec:v以及-vcodec是⼀个意思,设置video的codec⽅式-preset 设置⼀些编码参数,有很多levelultrafastsuperfastveryfastfasterfastmedium – default presetslowslowerveryslowplacebo(⼀般不⽤)可以省略,默认是"medium",越慢质量越⾼-qp 设置固定的量化参数 -c:a 等同于-acodec和-codec:a 设置audio的codec⽅式是copy将⼀个⽂件夹的所有视频每隔⼀定帧数提取出图⽚for %%i in (*.mov) do (ffmpeg -i %%i -vf "select=not(mod(n\,50))" -vsync vfr "%%~ni_%%03d.bmp")for %%i in (*.mov) 遍历⽂件夹中所有mov为后缀的⽂件-i input video -vf 等同于-filter:v 具体信息参见 select选择哪些输⼊帧会输出,这边选择的是所有整除50的需要输出第0,50,100... -vsync 设置视频的同步⽅式这⾥的vfr是指传timestamp,如果两帧相同的timestamp需要丢掉最后"%%~ni_%%03d.bmp"是指输出的bmp的名字是输⼊的video的名字后⾯加上001 002 003等从⼀个input raw 视频中抽取出每⼀帧ffmpeg -f rawvideo -framerate 25 -s 1280x720 -pixel_format yuv420p -i in.yuv -c copy -f segment -segment_time 0.01 frames%d.yuv-f 指定输⼊的format为rawvideo -framerate设置帧率 -s 设置输⼊视频的分辨率 -pixel_format设置输⼊视频的格式 -i 输⼊的raw视频 -c 设置输⼊到输出的codec⽅式,这⾥为copy,不需要编解码 -f 指定输出格式,把输⼊的video分成好多个⼩段,只要后⾯设置的segment_time(0.01)⽐⼀帧的时间短(这⾥是1/25=0.04),就会把⼀帧分成⼀段,然后存⼊到yuv中利⽤ffmpeg计算ssim/psnrffmpeg -s 1920x1080 -i F1.yuv -s 1920x1080 -i F2.yuv -lavfi"ssim="stats_file=stats_ssim.log";[0:v][1:v]"psnr="stats_psnr.log"-f null -F1.yuv为需要计算ssim的视频 F2.yuv为参考视频 -s设置分辨率 -i设置input视频ffmpeg-filters.html-lavfi是跟-filter_complex⼀个意思,设置滤波器,ffmpeg⽀持的filter有很多种类型,在下载的ffmpeg的包⾥⾯有⼀个叫做ffmpeg-filters.htm的⽹页就是讲的⽀持的各种filter, 详见ssim是其中⽀持的⼀个filter,在使⽤ssim的时候,要求输⼊的两个video要有相同的format resolution,⽽且帧数要⼀样每⼀帧都会算⼀个ssim的值。
ffmpeg 6.0使用手册

文章内容:一、介绍ffmpeg是一个广泛使用的开源多媒体工具包,可以用于录制、转换和流化音频和视频。
在本文中,我们将详细介绍ffmpeg 6.0的使用手册,以便读者能够更好地了解和使用这一工具。
二、安装和运行要使用ffmpeg 6.0,首先需要进行安装。
在Linux系统中,可以通过包管理器进行安装;在Windows系统中,可以下载预编译的可执行文件。
安装完成后,可以通过命令行终端运行ffmpeg,进行音视频处理操作。
三、基本命令ffmpeg提供了丰富的命令,可以进行音视频处理、转码、剪辑等操作。
常用的命令包括:- `-i`:指定输入文件- `-c`:指定编解码器- `-f`:指定输出格式- `-ss`:指定起始时间- `-t`:指定持续时间- `filterplex`:复杂过滤器的使用四、高级功能除了基本命令外,ffmpeg还提供了许多高级功能,包括:- 多路转码:可以同时对多个音视频流进行转码处理- 实时流化:可以将音视频实时流化到网络- 视频编辑:可以对视频进行裁剪、拼接、滤镜等操作五、个人观点ffmpeg是一个功能强大、灵活多样的多媒体工具,可以满足各种音视频处理需求。
通过学习和使用ffmpeg 6.0,不仅可以提升音视频处理能力,还可以为个人和企业带来更多的创造和商业机会。
六、总结在本文中,我们详细介绍了ffmpeg 6.0的使用手册,包括安装和运行、基本命令、高级功能等内容。
通过阅读本文,希望读者能够更全面地了解和掌握ffmpeg 6.0,从而在音视频处理领域取得更好的成就。
以上就是我撰写的关于ffmpeg 6.0使用手册的文章。
希望对你有所帮助!七、应用场景ffmpeg 6.0在实际应用中有广泛的场景,包括但不限于以下几个方面:1. 视频编辑和制作:通过ffmpeg可以轻松实现视频的剪辑、拼接、添加滤镜、调整画面亮度、对比度等操作,是视频编辑和制作领域的利器。
2. 音频处理和转换:除了视频处理,ffmpeg也可以用于音频领域,包括音频格式转换、音频剪辑、音频合并等,满足了音频处理的需求。
ffmpeg常用的命令

ffmpeg常用的命令ffmpeg是一个强大的多媒体处理工具,它可以处理视频、音频和图像等多种多媒体格式。
本文将介绍一些ffmpeg常用的命令及其用法。
一、视频处理命令1. 视频格式转换ffmpeg -i input.mp4 output.avi这个命令将把input.mp4转换为output.avi的格式。
其中,input.mp4是要转换的视频文件,output.avi是转换后的视频文件。
2. 视频剪切ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:30 -c copy output.mp4这个命令将从input.mp4中剪切出从第10秒开始,时长为30秒的视频,并保存为output.mp4。
其中,-ss参数指定开始剪切的时间,-t参数指定剪切的时长,-c copy参数表示直接复制视频流,不进行重新编码。
3. 视频合并ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4这个命令将把input1.mp4和input2.mp4两个视频文件合并为一个output.mp4。
其中,-filter_complex参数指定复杂的滤镜图,[0:v][0:a][1:v][1:a]表示两个视频文件的视频流和音频流,concat=n=2:v=1:a=1[outv][outa]表示合并后的视频流和音频流。
-map参数指定输出的视频流和音频流。
二、音频处理命令1. 音频格式转换ffmpeg -i input.mp3 output.wav这个命令将把input.mp3转换为output.wav的格式。
FMPEG常用指令

FMPEG常用指令1.查看视频信息2.ffmpeg -i /路径2.播放视频3.ffplay /路径3.旋转视频ffmpeg -i 123456.mp4 -metadata:s:v rotate='90' -codec copy output_success.mp4 -------------------4.MP4 转化为 GIFffmpeg -i small.mp4 small.gif•转化视频中的一部分为 GIF:ffmpeg -t 3 -ss 00:00:02 -i small.webm small-clip.gif从视频中第二秒开始,截取时长为3秒的片段转化为 gif5.转化高质量 GIF6.默认转化是中等质量模式,若要转化出高质量的 gif,可以修改比特率ffmpeg -i small.mp4 -b 2048k small.gif6.视频属性调整,缩放视频尺寸ffmpeg -i big.mov -vf scale=360:-1 small.mov注意 sacle 值必须是偶数,这里的 -1 表示保持长宽比,根据宽度值自适应高度。
如果要求压缩出来的视频尺寸长宽都保持为偶数,可以使用 -27.加倍速播放视频ffmpeg -i input.mov -filter:v 'setpts=0.5*PTS' output.mov•定义帧率 16fps:ffmpeg -i input.mov -r 16 -filter:v 'setpts=0.125*PTS' -an output.mov8.慢倍速播放视频ffmpeg -i input.mov -filter:v 'setpts=2.0*PTS' output.mov•静音视频(移除视频中的音频)ffmpeg -i input.mov -an mute-output.mov-an 就是禁止音频输出9.将 GIF 转化为 MP4ffmpeg -f gif -i animation.gif animation.mp4•也可以将 gif 转为其他视频格式ffmpeg -f gif -i animation.gif animation.mpegffmpeg -f gif -i animation.gif animation.webm获取 GIF 的第一帧图片使用 ImageMagick 可以方便第提取 gif 图片的第 N 帧图像。
ffmpeg命令使用

ffmpeg命令使用FFmpeg是一款强大的开源多媒体框架,被广泛用于音视频处理和转码。
它支持众多音视频格式,具备丰富的功能和灵活的编解码能力。
下面将一步一步地介绍FFmpeg的命令使用,帮助用户更好地了解和使用这个工具。
第一步:安装FFmpeg首先,在命令行或终端中输入以下命令来安装FFmpeg:sudo apt-get install ffmpeg如果你使用的是Windows系统,可以从FFmpeg官网()上下载预编译好的二进制文件,并将其添加到系统的环境变量中。
第二步:基本命令的使用在命令行或终端中,你可以输入以下命令:ffmpeg -i input_file output_file其中,input_file是待处理的音视频文件的路径,output_file是处理后的音视频文件的路径。
通过这个命令,你可以实现简单的音视频转码功能。
第三步:音视频转码FFmpeg能够处理各种音视频格式之间的相互转换。
例如,将MP4格式的视频转换为AVI格式,可以使用以下命令:ffmpeg -i input.mp4 -f avi output.avi其中,-i参数指定了输入文件,-f参数指定了输出格式。
你可以根据实际情况替换输入和输出文件的路径,以及指定不同的输出格式。
第四步:剪切和拼接视频你可以使用FFmpeg来剪切和拼接视频。
比如,将视频的前5秒剪切下来:ffmpeg -ss 00:00:00 -i input.mp4 -t 00:00:05 -c copy output.mp4这里,-ss参数指定了剪切的起始时间,-t参数指定了剪切的持续时间,-c copy参数表示直接复制原始编码格式。
如果你想将多个视频文件拼接在一起,可以使用以下命令:ffmpeg -i "concat:input1.mp4 input2.mp4" -c copy output.mp4这里,concat参数用于指定要拼接的文件名列表,每个文件由分隔,-c copy参数表示直接复制原始编码格式。
ffmpeg 硬件解码命令行参数

ffmpeg 硬件解码命令行参数
要使用FFmpeg进行硬件解码,你需要使用特定的命令行参数来
指定硬件解码器。
在大多数情况下,硬件解码通常是通过显卡的
GPU来实现的。
以下是一些常见的命令行参数示例:
1. 使用CUDA进行硬件解码:
bash.
ffmpeg -hwaccel cuda -i input.mp4 output.mp4。
这个命令使用CUDA进行硬件加速解码,输入文件是input.mp4,输出文件是output.mp4。
2. 使用OpenMAX进行硬件解码:
bash.
ffmpeg -c:v h264_omx -i input.mp4 -c:a copy output.mp4。
这个命令使用OpenMAX进行H.264视频的硬件解码,同时保持音频流不变,输入文件是input.mp4,输出文件是output.mp4。
3. 使用VAAPI进行硬件解码:
bash.
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v h264_vaapi -b:v 5M -c:a copy output.mp4。
这个命令使用VAAPI进行H.264视频的硬件解码,并指定了输出的视频码率为5M,输入文件是input.mp4,输出文件是
output.mp4。
这些只是一些常见的示例,实际上硬件解码的命令行参数可能会因系统环境、硬件设备和FFmpeg版本而有所不同。
在使用硬件解码时,建议查阅FFmpeg官方文档以获取最新的命令行参数信息,并根据具体情况进行调整。
ffmpeg 采样精度命令

ffmpeg 采样精度命令FFmpeg是一个跨平台的音视频处理工具,它提供了丰富的命令行选项,可以对音视频文件进行各种处理操作。
其中,采样精度是一个重要的参数,决定了音频的质量和精确度。
本文将介绍一些常用的FFmpeg采样精度命令,并对其功能和使用方法进行详细解析。
1. 采样精度的概念和作用采样精度是指采样过程中对音频信号的采样点进行量化的精度。
它决定了采样点的取值范围,从而影响了音频的动态范围和精确度。
采样精度一般以位数表示,常见的有8位、16位和24位等。
较高的采样精度可以提供更高的音频质量,但同时也增加了文件大小。
2. FFmpeg采样精度命令2.1 "-sample_fmt"命令"-sample_fmt"命令用于设置输出音频文件的采样精度格式。
它的语法如下:```ffmpeg -i input.wav -sample_fmt s16 output.wav```其中,"input.wav"是输入音频文件的路径,"output.wav"是输出音频文件的路径,"s16"表示采样精度为16位。
通过设置不同的采样精度,可以得到不同精度的音频文件。
2.2 "-ar"命令"-ar"命令用于设置输出音频文件的采样率。
采样率是指单位时间内采集和记录声音样本的数量,常见的有44.1kHz、48kHz等。
采样率的选择与采样精度密切相关,较高的采样率可以提供更高的频率范围和音质,但同时也增加了文件大小。
它的语法如下:```ffmpeg -i input.wav -ar 44100 output.wav```其中,"input.wav"是输入音频文件的路径,"output.wav"是输出音频文件的路径,"44100"表示采样率为44.1kHz。
ffmpeg常用命令

ffmpeg常⽤命令mp4中的h264编码,⽽h264有两种封装:⼀种是annexb模式,传统模式,有startcode,SPS和PPS是在ES中;另⼀种是mp4模式,⼀般mp4、mkv、avi会没有startcode,SPS和PPS以及其它信息被封装在container 中,每⼀个frame前⾯是这个frame的长度,很多解码器只⽀持annexb这种模式,因此需要将mp4做转换;在ffmpeg中⽤h264_mp4toannexb_filter可以做转换;所以需要使⽤-bsf h264_mp4toannexb来进⾏转换;ffmpeg命令参数说明:-i 输⼊⽂件-vcodec 视频编解码格式,如:h264或者libx264(h264编解码)、copy(原样拷贝)、mpeg4(mp4编码)-acodec ⾳频编码格式,如aac(aac编解码)-bsf h264_mp4toannexb 见上⾯解释-vn 取消视频-an 取消⾳频-sn 取消字幕-intra 采⽤帧内编码,仅适⽤帧内编码更多参数详见最后。
1.分离视频⾳频流ffmpeg -i input_file -vcodec copy -an output_file_video //分离视频流ffmpeg -i input_file -acodec copy -vn output_file_audio //分离⾳频流ffmpeg -i target.mp4 -vcodec libx264 -an target.h264 // 将target.mp4分离出没有声⾳的h264编码的视频⽂件ffmpeg -i target.mp4 -acodec aac target.aac // // 将target.mp4分离出aac编码的⾳频⽂件ffmpeg -i target.mp4 -c:v libx264 -c:a aac -strict -2 -f hls target.m3u8 // 将mp4⽂件切为ts视频段,并⽣成m3u8⽂件2.视频解复⽤ffmpeg –i test.mp4 –vcodec copy –an –f m4v test.264ffmpeg –i test.avi –vcodec copy –an –f m4v test.2643.视频转码ffmpeg –i test.mp4 –vcodec h264 –s 352*278 –an –f m4v test.264 //转码为码流原始⽂件ffmpeg –i test.mp4 –vcodec h264 –bf 0 –g 25 –s 352*278 –an –f m4v test.264 //转码为码流原始⽂件ffmpeg –i test.avi -vcodec mpeg4 –vtag xvid –qsame test_xvid.avi //转码为封装⽂件//-bf B帧数⽬控制,-g 关键帧间隔控制,-s 分辨率控制ffmpeg -i target.h264 -vcodec h264 -i target.aac -acodec copy target.ts4.视频封装ffmpeg –i video_file –i audio_file –vcodec copy –acodec copy output_file5.视频剪切ffmpeg –i test.avi –r 1 –f image2 image-%3d.jpeg //提取图⽚ffmpeg -ss 0:1:30 -t 0:0:20 -i input.avi -vcodec copy -acodec copy output.avi //剪切视频//-r 提取图像的频率,-ss 开始时间,-t 持续时间6.视频录制ffmpeg –i rtsp://192.168.3.205:5555/test –vcodec copy out.avi7.YUV序列播放ffplay -f rawvideo -video_size 1920x1080 input.yuv8.YUV序列转AVIffmpeg –s w*h –pix_fmt yuv420p –i input.yuv –vcodec mpeg4 output.avi常⽤参数说明:主要参数: -i 设定输⼊流 -f 设定输出格式 -ss 开始时间视频参数: -b 设定视频流量,默认为200Kbit/s -r 设定帧速率,默认为25 -s 设定画⾯的宽与⾼ -aspect 设定画⾯的⽐例 -vn 不处理视频 -vcodec 设定视频编解码器,未设定时则使⽤与输⼊流相同的编解码器⾳频参数: -ar 设定采样率 -ac 设定声⾳的Channel数 -acodec 设定声⾳编解码器,未设定时则使⽤与输⼊流相同的编解码器 -an 不处理⾳频----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1、将⽂件当做直播送⾄liveffmpeg -re -i localFile.mp4 -c copy -f flv rtmp://server/live/streamName2、将直播媒体保存⾄本地⽂件ffmpeg -i rtmp://server/live/streamName -c copy dump.flv3、将其中⼀个直播流,视频改⽤h264压缩,⾳频不变,送⾄另外⼀个直播服务流ffmpeg -i rtmp://server/live/originalStream -c:a copy -c:v libx264 -vpre slow -f flv rtmp://server/live/h264Stream4、将其中⼀个直播流,视频改⽤h264压缩,⾳频改⽤faac压缩,送⾄另外⼀个直播服务流ffmpeg -i rtmp://server/live/originalStream -c:a libfaac -ar 44100 -ab 48k -c:v libx264 -vpre slow -vpre baseline -f flv rtmp://server/live/h264Stream5、将其中⼀个直播流,视频不变,⾳频改⽤faac压缩,送⾄另外⼀个直播服务流ffmpeg -i rtmp://server/live/originalStream -acodec libfaac -ar 44100 -ab 48k -vcodec copy -f flv rtmp://server/live/h264_AAC_Stream6、将⼀个⾼清流,复制为⼏个不同视频清晰度的流重新发布,其中⾳频不变ffmpeg -re -i rtmp://server/live/high_FMLE_stream -acodec copy -vcodec x264lib -s 640×360 -b 500k -vpre medium -vpre baseline rtmp://server/live/baseline_500k -acodec copy -vcodec x264lib -s 480×272 -b 300k -vpre medium -vpre baseline rtm 7、功能⼀样,只是采⽤-x264opts选项ffmpeg -re -i rtmp://server/live/high_FMLE_stream -c:a copy -c:v x264lib -s 640×360 -x264opts bitrate=500:profile=baseline:preset=slow rtmp://server/live/baseline_500k -c:a copy -c:v x264lib -s 480×272 -x264opts bitrate=300:profile=baseline:pre 8、将当前摄像头及⾳频通过DSSHOW采集,视频h264、⾳频faac压缩后发布ffmpeg -r 25 -f dshow -s 640×480 -i video=”video source name”:audio=”audio source name” -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k -f flv rtmp://server/application/stream_name9、将⼀个JPG图⽚经过h264压缩循环输出为mp4视频ffmpeg.exe -i INPUT.jpg -an -vcodec libx264 -coder 1 -flags +loop -cmp +chroma -subq 10 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -flags2 +dct8x8 -trellis 2 -partitions +parti8x8+parti4x4 -crf 24 -threads 0 -r 25 -g 25 -y OUTPUT.mp410、将普通流视频改⽤h264压缩,⾳频不变,送⾄⾼清流服务(新版本FMS live=1)ffmpeg -i rtmp://server/live/originalStream -c:a copy -c:v libx264 -vpre slow -f flv “rtmp://server/live/h264Stream live=1〃ffmpeg参数说明:基本选项:-formats输出所有可⽤格式-f fmt指定格式(⾳频或视频格式)-i filename指定输⼊⽂件名,在linux下当然也能指定:0.0(屏幕录制)或摄像头-y覆盖已有⽂件-t duration记录时长为t-fs limit_size设置⽂件⼤⼩上限-ss time_off从指定的时间(s)开始, [-]hh:mm:ss[.xxx]的格式也⽀持-itsoffset time_off 设置时间偏移(s),该选项影响所有后⾯的输⼊⽂件。
FFMPEG命令入门到提高,一篇文章就够了

FFMPEG命令入门到提高,一篇文章就够了FFMPEG简介FFmpeg的名称来自MPEG视频编码标准,前面的“FF”代表“Fast Forward”,FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。
可以轻易地实现多种视频格式之间的相互转换。
FFmpeg的用户有Google,Facebook,Youtube,优酷,爱奇艺,土豆等基础知识1.容器/文件(Conainer/File):即特定格式的多媒体文件,比如mp4、flv、mkv等。
2.媒体流(Stream):表示时间轴上的一段连续数据,如一段声音数据、一段视频数据或一段字幕数据,可以是压缩的,也可以是非压缩的,压缩的数据需要关联特定的编解码器。
3.数据帧/数据包(Frame/Packet):通常,一个媒体流是由大量的数据帧组成的,对于压缩数据,帧对应着编解码器的最小处理单元,分属于不同媒体流的数据帧交错存储于容器之中。
一般情况下:Frame对应压缩前的数据,Packet对应压缩后的数据。
4.编解码器(Codec):以帧为单位实现压缩数据和原始数据之间的相互转换的5.复用(mux):把不同的流按照某种容器的规则放入容器,这种行为叫做复用(mux)6.解复用(mux):把不同的流从某种容器中解析出来,这种行为叫做解复用(demux)7.码率和帧率是视频文件的最重要的基本特征,对于他们的特有设置会决定视频质量。
如果我们知道码率和时长那么可以很容易计算出输出文件的大小。
8.帧率:帧率也叫帧频率,帧率是视频文件中每一秒的帧数,肉眼想看到连续移动图像至少需要15帧。
9.码率:比特率(也叫码率,数据率)是一个确定整体视频/音频质量的参数,秒为单位处理的位数,码率和视频质量成正比,在视频文件中中比特率用bps来表达。
FFMPEG命令行环境搭建1.到ffmpeg官方下载已经编译好的Windows shared库;2.将执行文件ffmpeg.exe ffplay.exe ffprobe.exe拷贝到C:\Windows目录;3.将相应的动态库拷贝到C:\Windows\SysWOW64目录;4.注:WOW64 (Windows-on-Windows 64-bit)5.在命令行窗口输入ffmpeg -version 查看版本,以却确定环境是否搭建成功。
mencoder 和ffmpeg常用命令

mencoder 和ffmpeg常用命令先从Mencoder这个开始,将所有格式转AVI,RMVB转AVImencoder 1.rmvb -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -ormvb.aviRM转AVImencoder 1.rm -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -orm.aviMPEG转AVImencoder mp4.mpeg -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -ofavi -o mp4.aviMOV转AVImencoder qtime.mov -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -ofavi -o qtime.aviWMV转AVI 包括WMV7到WMV9,只实验到WMV9mencoder m7.wmv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi-o m7.aviRV转AVImencoder 1.rv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -orv.avi等等……格式,参数不变,改文件名就好了。
这里参数是什么意思,我目前还不懂,学习中,你可以在网上找找,找到告诉我啊,谢谢。
接下来是FFMPEG上场。
AVI转FLVffmpeg -i test.avi -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv抓图JPG。
ffmpeg最全的命令参数

ffmpeg最全的命令参数Java代码Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Getting help: -h -- print basic options -h long -- print more options -h full -- print all options (including all format and codec specific options, very long) See man ffmpeg for detailed description of the options. Print help / information / capabilities: -Lshow license -h topic show help -? topic show help -help topic show help --help topic show help -version show version -formats show available formats -codecs show available codecs -decoders show available decoders-encoders show available encoders -bsfsshow available bit stream filters -protocols show available protocols -filters show available filters -pix_fmts show available pixel formats -layouts show standard channel layouts -sample_fmts show available audio sample formats Global options (affect whole program instead of just one file: -loglevel loglevel set libav* logging level -v loglevel set libav* logging level-report generate a report -max_alloc bytesset maximum size of a single allocated block -yoverwrite output files -n do not overwrite output files -stats print progress report during encoding -bits_per_raw_sample number set the number of bits per raw sample -croptop size Removed, use the crop filter instead -cropbottom size Removed, use the crop filter instead -cropleft size Removed, use the crop filter instead -cropright size Removed, use the crop filter instead -padtop size Removed, use the pad filter instead -padbottom size Removed, use the pad filter instead -padleft size Removed, use the pad filter instead -padright size Removed, use the pad filter instead -padcolor color Removed, use the pad filter instead -vol volume change audio volume(256=normal) Advanced global options: -cpuflags flags force specific cpu flags -benchmark add timings for benchmarking -benchmark_all add timings for each task -progress url write program-readable progress information -stdin enable or disable interaction on standard input -timelimit limit set max runtime in seconds -dump dump each inputpacket -hex when dumping packets, also dump the payload -vsync video sync method -async audio sync method -adrift_threshold threshold audio drift threshold -copyts copy timestamps -copytb mode copy input stream time base when stream copying -dts_delta_threshold threshold timestamp discontinuity delta threshold -dts_error_threshold threshold timestamp error delta threshold -xerror errorexit on error -filter_complex graph_description create a complex filtergraph -debug_ts print timestamp debugging info -intra deprecated use -g 1-vdt n discard threshold -sameqRemoved -same_quant Removed -deinterlace this option is deprecated, use the yadif filter instead -psnr calculate PSNR of compressed frames -vstatsdump video coding statistics to file -vstats_file file dump video coding statistics to file -dc precisionintra_dc_precision -qphist show QP histogram -vc channel deprecated, use -channel -tvstd standard deprecated, use -standard -isync this option is deprecated and does nothing Per-file main options: -f fmt force format -c codec codec name -codeccodec codec name -pre preset preset name -map_metadata outfile[,metadata]:infile[,metadata] set metadata information of outfile from infile -t durationrecord or transcode "duration" seconds of audio/video -fs limit_size set the limit file size in bytes -ss time_off set the start time offset -timestamp time set the recording timestamp ('now' to set the current time) -metadatastring=string add metadata -target type specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...) -frames number set the number of frames to record -filter filter_graph set stream filtergraph-reinit_filter reinit filtergraph on input parameter changes Advanced per-file options: -map[-]input_file_id[:stream_specifier][,sync_file_id[:stream_s set input stream mapping -map_channelfile.stream.channel[:syncfile.syncstream] map an audio channel from one stream to another -map_chaptersinput_file_index set chapters mapping -itsoffset time_off set the input ts offset -itsscale scale set the input ts scale -dframes number set the number of data frames to record -re read input at native frame rate-shortest finish encoding within shortest input-copyinkf copy initial non-keyframes-copypriorss copy or discard frames before start time -tag fourcc/tag force codec tag/fourcc -q quse fixed quality scale (VBR) -qscale q use fixed quality scale (VBR) -profile profile set profile -attach filename add an attachment to the output file-dump_attachment filename extract an attachment into a file -muxdelay seconds set the maximum demux-decode delay -muxpreload seconds set the initial demux-decode delay -bsf bitstream_filters A comma-separated list of bitstream filters -fpre filename set options from indicated preset file-dcodec codec force data codec ('copy' to copy stream) Video options: -vframes number set the number of video frames to record -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 -croptop size Removed, use the crop filter instead -cropbottom size Removed, use the crop filter instead -cropleft size Removed, use the crop filter instead -cropright size Removed, use the crop filterinstead -padtop size Removed, use the pad filter instead -padbottom size Removed, use the pad filter instead -padleft size Removed, use the pad filter instead -padright size Removed, use the pad filter instead -padcolor color Removed, use the pad filter instead -vn disable video -vcodec codec force video codec ('copy' to copy stream) -timecodehh:mm:ss[:;.]ff set initial TimeCode value. -pass nselect the pass number (1 to 3) -vf filter_graph set video filters -b bitrate video bitrate (please use -b:v)-dn disable data Advanced Video options: -pix_fmt format set pixel format -intra deprecated use -g 1 -vdt n discard threshold -rc_override override rate control override for specific intervals -sameq Removed -same_quant Removed -passlogfile prefix select two pass log file name prefix -deinterlace this option is deprecated, use the yadif filter instead -psnr calculate PSNR of compressed frames -vstats dump video coding statistics to file -vstats_file file dump video coding statistics to file -intra_matrix matrix specify intra matrix coeffs -inter_matrix matrix specify inter matrix coeffs -toptop=1/bottom=0/auto=-1 field first -dc precisionintra_dc_precision -vtag fourcc/tag force video tag/fourcc -qphist show QP histogram -force_fpsforce the selected framerate, disable the best supported framerate selection -streamid streamIndex:value set the value of an outfile streamid -force_key_frames timestamps force key frames at specified timestamps -vc channel deprecated, use -channel -tvstd standard deprecated, use -standard -vbsf video bitstream_filters deprecated -vpre preset set the video options to the indicated preset Audio options: -aframes number set the number of audio frames to record -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 codecforce audio codec ('copy' to copy stream) -vol volume change audio volume (256=normal) -af filter_graph set audio filters Advanced Audio options: -atag fourcc/tag force audio tag/fourcc -sample_fmt format set sample format -channel_layout layout set channel layout -absf audio bitstream_filters deprecated -apre preset set the audio options to the indicated preset Subtitle options: -ssize set frame size (WxH or abbreviation) -sn disable subtitle -scodec codec force subtitle codec ('copy' to copy stream) -stag fourcc/tag force subtitle tag/fourcc -fix_sub_duration fix subtitles duration -spre preset set the subtitle options to the indicated preset。
FFmpeg:视频转码、剪切、合并、播放速调整

FFmpeg:视频转码、剪切、合并、播放速调整安装去官网按提示安装即可,支持三大操作系统。
唯一要吐槽的是,Ubuntu 14.04 等较新的版本,从默认软件列表里移除了 ffmpeg,转而支持 libav,可是 libav 又没弄好,很难用——开源社区瞎折腾起来真是无力吐槽。
2017 更新: Ubuntu 16.04,FFmpeg 又回到了官方仓库:sudo apt install ffmpeg转码最简单命令如下:ffmpeg -i out.ogv -vcodec h264 out.mp4ffmpeg -i out.ogv -vcodec mpeg4 out.mp4ffmpeg -i out.ogv -vcodec libxvid out.mp4ffmpeg -i out.mp4 -vcodec wmv1 out.wmvffmpeg -i out.mp4 -vcodec wmv2 out.wmv-i 后面是输入文件名。
-vcodec 后面是编码格式,h264 最佳,但Windows 系统默认不安装。
如果是要插入ppt 的视频,选择wmv1 或 wmv2 基本上万无一失。
附加选项:-r 指定帧率,-s 指定分辨率,-b 指定比特率;于此同时可以对声道进行转码,-acodec 指定音频编码,-ab 指定音频比特率,-ac 指定声道数,例如ffmpeg -i out.ogv -s 640x480 -b 500k -vcodec h264 -r 29.97 -acodec libfaac -ab 48k -ac 2 out.mp4剪切用 -ss 和 -t 选项,从第 30 秒开始,向后截取 10 秒的视频,并保存:ffmpeg -i input.wmv -ss 00:00:30.0 -c copy -t 00:00:10.0 output.wmvffmpeg -i input.wmv -ss 30 -c copy -t 10 output.wmv达成相同效果,也可以用 -ss 和 -to 选项,从第 30 秒截取到第40 秒:ffmpeg -i input.wmv -ss 30 -c copy -to 40 output.wmv值得注意的是,ffmpeg 为了加速,会使用关键帧技术,所以有时剪切出来的结果在起止时间上未必准确。
ffmpeg各参数

ffmpeg各参数FFmpeg是一个开源的跨平台音视频处理库,它支持多种音视频格式,包括但不限于MPEG4、H.264、AAC等,在影视制作和音视频开发应用非常广泛。
FFmpeg中有众多参数可供使用,这里介绍一些常用参数。
1. -i 输入文件参数-i是FFmpeg中非常重要的参数。
它指定要处理的输入文件,并且必须作为FFmpeg命令的第一个选项。
例如,输入一个名为test.mp4的视频文件,命令如下:ffmpeg.exe -i test.mp42. -ss 跳过指定时间参数-ss参数可以让FFmpeg跳过输入文件的指定时间,从指定时间开始处理。
因为视频处理需要一定的时间,所以该参数可用于在测试过程中跳过开头部分,以加快测试效率。
例如,从5秒处开始处理test.mp4文件:ffmpeg.exe -i test.mp4 -ss 53. -t 持续时间参数-t参数指定处理视频所需的时间。
例如,在test.mp4文件中提取前10秒的视频:ffmpeg.exe -i test.mp4 -t 104. -c:v 视频编解码器参数-c:v参数指定要使用的视频编解码器。
默认情况下,FFmpeg将使用libx264编解码器。
例如,将视频文件压缩为MPEG4格式: ffmpeg.exe -i test.mp4 -c:v mpeg4 -b:v 1M5. -b:v 视频比特率参数-b:v参数指定压缩比特率,单位为Kbps,它将影响视频文件的大小和质量。
例如,设置20Mbps的比特率:ffmpeg.exe -i test.mp4 -b:v 20M6. -r 帧率参数-r参数指定视频的帧率,它将影响视频文件的流畅度和质量。
例如,将视频文件的帧率设置为30fps:ffmpeg.exe -i test.mp4 -r 307. -ar 音频采样率参数-ar参数指定音频文件的采样率,这将影响音频文件的质量和大小。
例如,将音频文件的采样率设置为44100Hz:ffmpeg.exe -i test.mp4 -ar 441008. -ac 音频通道数参数-ac参数指定音频文件的通道数,例如双声道或多声道音频文件。
ffmpeg函数手册

ffmpeg函数手册ffmpeg是一款功能强大的多媒体处理工具,它提供了许多函数用于处理音频、视频、字幕、水印等多媒体数据。
在本手册中,我们将介绍一些常用的ffmpeg函数,帮助您更好地使用ffmpeg进行多媒体处理。
一、输入和输出文件1.ffmpeg命令行工具:ffmpeg是命令行工具,可以通过命令行输入和输出文件。
常用的命令格式为:ffmpeg[选项]-i输入文件-i输出文件[过滤器]...[输出选项]2.输入文件格式:ffmpeg支持多种输入文件格式,如AVI、MP4、MKV、TS 等。
在命令中,您需要指定输入文件的路径和文件名。
3.输出文件格式:输出文件的格式可以是AVI、MP4、MKV、TS等。
在命令中,您需要指定输出文件的路径和文件名,并使用输出选项设置输出格式。
二、常用函数1.音频处理函数a.audio_input():用于读取音频输入流。
b.audio_output():用于将音频数据输出到目标设备。
c.audio_filter():用于对音频数据进行过滤和处理。
d.audio_output_options():用于设置音频输出选项,如采样率、比特率等。
2.视频处理函数a.video_input():用于读取视频输入流。
b.video_output():用于将视频数据输出到目标设备。
c.video_filter():用于对视频数据进行过滤和处理。
d.video_display():用于显示视频帧。
e.video_output_options():用于设置视频输出选项,如分辨率、比特率等。
3.文件操作函数a.file_open():用于打开文件。
b.file_close():用于关闭文件。
c.file_read():用于读取文件内容。
d.file_write():用于写入文件内容。
e.file_seek():用于设置文件指针的位置。
f.file_tell():用于获取当前文件指针的位置。
python使用ffmpeg指令

python使用ffmpeg指令Python是一种高级编程语言,可以通过它来使用FFmpeg指令进行音视频处理。
FFmpeg是一个跨平台的开源音视频处理工具,支持多种格式的音视频文件的编解码、转码、剪辑等操作。
下文将介绍如何在Python中使用FFmpeg指令。
1. 安装FFmpeg在使用FFmpeg指令之前,需要先安装FFmpeg。
可以通过以下命令在Linux系统中安装FFmpeg:sudo apt-get install ffmpeg在Windows系统中,需要从FFmpeg官网下载可执行文件,然后将FFmpeg添加到系统环境变量中。
2. 导入subprocess模块在Python中使用FFmpeg指令需要导入subprocess模块。
subprocess模块可以用来执行系统命令,并且可以获得命令的输出和返回值。
import subprocess3. 使用FFmpeg指令下面是一些常用的FFmpeg指令及其说明:(1)转换音视频格式将MP4格式的视频转换为AVI格式:subprocess.call(['ffmpeg', '-i', 'input.mp4','output.avi'])(2)剪辑视频将视频的前10秒剪辑出来:subprocess.call(['ffmpeg', '-i', 'input.mp4', '-ss', '00:00:00', '-t', '00:00:10', '-c', 'copy', 'output.mp4']) (3)提取音频将视频中的音频提取出来:subprocess.call(['ffmpeg', '-i', 'input.mp4', '-vn', '-acodec', 'copy', 'output.aac'])(4)添加水印在视频的左上角添加水印:subprocess.call(['ffmpeg', '-i', 'input.mp4', '-i','watermark.png', '-filter_complex', 'overlay=10:10','output.mp4'])(5)调整视频分辨率将视频的分辨率调整为720x480:subprocess.call(['ffmpeg', '-i', 'input.mp4', '-s','720x480', '-c', 'copy', 'output.mp4'])4. 总结通过Python中的subprocess模块,可以轻松使用FFmpeg指令进行音视频处理。
ffmpeg常用命令汇总

ffmpeg常用命令汇总FFmpeg是一个开源的音视频处理工具,可以用于转码、剪辑、合并、提取音视频等操作。
下面是一些常用的FFmpeg命令汇总:1.转码命令:- 将视频转为H.264编码:ffmpeg -i input.mp4 -c:v libx264 output.mp4- 将视频转为H.265编码:ffmpeg -i input.mp4 -c:v libx265 output.mp4- 将视频转为VP9编码:ffmpeg -i input.mp4 -c:v libvpx-vp9 output.webm- 将视频转为AV1编码:ffmpeg -i input.mp4 -c:v libaom-av1 output.mp4- 将视频转为MPEG-4编码:ffmpeg -i input.mp4 -c:v mpeg4 output.mp4- 将视频转为VP8编码:ffmpeg -i input.mp4 -c:v libvpx output.webm- 将音频转为AAC编码:ffmpeg -i input.mp3 -c:a aacoutput.aac- 将音频转为MP3编码:ffmpeg -i input.wav -c:a libmp3lame output.mp32.合并命令:- 合并视频和音频文件:ffmpeg -i input.mp4 -i input.mp3 -c:v copy -c:a copy output.mp43.剪辑命令:- 剪辑视频片段:ffmpeg -ss 00:00:10 -i input.mp4 -t 00:00:20 -c:v copy -c:a copy output.mp4- 剪辑音频片段:ffmpeg -ss 00:00:10 -i input.mp3 -t 00:00:20 -c:a copy output.mp34.提取命令:- 提取视频的音频:ffmpeg -i input.mp4 -vn -c:a copyoutput.mp3- 提取视频的帧图片:ffmpeg -i input.mp4 -vf"select='eq(n,100)'" -vframes 1 output.jpg- 提取视频的音频和视频:ffmpeg -i input.mp4 -vn -c:a copy audio.mp3 -an -c:v copy video.mp45.调整命令:- 调整视频的分辨率:ffmpeg -i input.mp4 -vf "scale=640:480" output.mp4- 调整视频的帧率:ffmpeg -i input.mp4 -r 30 output.mp4- 调整视频的码率:ffmpeg -i input.mp4 -b:v 1M output.mp4- 调整音频的码率:ffmpeg -i input.mp3 -b:a 128k output.mp3 6.其他命令:- 视频截图:ffmpeg -i input.mp4 -vframes 1 output.jpg- 视频转GIF动图:ffmpeg -i input.mp4 -vf"fps=10,scale=320:-1:flags=lanczos" output.gif以上是一些常用的FFmpeg命令汇总,可以根据需求进行使用。
ffmpeg平均分割命令

ffmpeg平均分割命令
FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。
它的平均分割命令如下:
```
ffmpeg -i input.mp4 -c:v copy -c:a copy -bsf:v h264_mp4toannexb -f mpegts output.ts
```
其中,`-i input.mp4`指定输入的视频文件;`-c:v copy`和`-c:a copy`分别指定视频流和音频流的复制方式;`-bsf:v h264_mp4toannexb`指定视频流的编码格式;`-f mpegts`指定输出的文件格式为mpegts;`output.ts`指定输出的文件名。
请注意,上述命令仅适用于特定的场景和需求,具体的分割方式可能会因输入文件的格式、内容和目标用途而有所不同。
在使用FFmpeg进行分割操作之前,建议你仔细阅读FFmpeg 的官方文档或相关教程,以确保正确使用命令并获得所需的结果。
19常用FFMPEG命令FFMPEGCOMMANDSFORALLNEEDS

19常用FFMPEG命令FFMPEGCOMMANDSFORALLNEEDSPublished on September 22nd, 2008 by Jean.ffmpeg is a multiplatform, open-source library for video and audio files. I have compiled 19 useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.GETTING INFOS FROM A VIDEO FILETURN X IMAGES TO A VIDEO SEQUENCEThis command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.TURN A VIDEO TO X IMAGESThis command will generate the files named image1.jpg, image2.jp g, …The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.ENCODE A VIDEO SEQUENCE FOR THE IPPOD/IPHONEExplanations :•Source : source_video.avi•Audio codec : aac•Audio bitrate : 128kb/s•Video codec : mpeg4•Video bitrate : 1200kb/s•Video size : 320px par 180px•Generated video : final_video.mp4ENCODE VIDEO FOR THE PSPExplanations :•Source : source_video.avi•Audio codec : aac•Audio bitrate : 32kb/s•Video codec : xvid•Video bitrate : 1200kb/s•Video size : 320px par 180px•Generated video : final_video.mp4EXTRACTING SOUND FROM A VIDEO, AND SAVE IT AS MP3Explanations :•Source video : source_video.avi•Audio bitrate : 192kb/s•output format : mp3•Generated sound : sound.mp3CONVERT A WAV FILE TO MP3CONVERT .AVI VIDEO TO .MPGCONVERT .MPG TO .AVICONVERT .AVI TO ANIMATED GIF(UNCOMPRESSED)MIX A VIDEO WITH A SOUND FILECONVERT .AVI TO .FLVCONVERT .AVI TO DVOr:CONVERT .AVI TO MPEG FOR DVD PLAYERSExplanations :•target pal-dvd : Output format•ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)•aspect 16:9 : WidescreenCOMPRESS .AVI TO DIVXCOMPRESS OGG THEORA TO MPEG DVDCOMPRESS .AVI TO SVCD MPEG2NTSC format:PAL format:COMPRESS .AVI TO VCD MPEG2 NTSC format:PAL format:MULTI-PASS ENCODING WITH FFMPEG。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ffmpeg 常用命令汇总2016-06-15 09:11 17116人阅读评论(0)收藏举报(经常用到ffmpeg 做一些视频数据的处理转换等,用来做测试,今天总结了一下,参考了网上部分朋友的经验,一起在这里汇总了一下,有需要的朋友可以收藏测试一下,有问题欢迎在下面回帖交流,谢谢;by ternence.hsu)1、ffmpeg使用语法命令格式:ffmpeg -i [输入文件名] [参数选项] -f [格式] [输出文件]ffmpeg [[options][`-i' input_file]]... {[options] output_file}...1、参数选项:(1) -an: 去掉音频(2) -acodec: 音频选项,一般后面加copy表示拷贝(3) -vcodec:视频选项,一般后面加copy表示拷贝2、格式:(1) h264: 表示输出的是h264的视频裸流(2) mp4: 表示输出的是mp4的视频(3)mpegts: 表示ts视频流如果没有输入文件,那么视音频捕捉(只在Linux下有效,因为Linux下把音视频设备当作文件句柄则,选项一般用于下一个特定的文件。
如果你给–b 64选项,改选会设置下一个视频速率。
对于原始情况下,ffmpeg试图尽可能的无损转换,采用与输入同样的音频视频参数来输出。
(by ternence.hsu)2、视频转换H264视频转ts视频流ffmpeg -i test.h264 -vcodec copy -f mpegts test.tsH264视频转mp4ffmpeg -i test.h264 -vcodec copy -f mp4 test.mp4ts视频转mp4ffmpeg -i test.ts -acodec copy -vcodec copy -f mp4 test.mp4mp4视频转flvffmpeg -i test.mp4 -acodec copy -vcodec copy -f flv test.flv转换文件为3GP格式ffmpeg -y -i test.mpeg -bitexact -vcodec h263 -b 128 -r 15 -s 176x144 -acodec aac -ac 2 -ar 22500 -ab 24 -f 3转换文件为3GP格式v2ffmpeg -y -i test.wmv -ac 1 -acodec libamr_nb -ar 8000 -ab 12200 -s 176x144 -b 128 -r 15 test.3gp使用ffmpeg 编码得到高质量的视频ffmpeg.exe -i "D:\Video\Fearless\Fearless.avi" -target film-dvd -s 720x352 -padtop 64 -padbottom 64 -maxra 1000000000 -trellis -cgop -g 12 -bf 2 -qblur 0.3 -qcomp 0.7 -me full -dc 10 -mbd 2 -aspect 16:9 -pass 2 -pass mpeg2video "D:\Fearless.m2v"转换指定格式文件到FLV格式ffmpeg.exe -i test.mp3 -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 f:\test.flvffmpeg.exe -i test.wmv -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 f:\test.flv转码解密的VOBffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi(上面的命令行将vob的文件转化成avi文件,mpeg4的视频和mp3的音频。
注意命令中使用了B帧,所300意味着29.97帧频下每10秒就有INTRA帧。
该映射在音频语言的DVD转码时候尤其有用,同时编码建立映射)转换文件为3GP格式ffmpeg -i test.avi -y -b 20 -s sqcif -r 10 -acodec amr_wb -ab 23.85 -ac 1 -ar 16000 test.3gp(如果要转换为3GP格式,则ffmpeg在编译时必须加上–enable-amr_nb –enable-amr_wb,详细内容可参转换文件为MP4格式(支持iPhone/iTouch)ffmpeg -y -i input.wmv -f mp4 -async 1-s 480x320 -acodec libfaac -vcodec libxvid -qscale 7 -dts_delta_th ffmpeg -y -i source_video.avi input -acodec libfaac -ab 128000 -vcodec mpeg4 -b 1200000 -mbd 2 -flags + 320x180 -title X final_video.mp4将一段音频与一段视频混合ffmpeg -i son.wav -i video_origine.avi video_finale.mpg将一段视频转换为DVD格式ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg(target pal-dvd : Output format ps 2000000000 maximum size for the output file, in bits (here, 2 Gb) aspect转换一段视频为DivX格式ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.aviTurn X images to a video sequenceffmpeg -f image2 -i image%d.jpg video.mpg(This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etTurn a video to X imagesffmpeg -i video.mpg image%d.jpg(This command will generate the files named image1.jpg, image2.jpg, ... ;The following image formats a PGMYUV, JPEG, GIF, PNG, TIFF, SGI.)使用ffmpeg录像屏幕(仅限Linux平台)ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -vd x11:0,0 -s 1024x768 ~/test.avi(-vd x11:0,0 指录制所使用的偏移为x=0 和y=0,-s 1024×768 指录制视频的大小为1024×768。
录主目录中;如果你只想录制一个应用程序窗口或者桌面上的一个固定区域,那么可以指定偏移位置和完成查找上述参数。
)重新调整视频尺寸大小(仅限Linux平台)ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -i ~/test.avi -s 800×600 ~/test-800-600.avi把摄像头的实时视频录制下来,存储为文件(仅限Linux平台)ffmpeg -f video4linux -s 320*240 -r 10 -i /dev/video0 test.asf使用ffmpeg压制H.264视频ffmpeg -threads 4 -i INPUT -r 29.97 -vcodec libx264 -s 480x272 -flags +loop -cmp chroma -deblockalpha 0 0 -me umh -me_range 16 -subq 5 -partitions parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qm i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 OUTPUT(使用该指令可以压缩出比较清晰,而且文件转小的H.264视频文件)3、网络推送udp视频流的推送ffmpeg -re -i 1.ts -c copy -f mpegts udp://192.168.0.106:12344、视频拼接裸码流的拼接,先拼接裸码流,再做容器的封装ffmpeg -i "concat:test1.h264|test2.h264" -vcodec copy -f h264 out12.h2645、图像相关截取一张352x240尺寸大小的,格式为jpg的图片ffmpeg -i test.asf -y -f image2 -t 0.001 -s 352x240 a.jpg把视频的前30帧转换成一个Animated Gifffmpeg -i test.asf -vframes 30 -y -f gif a.gif截取指定时间的缩微图,-ss后跟的时间单位为秒ffmpeg -i test.avi -y -f image2 -ss 8 -t 0.001 -s 350x240 test.jpg6、音频处理转换wav到mp2格式ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0(上面的命令行转换一个64Kbits 的a.wav到128kbits的a.mp2 ‘-map file:index’在输出流的顺序上定义了的。
)7、切割ts分片ffmpeg -i input.mp4 -c:v libx264 -c:a aac -strict -2 -f hls -hls_list_size 6 -hls_time 5output1.m3u8。