Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i save ffmpeg file-info output to a variable? if i put the following command into variable it's always empty, even though the command generates an output /usr/bin/ffmpeg/ffmpeg -i $1

what i've tried

INFO=$(/usr/bin/ffmpeg/ffmpeg -i $1)

if [ -z "$INFO" ]; then
        echo "empty variable"
        echo "$INFO"
share|improve this question
what issue you are facing? – Guru Jan 21 '13 at 10:30
the variable is empty. – teslasimus Jan 21 '13 at 10:35
without saving into variable, can you try running the command directly within the script to make sure output is generated? – Guru Jan 21 '13 at 10:40
up vote 3 down vote accepted

Try saving both STDERR and STDOUT. The following command will redirect standard error to standard output:

INFO=$(/usr/bin/ffmpeg/ffmpeg -i $1 2>&1)

By default, ffmpeg puts all its text output to STDERR, leaving STDOUT free for piping video/audio data to other applications.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.