Merge branch 'video'
* video: decode video files (ffmpeg) move code to decodeFile() Read tags from video files
This commit is contained in:
commit
83997bcc57
68
atom
68
atom
@ -420,75 +420,7 @@ do
|
||||
rest=${rest#*|}
|
||||
performer=${rest%%|*}
|
||||
unset rest
|
||||
case "$mimetype" in
|
||||
'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
|
||||
getDestFile
|
||||
if (( copied ))
|
||||
|
||||
@ -1,5 +1,76 @@
|
||||
#!/bin/bash
|
||||
decodeFile() {
|
||||
case "$mimetype" in
|
||||
'video/'*)
|
||||
extractAudio
|
||||
sox_needed=1
|
||||
;;
|
||||
'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
|
||||
if ! decodetaskid=$(
|
||||
Select tasks id <<<"key = $tmpfile"
|
||||
)
|
||||
@ -46,4 +117,5 @@ decodeFile() {
|
||||
progressSpin
|
||||
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
|
||||
getTags_version='unknown-2'
|
||||
getTags_version='unknown-3'
|
||||
tagreaders+=( "$getTags_version" )
|
||||
getTags() {
|
||||
unset type
|
||||
@ -16,6 +16,9 @@ getTags() {
|
||||
audio/x-flac)
|
||||
type=FLAC
|
||||
;;
|
||||
video/*)
|
||||
type=ffmpeg
|
||||
;;
|
||||
*)
|
||||
extendedtype=$(file -b "$sourcepath/$filename")
|
||||
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