Skip to content

Instantly share code, notes, and snippets.

@sathishrs
Created April 16, 2023 05:46
Show Gist options
  • Save sathishrs/3962e7fc24a530378497e7e433fe00e6 to your computer and use it in GitHub Desktop.
Save sathishrs/3962e7fc24a530378497e7e433fe00e6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Input file
input_file="${1}"
# Run ffprobe to analyze the input file and capture the output
output=$(ffprobe -v quiet -show_streams -print_format json "$input_file")
# Check if the output contains video and/or audio streams
if [[ $output == *'"codec_type": "video"'* && $output == *'"codec_type": "audio"'* ]]; then
echo "Input file has both video and audio streams"
elif [[ $output == *'"codec_type": "video"'* ]]; then
echo "Input file has video stream"
elif [[ $output == *'"codec_type": "audio"'* ]]; then
echo "Input file has audio stream"
else
echo "Bad input"
fi
@sathishrs
Copy link
Author

chmod +z check_audio_video_using_ffprobe.sh
./check_audio_video_using_ffprobe.sh FILENAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment