Score:0

Arguments from bash script to ffprobe not correctly interepreted

pk flag

I have the following function in a bash script. When I execute it, I always get a returned string from the ffprobe command containing an error in the form:

Argument '-' provided as input filename, but '/media/Testing/Sorted/badfile.mp4' was already specified.

I have tried moving the arguments to ffprobe inside the quotes for the filename (doesn't solve the problem). I have tried moving the arguments into an array and passing "${array[@]}" (doesn't solve the problem). Obviously I am missing something blindingly obvious here. Where am I going wrong?

# ProcessVideo
#
# Takes an input file name (presumably for a video file, but the function doesn't
# actually attempt to verify that), and hands it off to ffprobe to do some basic 
# processing of the video stream. We set a flag so that any error encountered will
# cause ffmpeg to exit with an error code set. If ffmpeg sets an error code, we
# log the file name to a file.
#
# ProcessVideo <path to video>

ProcessVideo()
{
    local vfn=$1
    local ec=0
    local oput
    echo "Checking video $vfn"
    oput=$(ffprobe -loglevel warning "$vfn" - 2>&1)
    ec=$?
#   if (( ec > 0 ))
#   then
#       echo "Error exit $ec $vfn"
#       LogErr "Error exit $ec $vfn"
#   fi
#   if [[ "$oput" == *"moov atom"* ]]
    if [[ -n "$oput" ]]
    then
        echo "Error string $vfn"
        LogErr "Error string $vfn"
        LogErr "$oput"
    fi
}

Note that LogErr in the script above is another function - all it does is take the passed string and write it to a specified log file. If someone thinks that is relevant to the problem, I will post it, but I don't think it is.

hr flag
Are you sure the problem is with the arguments *passed* to the function - not the hardcoded `-` that you have in `$(ffprobe -loglevel warning "$vfn" - 2>&1)` ?
Cyrus avatar
cn flag
Should ffprobe read from "$vfn" or from stdin?
Tracy avatar
pk flag
Thank you both, for pointing the error out - I was focusing on the wrong '-'. This is what I get for adapting a script to a different purpose without completely rewriting the relevant sections.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.