You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to check whether a file whose name end with .png is a really png file(is valid). And I think I can do this by check the error field in FFmpegProbeResult. But when I use the following code to check a invalid png file, the error in FFmpegProbeResult is null and I think it imply that the file can be decoded normal.
This is the code I used.
val ffprobe =FFprobe("/usr/local/bin/ffprobe")
val probeResult = ffprobe.probe(filename)
logger.info("format name is ${probeResult.format.format_name}, "+"duration is ${probeResult.format.duration}"+"size is ${probeResult.format.size}"+" error code is ${probeResult.error.code}")
and I got a exception as follow java.lang.NullPointerException: Cannot read field "code" because "probeResult.error" is null
Then I use the ffprobe in command line directly by this command. ffprobe -i test.png
I got info that the PNG is invalid. [png @ 0x7fa1a5808e00] Invalid PNG signature 0x3C21444F43545950. [image2 @ 0x7fa1a5015a00] decoding for stream 0 failed [image2 @ 0x7fa1a5015a00] Could not find codec parameters for stream 0 (Video: png, none(pc)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, image2, from 'test.png': Duration: 00:00:00.04, start: 0.000000, bitrate: 9780 kb/s Stream #0:0: Video: png, none(pc), 25 tbr, 25 tbn, 25 tbc
so I wonder how can I check if the file is valid by code, thank you for reply.
The text was updated successfully, but these errors were encountered:
Euklios
changed the title
how to check if a file is a really image file?
how to check if a file is really an image file?
Mar 12, 2024
I want to check whether a file whose name end with .png is a really png file(is valid). And I think I can do this by check the error field in FFmpegProbeResult. But when I use the following code to check a invalid png file, the error in FFmpegProbeResult is null and I think it imply that the file can be decoded normal.
This is the code I used.
and I got a exception as follow
java.lang.NullPointerException: Cannot read field "code" because "probeResult.error" is null
Then I use the ffprobe in command line directly by this command.
ffprobe -i test.png
I got info that the PNG is invalid.
[png @ 0x7fa1a5808e00] Invalid PNG signature 0x3C21444F43545950. [image2 @ 0x7fa1a5015a00] decoding for stream 0 failed [image2 @ 0x7fa1a5015a00] Could not find codec parameters for stream 0 (Video: png, none(pc)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, image2, from 'test.png': Duration: 00:00:00.04, start: 0.000000, bitrate: 9780 kb/s Stream #0:0: Video: png, none(pc), 25 tbr, 25 tbn, 25 tbc
so I wonder how can I check if the file is valid by code, thank you for reply.
The text was updated successfully, but these errors were encountered: