I know this is very old, but when I came across and did not find another reliable answer, and after some testing:
An offer with a 0 return check is usually good advice - but does not help in all cases. Another idea with checking for a file is also good - but again - it does not help in all cases.
For example, when the input file is an mp3 file with a built-in cover, then ffmpeg (in my tests) uses this image and extracts it as a (unusable) video file.
Now I have to have the debug level output and analyze it for the number of multiplexed packets.
ffmpeg -i "wildlife.mp4" -c:v copy -an -sn "out.mp4" -y -loglevel debug 2> wildlife.txt
In regex, I am looking for this text:
Output stream .+ (video): [0-9][0-9]+ packets muxed \([0-9][0-9]+ bytes\)
(this assumes that each video has more than 9 packages - of course, it can be optimized for really short videos).
Of course, the output may be different for RTMP or other settings, but I think parsing the full output stream is the only option.
source share