ffmpeg简单使用
·
ffplay 播放rtsp流
ffplay.exe -rtsp_transport tcp rtsp://10.0.20.193/test2
ffplay 无缓冲播放流
ffplay.exe -rtsp_transport tcp -i rtsp://10.0.20.193/ai_stream -fflags nobuffer
使用ffmpeg 推流到rtsp server
ffmpeg -re -i test.mp4 -vcodec h264 -f rtsp -rtsp_transport tcp rtsp://10.0.20.221:554/test
循环推流
ffmpeg -re -stream_loop -1 -i test.mp4 -s 1280*720 -vcodec h264 -f rtsp -rtsp_transport tcp rtsp://10.0.20.221:554/test
常用到的rtsp sever
使用v4l2 查看本地usb camera 信息
# 查看支持的流信息
v4l2-ctl --list-formats-ext
# 设置流属性
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=960
使用ffmpeg 推送本地usbcamera rtsp 网络流
# software encode
ffmpeg -f v4l2 -i /dev/video0 -vf "format=nv12,scale=1920:1080" -vcodec libx264 -preset ultrafast -tune zerolatency -an -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:554/live/in7
ffmpeg -f v4l2 -i /dev/video0 -vf "format=nv12,scale=1920:1080,framerate=25" -vcodec libx264 -preset ultrafast -tune zerolatency -an -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:554/live/in7
ffmpeg -f v4l2 -list_formats all -i /dev/video0
# win10 查看设备
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -f dshow -list_options true -i video="Logi C270 HD WebCam"
# 查看编码起的属性
ffmpeg.exe -h encoder=h264_nvenc
# h264_nvenc
ffmpeg -f dshow -i "video=Logi C270 HD WebCam" -vf "format=nv12,scale=1920:1080" -vcodec h264_nvenc -preset p1 -tune ull -zerolatency true -an -rtsp_transport tcp -f rtsp rtsp://192.168.0.100:554/live/in7
ffmpeg -f dshow -i "video=Logi C270 HD WebCam" -vf "format=nv12,scale_cuda=1920:1080" -vcodec h264_nvenc -preset p1 -tune ull -zerolatency true -an -rtsp_transport tcp -f rtsp rtsp://192.168.0.100:554/live/in7
# intel qsv
ffmpeg -f v4l2 -i /dev/video0 -vf "format=nv12,scale=1920:1080,framerate=25" -vcodec h264_qsv -preset veryfast -tune zerolatency -an -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:554/in7
# build ffmpeg
./configure --enable-libv4l2 --enable-libx264 --enable-libvpl --enable-gpl --disable-x86asm --enable-shared
# intel vaapi
ffmpeg -vaapi_device /dev/dri/renderD128 -f v4l2 -i /dev/video0 -vf format=nv12,scale=1920:1080,hwupload -vcodec h264_vaapi -preset veryfast -tune zerolatency -an -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:554/in7
Install on nvidia platform and usage
- https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html
- Build
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
#Install ffnvcodec
cd nv-codec-headers
git checkout remotes/origin/sdk/8.1
sudo make install && cd –
#Clone FFmpeg's public GIT repository.
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/
#Install necessary packages.
sudo apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev
#Configure
./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared
#Compile
make -j 8
#Install the libraries.
sudo make install
- usage
#win10 nvidia
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -f dshow -i "video=Logi C270 HD WebCam" -vf "hwupload_cuda,scale_cuda=w=1920:h=1080:format=nv12" -vcodec h264_nvenc -preset p1 -tune ull -zerolatency true -an -rtsp_transport tcp -f rtsp rtsp://192.168.0.107:554/in7
#win10 qsv -> error
ffmpeg -hwaccel qsv -load_plugin hevc_hw -f dshow -i "video=Logi C270 HD WebCam"-vf hwdownload,scale_qsv=w=1920:h=1080:format=nv12 -c:v hevc_qsv -an -rtsp_transport tcp -f rtsp rtsp://192.168.0.107:554/in7
更多推荐
所有评论(0)