1.将视频文件分解称多个JPG文件
ffmpeg -i 1.264 example.%d.jpg
2.mp4转h264
ffmpeg -i 2018.mp4 -codec copy -bsf: h264_mp4toannexb -f h264 tmp.264
3.从h264文件中截取yuv数据
ffmpeg -i 720P.264 -s 1280x720 -pix_fmt yuv422p 720P-out.yuv
4.JPG和YUV格式互换
ffmpeg -i a.jpg -s 640x480 -pix_fmt yuv422p a.yuv
ffmpeg -pix_fmt yuv422p -s 640x480 -i a.yuv b.jpg
5.读取笔记本摄像头数据
ffmpeg -f alsa -i pulse -f video4linux2 -s qcif -i /dev/video0 ./output.mpg
ffmpeg -f video4linux2 -s 320*240 -r 10 -i /dev/video0 test.asf
ffplay [-f rawvideo] -video_size 640x480 test.yuv
ffplay -f rawvideo -video_size 1920x1080 test_1.yuv
ffmpeg -v 40 -r 10 -i /dev/video0 -s 640x480 -pix_fmt yuv420p -y video.yuv
ffmpeg -f video4linux2 -s 1280x720 -i /dev/video0 -pix_fmt yuv420p -y video.yuv
ffmpeg -f video4linux2 -r 10 -s 640x480 -i /dev/video1 -pix_fmt yuv420p -y /tmp/video.yuv
ffmpeg -i video1.mp4 -ss 00:00:20 -t 10 -s 640x272 -pix_fmt yuv420p video1.yuv
6.获取摄像头YUV数据,并播放
ffmpeg -r 10 -i /dev/video0 -s 1280x720 -pix_fmt yuv420p 720P-out.yuv
ffmpeg -i /dev/video0 -s 1280x720 -pix_fmt yuv420p -r 10 720P-out.yuv
ffplay -f rawvideo -video_size 1280x720 720P-out.yuv
7.访问网络摄像头,获取不同格式的数据
rtsp://admin:admin123@172.17.127.21
rtsp://172.17.127.21
ffmpeg -i rtsp://admin:admin123@172.17.127.21 -s 1920x1080 -pix_fmt yuv420p -r 10 720P-out.yuv
ffplay -f rawvideo -video_size 1920x1080 720P-out.yuv
ffmpeg -pix_fmt yuv420p -s 1920x1080 -i 7.yuv b.jpg
ffmpeg -i rtsp://admin:admin123@172.17.127.21 -s 1920x1080 -pix_fmt yuv420p -r 10 -y 7.yuv < /dev/null &
7.查看摄像头支持的格式和分辨率
ffmpeg -f v4l2 -list_formats all -i /dev/video0
7.查看摄像头信息
v4l2-ctl -d /dev/video0 --all
river Info (not using libv4l2):
Driver name : uvcvideo
Card type : Integrated Camera: Integrated C
Bus info : usb-0000:00:1a.0-1.6
Driver version: 4.18.17
Capabilities : 0x84A00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 320/240
Pixel Format : 'YUYV'
Field : None
Bytes per Line : 640
Size Image : 153600
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 320, Height 240
Default : Left 0, Top 0, Width 320, Height 240
Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 320, Height 240
Selection: crop_bounds, Left 0, Top 0, Width 320, Height 240
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=15 value=15
contrast 0x00980901 (int) : min=0 max=95 step=1 default=30 value=30
saturation 0x00980902 (int) : min=0 max=100 step=1 default=40 value=40
hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=48 max=300 step=1 default=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=1 max=7 step=1 default=2 value=2
backlight_compensation 0x0098091c (int) : min=0 max=2 step=1 default=1 value=1
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=3
exposure_absolute 0x009a0902 (int) : min=333 max=5000 step=1 default=333 value=333 flags=inactive
exposure_auto_priority 0x009a0903 (bool) : default=0 value=1
pan_absolute 0x009a0908 (int) : min=-36000 max=36000 step=3600 default=0 value=0
tilt_absolute 0x009a0909 (int) : min=-36000 max=36000 step=3600 default=0 value=0
zoom_absolute 0x009a090d (int) : min=0 max=10 step=1 default=0 value=0
privacy 0x009a0910 (bool) : default=0 value=0
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x1b97180] fd:3 capabilities:84000001
[video4linux2,v4l2 @ 0x1b97180] Current input_channel: 0, input_name: Camera 1, input_std: 0
[video4linux2,v4l2 @ 0x1b97180] Querying the device for the current frame size
[video4linux2,v4l2 @ 0x1b97180] Setting frame size to 1920x1080
[video4linux2,v4l2 @ 0x1b97180] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x1b97180] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x1b97180] The V4L2 driver changed the pixel format from 0x32315559 to 0x47504A4D
[video4linux2,v4l2 @ 0x1b97180] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x1b97180] The V4L2 driver changed the pixel format from 0x32315659 to 0x47504A4D
[video4linux2,v4l2 @ 0x1b97180] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x1b97180] The V4L2 driver changed the pixel format from 0x50323234 to 0x47504A4D
[video4linux2,v4l2 @ 0x1b97180] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x1b97180] All info found
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 15018.307882, bitrate: 165888 kb/s
Stream #0:0, 1, 1/1000000: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 1/1000000, 165888 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc
Successfully opened the file.