Last active
July 30, 2021 02:55
-
-
Save qvoid/59903f44a0013c283a87c0dd347ccfce to your computer and use it in GitHub Desktop.
Useful ffmpeg command
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
# 检查坏帧 | |
ffmpeg -y -i 00013633_de.mpg -vf showinfo -frames:v 200 test.mpg | |
ffmpeg -i A016C001_160112_R6QT.mov -an -vcodec libx264 test.mp4 | |
# 查看Mediainfo | |
ffmpeg -i test.mp4 | |
# 抽取音频 | |
ffmpeg -i ./00015234.mpg -map 0:2 15234_2.mp3 | |
# 将m3u8下载下来 | |
ffmpeg -i http://9343.long-vod.cdn.aodianyun.com/u/9343/m3u8/1280x720/720-f70034484d9d71b66f32b6cbb5534126/720-f70034484d9d71b66f32b6cbb5534126.m3u8 -acodec copy -bsf:a aac_adtstoasc -vcodec copy 1.mp4 | |
# 将节目中的视频去掉 | |
ffmpeg -i ./aa.ts -acodec copy -vn aa_audio.ts | |
# 分离音视频 | |
ffmpeg -i input_file -vcodec copy -an output_file_video //提取视频流 | |
ffmpeg -i input_file -acodec copy -vn output_file_audio //提取音频流 | |
# 转码 | |
ffmpeg -threads 4 -i ./aa.ts -acodec copy -vcodec libx264 -preset placebo -crf 20 aa_20_placebo.mp4 | |
# 节目中的PCM音频转mp3 | |
ffmpeg -i ./mawang\ \(1\)-5.mov -acodec libmp3lame -ab 320k -vcodec libx264 -crf 20 mawang.mp4 | |
# ffmpeg输出重定向到文件 | |
ffmpeg > file 2>&1 | |
# ffmpeg 转码设定gop | |
ffmpeg -i ./00024830.mpg -acodec copy -vcodec libx264 -keyint_min 30 -g 30 -sc_threshold 0 -crf 20 aa.mpg | |
# 将节目信息输出到文本 | |
ffprobe -i <file> >> <output_file> 2>&1 | |
# 从mp4中将视频抽成h264文件 | |
ffmpeg -i 20130312_133313.mp4 -codec copy -bsf h264_mp4toannexb -f h264 20130312_133313.264 | |
说明: | |
-i 20130312_133313.mp4 :是输入的MP4文件 | |
-codec copy:从MP4封装中进行拷贝 | |
-bsf: h264_mp4toannexb:从MP4拷贝到annexB封装 | |
-f h264:采用h.264格式 | |
20130312_133313.264:输出的文件名称 | |
# ffmpeg 播放yuv文件 | |
ffplay -f rawvideo -video_size 426x240 -pix_fmt yuv422p ./firestone.yuv | |
# 将视频转为yuv输出 | |
ffmpeg -i 720P.264 -s 1280x720 -pix_fmt yuv422p 720P-out.yuv | |
# 查看ffmpeg支持那些yuv格式转换 | |
ffmpeg -pix_fmts | |
# check audio info | |
ffmpeg -report -i audio.wav -af ashowinfo -f null /dev/null | |
# 封装裸码流 | |
ffmpeg -f m4v -i ./dec_in.bin.mpeg4 -vcodec copy dec_in.mp4 | |
# 剪切视频 | |
ffmpeg -i <input> -acodec copy -vcodec copy -ss 00:00:26 -t 00:00:16 <output> | |
ffmpeg -ss [start] -t [duration] -accurate_seek -i [in].mp4 -codec copy [out].mp4 | |
# 较为精确剪切视频(有转码) | |
ffmpeg -y -ss start -t duration -I filename -c:v libx264 -preset superfast -c:a copy | |
ffmpeg -y -ss start -t duration -accurate_seek -i filename codec copy -avoid_negative_ts 1 | |
ffmpeg -ss [start] -t [duration] -i [in].mp4 -c:v libx264 -c:a aac -strict experimental -b:a 98k [out].mp4 | |
# 合并视频 | |
ffmpeg -f concat -i list.txt -c copy concat.mp4 | |
> list.txt 中定义待合并的文件 | |
file ./split.mp4 | |
file ./split1.mp4 | |
# YUV to JPEG | |
ffmpeg -s 640x480 -pix_fmt yuv420p -i test-yuv420p.yuv test-640x480.jpg | |
# 生成测试图案 | |
## testsrc | |
ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 testsrc.mpg | |
## smptebars | |
ffmpeg -f lavfi -i smptebars=duration=10:size=640x360:rate=30 smptebars.mp4 | |
## color source | |
ffmpeg -f lavfi -i color=c=red@0.2:duration=5:s=qcif:r=10 colorsrc.mp4 | |
## rgbtestsrc | |
ffmpeg -f lavfi -i rgbtestsrc -pix_fmt yuv420p -t 5 rgbtestsrc.mp4 | |
# see http://ffmpeg.org/ffmpeg-filters.html#color_002c-haldclutsrc_002c-nullsrc_002c-rgbtestsrc_002c-smptebars_002c-smptehdbars_002c-testsrc | |
## 将输出重定向 | |
ffmpeg xxxxx > /dev/null 2>&1 | |
ffmpeg xxxxx > <out_file> 2>&1 | |
> ffmpeg ffprobe等的命令行执行结果是错误输出(2) 而不是屏幕输出(1),所以需要重定向后才可以输出到文件 | |
## 显示帧的debug信息 | |
ffplay -debug pict -vf showinfo -i ./test.h264 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment