基于FFmpeg的热成像摄像头多格式转换技术问题求助
树莓派3B+(32位Bullseye)FFmpeg处理UVC热成像摄像头原始数据问题
我在树莓派3B+的32位Bullseye系统上,无法生成合适的FFmpeg命令来处理UVC热成像摄像头的原始数据——目标是将数据上色后输出到虚拟设备,实现RTSP推流。
正常工作的预览命令
以下命令可正确预览上色后的热成像画面:
ffmpeg -input_format yuyv422 -video_size 256x384 -i /dev/video0 -vf 'crop=h=(ih/2):y=(ih/2)' -pix_fmt yuyv422 -f rawvideo - | ffplay -pixel_format gray16le -video_size 256x192 -f rawvideo -i - -vf 'normalize=smoothing=10, format=pix_fmts=rgb48, pseudocolor=p=inferno'
该命令的作用:提取原始数据中的有效区域(裁剪下半部分),通过管道传给ffplay;ffplay将数据识别为16位灰度格式(gray16le),再依次完成归一化、转48位RGB格式、应用inferno伪彩色滤镜。
尝试的命令及问题
我尝试将预览流程转为纯FFmpeg命令,或用v4l2loopback配合两个FFmpeg实例排查,但遇到编解码错误、格式错误,或16位数据被转为10位的问题。目前最接近的命令组合如下:
第一步,将裁剪后的原始数据输出到虚拟设备/dev/video3:
ffmpeg -input_format yuyv422 -video_size 256x384 -i /dev/video0 -vf 'crop=h=(ih/2):y=(ih/2)' -pix_fmt yuyv422 -f rawvideo /dev/video3
第二步,读取/dev/video3并处理后输出到/dev/video4:
ffmpeg -video_size 256x192 -i /dev/video3 -f rawvideo -pix_fmt gray16le -vf 'normalize=smoothing=10,format=pix_fmts=rgb48, pseudocolor=p=inferno' -f rawvideo -f v4l2 /dev/video4
但执行后结果异常:图像未上色,且部分温度区域出现像素丢失,而预览命令能正常显示完整的上色画面。
预览命令的运行日志
ffmpeg -input_format yuyv422 -video_size 256x384 -i /dev/video0 -vf 'crop=h=(ih/2):y=(ih/2)' -pix_fmt yuyv422 -f rawvideo - | ffplay -pixel_format gray16le -video_size 256x192 -f rawvideo -i - -vf 'normalize=smoothing=10, format=pix_fmts=rgb48, pseudocolor=p=inferno' ffplay version N-109758-gbdc76f467f Copyright (c) 2003-2023 the FFmpeg developers built with gcc 10 (Raspbian 10.2.1-6+rpi1) configuration: --prefix=/usr/local --enable-nonfree --enable-gpl --enable-hardcoded-tables --disable-ffprobe --disable-ffplay --enable-libx264 --enable-libx265 --enable-sdl --enable-sdl2 --enable-ffplay libavutil 57. 44.100 / 57. 44.100 libavcodec 59. 63.100 / 59. 63.100 libavformat 59. 38.100 / 59. 38.100 libavdevice 59. 8.101 / 59. 8.101 libavfilter 8. 56.100 / 8. 56.100 libswscale 6. 8.112 / 6. 8.112 libswresample 4. 9.100 / 4. 9.100 libpostproc 56. 7.100 / 56. 7.100 ffmpeg version N-109758-gbdc76f467f Copyright (c) 2000-2023 the FFmpeg developers built with gcc 10 (Raspbian 10.2.1-6+rpi1) configuration: --prefix=/usr/local --enable-nonfree --enable-gpl --enable-hardcoded-tables --disable-ffprobe --disable-ffplay --enable-libx264 --enable-libx265 --enable-sdl --enable-sdl2 --enable-ffplay libavutil 57. 44.100 / 57. 44.100 libavcodec 59. 63.100 / 59. 63.100 libavformat 59. 38.100 / 59. 38.100 libavdevice 59. 8.101 / 59. 8.101 libavfilter 8. 56.100 / 8. 56.100 libswscale 6. 8.112 / 6. 8.112 libswresample 4. 9.100 / 4. 9.100 libpostproc 56. 7.100 / 56. 7.100 Input #0, video4linux2,v4l2, from '/dev/video0':B sq= 0B f=0/0 Duration: N/A, start: 242.040935, bitrate: 39321 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 256x384, 39321 kb/s, 25 fps, 25 tbr, 1000k tbn Stream mapping:.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native)) Press [q] to stop, [?] for help Output #0, rawvideo, to 'pipe:': 0KB vq= 0KB sq= 0B f=0/0 Metadata: encoder : Lavf59.38.100 Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422(tv, progressive), 256x192, q=2-31, 19660 kb/s, 25 fps, 25 tbn Metadata: encoder : Lavc59.63.100 rawvideo frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbInput #0, rawvideo, from 'fd:': 0KB vq= 0KB sq= 0B f=0/0 Duration: N/A, start: 0.000000, bitrate: 19660 kb/s Stream #0:0: Video: rawvideo (Y1[0][16] / 0x10003159), gray16le, 256x192, 19660 kb/s, 25 tbr, 25 tbn frame= 13 fps=0.0 q=-0.0 size= 1152kB time=00:00:00.52 bitrate=18148.4kbitsframe= 25 fps= 24 q=-0.0 size= 2304kB time=00:00:01.00 bitrate=18874.4kbitsframe= 39 fps= 25 q=-0.0 size= 3648kB time=00:00:01.56 bitrate=19156.7kbitsframe= 51 fps= 24 q=-0.0 size= 4800kB time=00:00:02.04 bitrate=19275.3kbitsframe= 64 fps= 24 q=-0.0 size= 6048kB time=00:00:02.56 bitrate=19353.6kbitsframe= 78 fps= 25 q=-0.0 size= 7392kB time=00:00:03.12 bitrate=19408.7kbits
额外需求
- 寻找FFmpeg的选项,关闭日志的逐帧滚动显示,只保留关键信息。
- 适合初学者的FFmpeg命令转脚本的学习指引。
内容的提问来源于stack exchange,提问作者Greynol4
相关产品推荐
相关产品推荐

