FFmpeg command line (ffmpeg, ffplay, ffprobe)

ffmpeg command line

A command line tool to convert multimedia files between formats.

name Order explain
View current device input information ffmpeg -f avfoundation -list_devices true -i “”
Mac device recording ffmpeg -f avfoundation -i “:” output.mkv
capture screen ffmpeg -f avfoundation -i 1 -r 15 out.yuv -i (0 camera, 1 built-in screen, 2 external screen-1, 3 external screen-2)
yuv sampling video resolution and color space conversion ffmpeg -video_size 2560x1440 -pix_fmt uyvy422 -i out.yuv -s 1920x1080 -pix_fmt yuv420p out.yuv
Encoding Video Frame Rate Control ffmpeg -r 80 -i input output ffmpeg -i input -r 20 output The location of -r is different, which determines whether its parameters work on the input video or the output video. Put it before the input, reduce the fps, and increase the video duration: make the duration of the output file be half and twice the original, that is, the playback speed is twice and half of the original. After putting it into the input, reduce the fps, the video duration will remain the same, the frame will be lost, and the quality will deteriorate: the code stream of the output file is theoretically about half of the input file.
Mac video hardcoded ffmpeg -r 5 -s 1920x1080 -i ppt.yuv -b 1000000 -profile high -coder cabac -vcodec h264_videotoolbox -y out.h264
Generate video with motion vectors ffmpeg -flags2 +export_mvs -i input.mp4 -vf codecview=mv=pf+bf+bb output.mp4
Calculate the psnr of two YUV ffmpeg -s 720x1280 -i input.yuv -s 720x1280 -i input2.yuv -lavfi psnr=“psnr.log” -f null -
Capture a part of the original video ffmpeg -s 720x1280 -i input.yuv -ss 00:00:00 -to 00:00:40 output.yuv Cut the file from 50 seconds to 20 seconds and input it to a new file, -ss is the specified time, -t is the specified duration
Remove watermark from video ffmpeg -i test.mp4 -vf delogo=x=?:y=?:w=?:h=?:show=? out.mp4 x, y position of the logo; w, h width and height of the logo; show When set to 1, a green rectangle will be drawn on the screen to simplify finding the correct x, y, w and h parameters. The default value is 0.
Convert each frame of the video into an image ffmpeg -i input.mp4 ‘out.bmp’
video to gif ffmpeg -i small.mp4 small.gif
video cut ffmpeg -i input.mp4 -vf crop=410:720 -y out.mp4 The parameter format of crop is w: h: x : y; w and h are the width and height of the output video; x and y are a certain point in the video, use this point as a reference point, and crop it to the bottom right to get the output video. If x and y are not written, it will be centered by default.
rotate transpose ffmpeg -i input.jpg -vf transpose=2 -y out.jpg There is no black background after rotation; transpose=0 rotates 90° counterclockwise, then flips vertically; transpose=1 rotates 90° clockwise; transpose=2 rotates 90° counterclockwise; transpose=3 rotates 90° clockwise and then flips vertically.
rotate rotate ffmpeg -i input.jpg -vf rotate=PI/3 -y out.jpg With a black background after rotation, the original width and height of the video/picture have not changed.

ffprobe command line

A simple multimedia stream analyzer.

name Order explain
View video frame frame information ffprobe -show_frames input.h264
View video stream information ffprobe -show_streams input.h264

ffplay command line

A simple media player based on SDL and the FFmpeg libraries.

name Order explain
Show license ffplay -L
help ffplay -h
View motion vector mv information ffplay -flags2 +export_mvs output.h264 -vf codecview=mv=pf
Macroblock MB information is printed to local txt ffplay -debug mb_type thinkvision-2560x1440.mp4 2>mv.txt
play yuv ffplay -f rawvideo -video_size 2560x1440 -pixel_format uyvy422 out.yuv
ffplay play aac ffplay -f f32le -ac 1 -ar 44100 test.aac -ac specifies the number of channels, -ar specifies the sampling rate
ffplay play rgb ffplay -f rawvideo -pixel_format rgb24 -video_size 480x480 texture.rgb
Specify the window size to play ffplay -x 400 output.mp4 Specify the size of the playback window to be 500 pixels

Batch transcoding/transcapsulation scripts (and delete original files)

#!/bin/bash
for i in *.mkv;
 do echo"${i%.*}.mp4"; 
 ffmpeg -i "$i" -codec copy "${i%.*}.mp4";
 rm -rf "${i%.*}.mkv";
 done

Guess you like

Origin blog.csdn.net/yanceyxin/article/details/126453647