명령줄에서 주어진 시간 간격 내에 지속 시간이 있는 모든 비디오 파일을 찾습니다.

명령줄에서 주어진 시간 간격 내에 지속 시간이 있는 모든 비디오 파일을 찾습니다.

특정 시간 간격 내에 지속 시간이 있는 모든 비디오 파일을 찾는 방법.

예를 들어 길이가 20~40분 사이인 모든 비디오 파일을 찾습니다.

답변1

다음 스크립트가 해당 작업을 수행합니다. 이는 비디오가 하나의 디렉토리(전체 시스템이 아님)에 있다고 가정합니다.

또한 스크립트는 사용자가 avprobe이를 설치 했다고 가정합니다. avconv즉, 해당 스크립트는 (의 일부)와 ffprobe동일한 구문을 가져야 합니다. ffmpeg출력이 ffprobe다른 경우 스크립트를 편집해야 합니다.

그러나 기간은 초 단위여야 합니다. 저장하면 계산이 수행됩니다.

#!/bin/sh

# NOTE: Assumes you have avprobe installed and the full path
# to it is /usr/bin/avprobe - if not, edit.

# Where are the videos?
MASTER="/home/tigger/Videos"
# Duration min in seconds (1200 = 20min)
DUR_MIN="1200"
# Duration max in seconds (2400 = 40min)
DUR_MAX="2400"

# Get a list of files
LIST=`find "$MASTER" -type f`

# In case of a space in file names, split on return
IFS_ORIG=$IFS
IFS="
"

valid="\nList of videos with duration between $DUR_MIN and $DUR_MAX seconds"

# Loop over the file list and probe each file.
for v in $LIST
do
    printf "Checking ${v}\n"
    dur=`/usr/bin/avprobe -v error -show_format_entry duration "${v}"`
    if [ -n $dur ]
    then
        # Convert the float to int
        dur=${dur%.*}
        if [ $dur -ge $DUR_MIN -a $dur -le $DUR_MAX ]
        then
            valid="${valid}\n$v"
        fi
    fi
done

printf "${valid}\n"
exit

관련 정보