1

I updated it a little bit, but I'm still not getting the results I should be getting:

#!/bin/bash
find "$1" -type f | while read filename
do

    videoCodec=$(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$filename")
    audioCodec=$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$filename")
    audioChannels=$(ffprobe -v error -select_streams a:0 -show_entries stream=channels -of default=noprint_wrappers=1:nokey=1 "$filename")

    echo $videoCodec $audioCodec $audioChannels $filename

    if [ $videoCodec = "h264" ] && [ $audioCodec = "aac" ] && [ audioChannels = "2" ] ; then
        echo "Direct play capable"
    fi

done

I run this on a folder containing a file that meets all the if conditions ("h264 aac 2 ./Black.Mass.(2015)/Black.Mass.(2015).mp4") but do not get the "Direct play capable" echo.

1
  • You seem to have left a $ out of audioChannels in the if statement.
    – dogoncouch
    May 21, 2017 at 18:31

1 Answer 1

1

You don't say, but is it supposed to not run for DTS audio? In any case, this line won't work right:

if [[ $video_good="true" && $audio_good="true" ]] ; then

Since there are no spaces around the equal signs, they're parsed as part of strings rather than as comparison operators. Use this instead:

    if [[ $video_good = "true" && $audio_good = "true" ]] ; then

(Double-equal signs, like you use in the earlier comparisons, would also work. But again, spaces around them are required.)

BTW, I strongly recommend double-quoting variable references (i.e. "$f" instead of just $f). But the way you're using $cli_video and $cli_audio wouldn't work if they were double-quoted, so don't do it to them. The really proper way to store parameters like that is to use arrays instead of plain variables, like this:

    cli_video=(-c:v copy)
...
    cli_audio=(-c:a copy)
...
    ffmpeg -i "$f" "${cli_video[@]}" "${cli_audio[@]}" "$(basename "$f")"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .