ffmpeg 一些常用命令

===[encode]===

ffmpeg -f dshow -i audio="麦克风 (Realtek High Definition Au" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f gdigrab -i desktop  -vcodec libx264 -r 60.97 -b:v 1500K -codec:a aac -ac 2 -ar 44100  -pix_fmt yuv420p -tune zerolatency -preset ultrafast -f flv "rtmp://localhost/live/livestream"

ffmpeg.exe -f gdigrab -i desktop -vcodec libx264 -s 1920*1080 -r 60 -b:v 4000K  -pix_fmt yuv420p -tune zerolatency -preset ultrafast out.mp4

ffmpeg.exe -f gdigrab -i desktop -vcodec libx264 -s 1920*1080 -r 60 -b:v 4000K -g 120 -pix_fmt yuv420p -preset ultrafast test_1080p.mp4

ffmpeg.exe -f gdigrab -i desktop -vcodec libx264 -s 1920*1080 -r 60 -b:v 4000K -pix_fmt yuv420p -preset ultrafast test_1080p.mp4

ffmpeg.exe -f gdigrab -i desktop -c:v h264_qsv -s 1920*1080 -r 60 -b:v 4000K -preset faster testqsv_1080p.mp4

ffmpeg.exe -f gdigrab -i desktop -c:v h264_qsv -preset:v faster out.qsv.mp4

ffmpeg.exe -f gdigrab -i desktop -c:v libx264 -preset:v faster out.x264.mp4

ffmpeg.exe -f gdigrab -i desktop -c:v nvenc_h264 -preset:v faster out.nvenc.mp4

ffmpeg.exe -f gdigrab -i desktop -c:v h264_nvenc -s 1920*1080 -r 30 -b:v 4000K out.nvenc.mp4

 

===[decode]===

ffmpeg.exe -benchmark -re -i test_1080p.mp4  -f null out.null

ffmpeg.exe -benchmark -hwaccel dxva2 -re -i test_1080p.mp4  -f null out.null

ffmpeg.exe -benchmark -hwaccel qsv -re -i test_1080p.mp4  -f null out.null

ffmpeg.exe -benchmark -hwaccel cuvid -re -i test_1080p.mp4  -f null out.null

ffmpeg.exe -benchmark -hwaccel qsv -re -i test_1080p.mp4  -c:v h264_qsv -f null out.null

 

===[dshow]===

ffmpeg -list_devices true -f dshow -i dummy

ffmpeg -list_options true -f dshow -i video="HD 720P Webcam"

ffmpeg -f dshow -s 640x480 -i video="HD 720P Webcam":audio="XXX(USB Microphone)" -vcodec libx264 -b 600k -preset:v fast -acodec aac -ar 44100 -ab 96k -f flv rtmp://192.168.0.38/live/test 

ffmpeg -f dshow -pixel_format yuyv422 -s 1280x720 -i video="HD 720P Webcam"  -vcodec libx264 -b:v 2000k -g:v 10 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.0.38/live/test

ffplay -f dshow -pixel_format yuyv422 -video_size 640x480 -i video="HD 720P Webcam"

ffplay -f mjpeg -video_size 1280x720 -f dshow -i video="HD 720P Webcam"

ffplay -f mjpeg -f dshow -video_size 1280x720 -i video="HD 720P Webcam"

ffplay -f mjpeg -video_size 1280x720 -i video="HD 720P Webcam" -f dshow

 

===[v4l2]===

ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0

ffmpeg -hide_banner -s 640*480 -i /dev/video0  out2.avi

ffmpeg -input_format mjpeg -f v4l2 -s 640x480 -i /dev/video0 -f alsa -ac 1 -ar 44100 -i hw:1 -vcodec libx264 -b:v 600k -preset:v superfast -acodec aac -ab 96k -f flv rtmp://192.168.0.38/live/test

