1

I need to keep the correct output of avconv command:

filetype=`avconv -i first.mp3 2>&1`

echo $filetype

the results is an incorrect output. like this:

avconv version 11-6:11-2, Copyright (c) 2000-2014 the Libav developers built on Oct 19 2014 21:50:10 with gcc 4.9.1 (Debian 4.9.1-15) [mp3 @ 0x9c22840] max_analyze_duration 5000000 reached [mp3 @ 0x9c22840] Estimating duration from bitrate, this may be inaccurate Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, mp3, from 'first.mp3': Duration: 00:03:33.55, start: 0.000000, bitrate: 49 kb/s Stream #0.0: Audio: mp3, 22050 Hz, 2 channels, s16p, 49 kb/s At least one output file must be specified
  • 4
    What should the correct output look like? Please paste it into your question. Remember, not everyone here has avconv. BTW, don't use echo to display arbitrary data, use printf. Also "$()" is preferred over the use of backticks, as mentioned in the answer to your earlier question. – PM 2Ring Dec 14 '14 at 12:13
  • There are 2 issues here. One is whether all output goes to stdout, in which case you need to use awk as an optimal tool for parsing and conditional printing, whether by line, string match or positional match. The other is whether all output is going to stdout or stderr and whether the desired portion of that output goes to one or the other. Assuming you want to discard stdout and only keep stderr, the following will permit you to capture only stderr in a file: ( ( ./DummyCommand.sh >/dev/null ) 2>&1 )>outfile . – Eric Marceau Sep 14 '22 at 02:27

0 Answers0