0

So I have been trying filter out H265/HEVC and only show videos that are not the previous codec and then execute a command that I have that will transcode the video using my settings.

Every time I find a solution or a way I may manipulate into how I want it done, it doesn't work. Either an error of some kind or where it's outdated and that's not how it is done now.

But it should be something like this:

find /mnt/videos -type f *.mp4 exec $filtercmd; $transcodecmd

The command should only print the file's absolute path, that way I can have it be used by the second command so that it can be transcoded.

I would prefer using ffprobe as it seems to be a cleaner method. And I hate to basically ask someone write up a command or script but I just don't have the knowledge for something like this. Also it would be nice if this was written with the purpose of being on a schedule.

Thanks in advance!

EDIT:

I think I may have found a solution.

#!/bin/bash

# Reset
Color_Off='\033[0m'       # Text Reset

# Regular Colors
Red='\033[0;31m'          # Red
Green='\033[0;32m'        # Green

# Bold
BRed='\033[1;31m'         # Red
BGreen='\033[1;32m'       # Green


for i in $(find /mnt/movies/ -type f -name '*.mkv' -o -name '*.mp4' -o -name '*.wmv' -o -name '*.flv' -o -name '*.webm' -o -name '*.mov'); do
    ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "${i}"
    if [[ $1 == 'h264' ]]; then
        echo "Video is a ${BGreen}H264${Color_off} video file"
        python sickbeard_mp4_automator/manual.py -i "$i" -a
    elif [[ $1 == hevc ]]; then
        echo "Video is alread transcoded to ${BRed}HEVC${Color_Off}"
    fi
done

But it seems to be escaping the spaces. Can't seem to get it to quit. What do you guys think?

0

I found the answer!

#!/bin/bash

IFS=$'\n'

# Reset
Color_Off='\033[0m'       # Text Reset

# Regular Colors
Red='\033[0;31m'          # Red
Green='\033[0;32m'        # Green

# Bold
BRed='\033[1;31m'         # Red
BGreen='\033[1;32m'       # Green

for i in $(find /mnt/movies/ -type f -name '*.mkv' -o -name '*.mp4' -o -name '*.wmv' -o -name '*.flv' -o -name '*.webm' -o -name '*.mov'); do
#    ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i"
    if [ $(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i") = h264 ]; then
        echo -e "Video is a ${BGreen}H264${Color_Off} video file"
        python2 sickbeard_mp4_automator/manual.py -i "$i" -a
    elif [ $(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i") == hevc ]; then
        echo -e "Video is already transcoded to ${BRed}HEVC${Color_Off}"
    elif [ $(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i") == vp8 ]; then
        echo -e "Video is a ${BGreen}WEBM${Color_Off} video file"
        python2 sickbeard_mp4_automator/manual.py -i "$i" -a
    fi
done

This will check for H264 and will transcode the file. Otherwise it leaves it alone. Thanks guys for the help and realized that I can be an idiot sometimes. :)

-1

You can use the following command:

find /your/path -exec bash -c "if file {} | grep "python"; then cat {} ; fi" \;

This command will execute file on all files found and in case the output of this command contains "python", cat is executed.

Obviously, you have to adapt this command to your needs.

  • Ok. So this has promise. Thanks! But I have one problem. My files have spaces. I know, I know. It's not conventional but I like it like that. Is there a way to capture it properly? I don't want to test it out in case of loss of data. – shadow11001 Aug 30 at 18:19
  • I may have found a solution an feel like an idiot. And have edited my original post. – shadow11001 Aug 30 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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