ffmpeg -input_format mjpeg -f v4l2 -s 640x480 -i /dev/video0 -f alsa -ac 1 -ar 44100 -i pulse -vcodec libx264 -b:v 600k -preset:v superfast -acodec aac -ab 96k -f flv rtmp://192.168.0.38/live/test

ffmpeg -input_format mjpeg -f v4l2 -s 1280x720 -i /dev/video0 -vcodec libx264 -r:v 20 -g:v 20 -b:v 1900k -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.0.38/live/test

ffmpeg -input_format mjpeg -f v4l2 -s 1280x720 -i /dev/video0 -vcodec libx264 -r 25 -g:v 20 -b:v 2000k -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.0.38/live/test -loglevel quiet

ffmpeg -input_format yuyv422 -f v4l2 -s 1280x720 -i /dev/video0 -vcodec libx264 -g:v 10 -b:v 2000k -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.0.38/live/test -loglevel quiet

ffplay -f v4l2 -video_size 1280x720 -i /dev/video0

ffplay -f v4l2 -input_format yuyv422/mjpeg -pixel_format yuyv422 -video_size 1280x720 -i /dev/video0

ffplay -f v4l2 -pixel_format yuyv422 -framerate 25 -video_size 640x480 -i /dev/video0

-framerate 25 // 只能设置支持的帧率

-loglevel quiet // 不打印日志信息

 

===[threads]===

默认(auto):ffmpeg -y -i test1080p.mp4 -s 960x540 -b:v 800k out.mp4

解码线程数:ffmpeg -y -threads 2 -i test1080p.mp4 -s 960x540 -b:v 800k out.mp4

编码线程数:ffmpeg -y -i test1080p.mp4 -s 960x540 -b:v 800k -threads 2 out.mp4

编解码线程数:ffmpeg -y -threads 2 -i test1080p.mp4 -s 960x540 -b:v 800k -threads 2 out.mp4

-y  //不询问直接覆盖

 

===[filter]===

ffmpeg -i test.wav -filter_complex "[0:a]ahistogram,format=yuv420p[v]" -map "[v]" -map 0:a outhistogram.mp4

ffmpeg -i test.wav -filter_complex "[0:a]aphasemeter=s=1280x720:mpc=cyan,format=yuv420p[v]" -map "[v]" -map 0:a outaphasemeter.mp4

ffmpeg -i test.wav -filter_complex "[0:a]avectorscope=s=1280x720,format=yuv420p[v]" -map "[v]" -map 0:a avectorscope.mp4

ffmpeg -i test.wav -filter_complex "[0:a]showcqt,format=yuv420p[v]" -map "[v]" -map 0:a showcqt.mp4

ffmpeg -i test.wav -filter_complex "[0:a]showfreqs=mode=line:fscale=log,format=yuv420p[v]" -map "[v]" -map 0:a showfreqs.mp4

ffmpeg -i test.wav -filter_complex "[0:a]showspectrum=s=1280x720,format=yuv420p[v]" -map "[v]" -map 0:a showspectrum.mp4

ffmpeg -i test.wav -filter_complex "[0:a]showwaves=r=30,format=yuv420p[v]" -map "[v]" -map 0:a showwaves.mp4

ffmpeg -f lavfi -i aevalsrc="sin(1*2*PI*t)*sin(880*2*PI*t)|cos(2*PI*200*t)" -filter_complex "[0:a]showwaves=r=30,format=yuv420p[v]" -map "[v]" -map 0:a showwaves_.mp4

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] ahistogram=s=640x480 [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] aphasemeter=s=1280x720:mpc=cyan [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] avectorscope=zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7 [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] showcqt [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] showfreqs=mode=line:fscale=log [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] showspectrum=mode=separate:color=intensity:slide=1:scale=cbrt [out1]"

ffplay -f lavfi "amovie=test.wav, asplit [a][out0]; [a] showwaves [out1]"

ffplay -f lavfi "aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t)|cos(2*PI*200*t),asplit[out0],showwaves=r=30[out1]"

你可能感兴趣的:(linux,开发,windows)