Merge branch 'video'
* video: decode video files (ffmpeg) move code to decodeFile() Read tags from video files
This commit is contained in:
commit
83997bcc57
70
atom
70
atom
@ -420,75 +420,7 @@ do
|
|||||||
rest=${rest#*|}
|
rest=${rest#*|}
|
||||||
performer=${rest%%|*}
|
performer=${rest%%|*}
|
||||||
unset rest
|
unset rest
|
||||||
case "$mimetype" in
|
decodeFile
|
||||||
'audio/mpeg')
|
|
||||||
if [[ ${destinationformat[$destination]} = mp3 ]] \
|
|
||||||
&& checkCopy
|
|
||||||
then
|
|
||||||
copied=1
|
|
||||||
else
|
|
||||||
decodeSox
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'application/ogg opus')
|
|
||||||
if [[ ${destinationformat[$destination]} = opus ]] \
|
|
||||||
&& checkCopy
|
|
||||||
then
|
|
||||||
copied=1
|
|
||||||
else
|
|
||||||
decodeOpusdec
|
|
||||||
if (( ${destinationnormalize["$destination"]}))\
|
|
||||||
|| (
|
|
||||||
[ -n "${destinationfrequency["$destination"]}" ]\
|
|
||||||
&& (( ${rate:-0} != ${destinationfrequency["$destination"]}))\
|
|
||||||
) || (
|
|
||||||
[ -n "${destinationchannels["$destination"]}" ]\
|
|
||||||
&& (( ${channels:-0} != ${destinationchannels["$destination"]} ))
|
|
||||||
)
|
|
||||||
then
|
|
||||||
sox_needed=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'application/ogg'*)
|
|
||||||
if [[ ${destinationformat[$destination]} = vorbis ]] \
|
|
||||||
&& checkCopy
|
|
||||||
then
|
|
||||||
copied=1
|
|
||||||
else
|
|
||||||
decodeSox
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'audio/x-flac')
|
|
||||||
decodeSox
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
extendedtype=$(file -b "$sourcepath/$filename")
|
|
||||||
case "$extendedtype" in
|
|
||||||
*'Musepack '*)
|
|
||||||
decodeMpcdec
|
|
||||||
if (( ${destinationnormalize["$destination"]}))\
|
|
||||||
|| (
|
|
||||||
[ -n "${destinationfrequency["$destination"]}" ]\
|
|
||||||
&& (( ${rate:-0} != ${destinationfrequency["$destination"]}))\
|
|
||||||
) || (
|
|
||||||
[ -n "${destinationchannels["$destination"]}" ]\
|
|
||||||
&& (( ${channels:-0} != ${destinationchannels["$destination"]} ))
|
|
||||||
)
|
|
||||||
then
|
|
||||||
sox_needed=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
decodeSox
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if ! (( copied ))
|
|
||||||
then
|
|
||||||
decodeFile
|
|
||||||
fi
|
|
||||||
getDestDir
|
getDestDir
|
||||||
getDestFile
|
getDestFile
|
||||||
if (( copied ))
|
if (( copied ))
|
||||||
|
|||||||
@ -1,33 +1,81 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
decodeFile() {
|
decodeFile() {
|
||||||
if ! decodetaskid=$(
|
case "$mimetype" in
|
||||||
Select tasks id <<<"key = $tmpfile"
|
'video/'*)
|
||||||
)
|
extractAudio
|
||||||
then
|
sox_needed=1
|
||||||
decodetaskid=$(
|
;;
|
||||||
Insert tasks <<-EOInsert
|
'audio/mpeg')
|
||||||
key $tmpfile
|
if [[ ${destinationformat[$destination]} = mp3 ]] \
|
||||||
source_file $fileid
|
&& checkCopy
|
||||||
$(
|
then
|
||||||
for key in ${!commandline[@]}
|
copied=1
|
||||||
do
|
else
|
||||||
echo "cmd_arg$key ${commandline[key]}"
|
decodeSox
|
||||||
done
|
fi
|
||||||
|
;;
|
||||||
|
'application/ogg opus')
|
||||||
|
if [[ ${destinationformat[$destination]} = opus ]] \
|
||||||
|
&& checkCopy
|
||||||
|
then
|
||||||
|
copied=1
|
||||||
|
else
|
||||||
|
decodeOpusdec
|
||||||
|
if (( ${destinationnormalize["$destination"]}))\
|
||||||
|
|| (
|
||||||
|
[ -n "${destinationfrequency["$destination"]}" ]\
|
||||||
|
&& (( ${rate:-0} != ${destinationfrequency["$destination"]}))\
|
||||||
|
) || (
|
||||||
|
[ -n "${destinationchannels["$destination"]}" ]\
|
||||||
|
&& (( ${channels:-0} != ${destinationchannels["$destination"]} ))
|
||||||
)
|
)
|
||||||
status 0
|
then
|
||||||
EOInsert
|
sox_needed=1
|
||||||
)
|
fi
|
||||||
progressSpin
|
fi
|
||||||
fi
|
;;
|
||||||
if (( sox_needed ))
|
'application/ogg'*)
|
||||||
|
if [[ ${destinationformat[$destination]} = vorbis ]] \
|
||||||
|
&& checkCopy
|
||||||
|
then
|
||||||
|
copied=1
|
||||||
|
else
|
||||||
|
decodeSox
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
'audio/x-flac')
|
||||||
|
decodeSox
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
extendedtype=$(file -b "$sourcepath/$filename")
|
||||||
|
case "$extendedtype" in
|
||||||
|
*'Musepack '*)
|
||||||
|
decodeMpcdec
|
||||||
|
if (( ${destinationnormalize["$destination"]}))\
|
||||||
|
|| (
|
||||||
|
[ -n "${destinationfrequency["$destination"]}" ]\
|
||||||
|
&& (( ${rate:-0} != ${destinationfrequency["$destination"]}))\
|
||||||
|
) || (
|
||||||
|
[ -n "${destinationchannels["$destination"]}" ]\
|
||||||
|
&& (( ${channels:-0} != ${destinationchannels["$destination"]} ))
|
||||||
|
)
|
||||||
|
then
|
||||||
|
sox_needed=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
decodeSox
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if ! (( copied ))
|
||||||
then
|
then
|
||||||
cleanup="$tempdir/$tmpfile"
|
if ! decodetaskid=$(
|
||||||
decodeSox "$tempdir/$tmpfile.wav"
|
|
||||||
if ! soxtaskid=$(
|
|
||||||
Select tasks id <<<"key = $tmpfile"
|
Select tasks id <<<"key = $tmpfile"
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
soxtaskid=$(
|
decodetaskid=$(
|
||||||
Insert tasks <<-EOInsert
|
Insert tasks <<-EOInsert
|
||||||
key $tmpfile
|
key $tmpfile
|
||||||
source_file $fileid
|
source_file $fileid
|
||||||
@ -37,13 +85,37 @@ decodeFile() {
|
|||||||
echo "cmd_arg$key ${commandline[key]}"
|
echo "cmd_arg$key ${commandline[key]}"
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
requires $decodetaskid
|
|
||||||
required $decodetaskid
|
|
||||||
status 0
|
status 0
|
||||||
cleanup $cleanup
|
|
||||||
EOInsert
|
EOInsert
|
||||||
)
|
)
|
||||||
progressSpin
|
progressSpin
|
||||||
fi
|
fi
|
||||||
|
if (( sox_needed ))
|
||||||
|
then
|
||||||
|
cleanup="$tempdir/$tmpfile"
|
||||||
|
decodeSox "$tempdir/$tmpfile.wav"
|
||||||
|
if ! soxtaskid=$(
|
||||||
|
Select tasks id <<<"key = $tmpfile"
|
||||||
|
)
|
||||||
|
then
|
||||||
|
soxtaskid=$(
|
||||||
|
Insert tasks <<-EOInsert
|
||||||
|
key $tmpfile
|
||||||
|
source_file $fileid
|
||||||
|
$(
|
||||||
|
for key in ${!commandline[@]}
|
||||||
|
do
|
||||||
|
echo "cmd_arg$key ${commandline[key]}"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
requires $decodetaskid
|
||||||
|
required $decodetaskid
|
||||||
|
status 0
|
||||||
|
cleanup $cleanup
|
||||||
|
EOInsert
|
||||||
|
)
|
||||||
|
progressSpin
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
51
lib/tags/getInfos::ffmpeg
Normal file
51
lib/tags/getInfos::ffmpeg
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
getInfosffmpeg_version='ffmpeg-1'
|
||||||
|
tagreaders+=( "$getInfosffmpeg_version" )
|
||||||
|
getInfos::ffmpeg() {
|
||||||
|
tagreader="$getInfosffmpeg_version"
|
||||||
|
local allinfos=$(
|
||||||
|
ffprobe -show_streams \
|
||||||
|
-i "$sourcepath/$filename" 2>&1 \
|
||||||
|
|sed '
|
||||||
|
/^Input/,/.* Audio: /{s/ *: */=/}
|
||||||
|
s/^[[:space:]]*//'
|
||||||
|
)
|
||||||
|
local metadata=$(
|
||||||
|
echo -e "$allinfos" \
|
||||||
|
|sed -n '/Metadata=/,/\[STREAM\]/p'
|
||||||
|
)
|
||||||
|
local fmt_infos=$(
|
||||||
|
echo -e "$allinfos" \
|
||||||
|
|sed -n \
|
||||||
|
'/codec_type=audio/,/\[STREAM\]/{
|
||||||
|
/^\(sample_rate\|bit_rate\|channels\)=/{
|
||||||
|
p
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
)
|
||||||
|
local infos="$metadata"
|
||||||
|
albumartist=$(gettag album_artist)
|
||||||
|
album=$(gettag album)
|
||||||
|
artist=$(gettag artist)
|
||||||
|
composer=$(gettag composer)
|
||||||
|
genre=$(gettag genre)
|
||||||
|
performer=$(gettag TOPE)
|
||||||
|
title=$(gettag title)
|
||||||
|
tracknum=$(gettag tracknumber)
|
||||||
|
year=$(gettag year)
|
||||||
|
expr='^[0-9]*$'
|
||||||
|
if [ -n "$genre" ] && [[ $genre =~ $expr ]]
|
||||||
|
then
|
||||||
|
genre="${id3genres[$genre]}"
|
||||||
|
fi
|
||||||
|
infos="$fmt_infos"
|
||||||
|
channels=$(gettag channels)
|
||||||
|
rate=$(gettag 'sample_rate')
|
||||||
|
bitrate=$(gettag 'bit_rate')
|
||||||
|
if [[ $bitrate == N/A ]]
|
||||||
|
then
|
||||||
|
unset bitrate
|
||||||
|
else
|
||||||
|
bitrate=$((bitrate / 1000))
|
||||||
|
fi
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
getTags_version='unknown-2'
|
getTags_version='unknown-3'
|
||||||
tagreaders+=( "$getTags_version" )
|
tagreaders+=( "$getTags_version" )
|
||||||
getTags() {
|
getTags() {
|
||||||
unset type
|
unset type
|
||||||
@ -16,6 +16,9 @@ getTags() {
|
|||||||
audio/x-flac)
|
audio/x-flac)
|
||||||
type=FLAC
|
type=FLAC
|
||||||
;;
|
;;
|
||||||
|
video/*)
|
||||||
|
type=ffmpeg
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
extendedtype=$(file -b "$sourcepath/$filename")
|
extendedtype=$(file -b "$sourcepath/$filename")
|
||||||
case "$extendedtype" in
|
case "$extendedtype" in
|
||||||
|
|||||||
6
lib/video/extractaudio
Normal file
6
lib/video/extractaudio
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
extractAudio() {
|
||||||
|
tmpfile="${fileid}ffmpeg"
|
||||||
|
commandline=(${ionice}ffmpeg -v 0 -vn -y)
|
||||||
|
commandline+=(-i "$sourcepath/$filename" "$tempdir/$tmpfile.wav")
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user