如何在GStreamer中解码.tga图像?解码报错求助
GStreamer解码TGA文件失败问题
文件信息
我尝试用GStreamer读取.tga文件并转换为视频,目前卡在TGA解码环节。该文件可被MacOS Preview正常打开,属性如下:
- 大小:8,294,418字节
- 分辨率:1920 x 1080
- 色彩空间:RGB Alpha(带通道)
文件大小符合计算值:1920×1080×4字节=8,294,000字节,包含合法TGA头部,是有效的无损图像文件。
尝试的解码管道及错误
我使用libav的avdec_targa解码器,执行了以下GStreamer管道命令:
gst-launch-1.0 -e filesrc location=/home/user/image.tga ! image/x-tga,width=1920,height=1080,framerate=1/1 ! avdec_targa ! videoconvert ! pngenc ! filesink location=output.png
运行后出现大量错误:
Setting pipeline to PAUSED ... Pipeline is PREROLLING ... Redistribute latency... 0:00:00.025646827 656 0x2685c60 WARN videodecoder gstvideodecoder.c:2425:gst_video_decoder_chain:<avdec_targa0> Received buffer without a new-segment. Assuming timestamps start from 0. 0:00:00.025789186 656 0x2685c60 ERROR libav :0:: Not enough data available for image 0:00:00.025815987 656 0x2685c60 WARN libav gstavviddec.c:1864:gst_ffmpegviddec_handle_frame:<avdec_targa0> Failed to send data for decoding 0:00:00.025842800 656 0x2685c60 ERROR libav :0:: Not enough data to read header 0:00:00.025856014 656 0x2685c60 WARN libav gstavviddec.c:1864:gst_ffmpegviddec_handle_frame:<avdec_targa0> Failed to send data for decoding 0:00:00.025874318 656 0x2685c60 ERROR libav :0:: Bit depth 186 is not supported 0:00:00.025887348 656 0x2685c60 WARN libav gstavviddec.c:1864:gst_ffmpegviddec_handle_frame:<avdec_targa0> Failed to send data for decoding 0:00:00.025897921 656 0x2685c60 ERROR libav :0:: Not enough data to read header 0:00:00.025909691 656 0x2685c60 WARN libav gstavviddec.c:1864:gst_ffmpegviddec_handle_frame:<avdec_targa0> Failed to send data for decoding 0:00:00.104450817 656 0x2685c60 WARN libav gstavviddec.c:1864:gst_ffmpegviddec_handle_frame:<avdec_targa0> Failed to send data for decoding 0:00:00.104466306 656 0x2685c60 WARN videodecoder gstvideodecoder.c:1140:gst_video_decoder_sink_event_default:<avdec_targa0> error: No valid frames decoded before end of stream 0:00:00.104473182 656 0x2685c60 WARN videodecoder gstvideodecoder.c:1140:gst_video_decoder_sink_event_default:<avdec_targa0> error: no valid frames found ERROR: from element /GstPipeline:pipeline0/avdec_targa:avdec_targa0: No valid frames decoded before end of stream Additional debug info: ../../../../../../../../src/Gstreamer-plugins-base/gst-libs/gst/video/gstvideodecoder.c(1140): gst_video_decoder_sink_event_default (): /GstPipeline:pipeline0/avdec_targa:avdec_targa0: no valid frames found ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ...
我对此感到困惑:根据计算,该图像位深为32位,但libav却识别为186位,希望得到解决提示。
补充验证信息
我用Python Pillow库读取该文件,代码如下:
from PIL import Image with Image.open("imageFrame_0001.tga") as img: for attribute_name in dir(img): attribute = getattr(img, attribute_name) if not callable(attribute): print(f"{attribute_name}: {attribute}")
得到的元数据:
'version': 3 'shape': (1080, 1920, 4) 'typestr': '|u1' 'mode': 'RGBA', 'info': {'orientation': -1}, 'tile': [], 'decoderconfig': (), 'decodermaxblock': 65536, 'fp': None, 'filename': 'imageFrame_0001.tga', __module__: PIL.TgaImagePlugin _category: 0 format: TGA format_description: Targa info: {'orientation': -1} mode: RGBA readonly: 0 size: (1920, 1080) width: 1920 height: 1080
内容的提问来源于stack exchange,提问作者Xiangyang Shi
相关产品推荐
相关产品推荐

