Given:
An ffprobe command that detects duration of an mp4 video files on a remote host.
Expected:
Output of ffprobe is prefixed with custom string and redirected to a text file.
Problem:
Sometimes due to network error, ffprobe fails with some error message. I would like to capture that error, prefix it with a custom string and send it to a text file.
Example:
This command appends "ABC=55" to out.txt where 55 is the discovered duration:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 https://example.com/video.mp4' | awk '{print "ABC="$1}' 2>&1 >> out.txt
However, if that same command encounters a network error, instead of writing "ABC=Error message here", it writes noting to text file and shows that message in console.
Question
How do I tweak this part to capture execution errors, prefix them with "ABC=" and send to out.txt?
| awk '{print "ABC="$1}' 2>&1 >> out.txt
Thank you.
EDIT
This solved the problem:
2>&1 | awk '{print "ABC="$0}'