
Hasta ahora sólo tengo espacios y comillas simples para tratar, así que lo puse entre comillas dobles.
#!/bin/bash
#ffmpeg -i Muppets\ Most\ Wanted_KBYUT_2017_07_08_18_56_00.wtv -f ffmetadata metadata.txt
#ffmpeg -i Gene\ Roddenberry\'s\ Andromeda_COMET_2017_12_14_20_05_51.wtv -f ffmetadata metadata1.txt
find . -type f | grep 'wtv$' | while read file; do
echo "----"
echo "----"
echo "----"
echo "$file"
ls -alh "$file"
echo "$file.txt"
#ffmpeg -i "$file" -f ffmetadata "$file.txt"
done
imprime
stephen@B450-AORUS-M:~/Videos$ ./ffmetadata.sh
./Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv
-rw------- 1 stephen stephen 7.9G Sep 6 2019 './Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv'
./Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv.txt
./Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv
-rw------- 1 stephen stephen 794M Dec 16 2017 "./Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv"
./Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv.txt
Se ve bien, así que intento dejar que ffmpeg haga su trabajo, descomentando una línea, y obtengo
stephen@B450-AORUS-M:~/Videos$ ./ffmetadata.sh
./Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv
-rw------- 1 stephen stephen 7.9G Sep 6 2019 './Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv'
./Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv.txt
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
...
Input #0, wtv, from './Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv':
Metadata:
WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
Title : Muppets Most Wanted
...
Output #0, ffmetadata, to './Muppets Most Wanted_KBYUT_2017_07_08_18_56_00.wtv.txt':
Metadata:
WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
Title : Muppets Most Wanted
...
Stream mapping:
Press [q] to stop, [?] for help
size= 2kB time=-577014:32:22.77 bitrate=N/A speed=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded
----
----
----
/Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv
ls: cannot access "/Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv": No such file or directory
/Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv.txt
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
...
libpostproc 54. 7.100 / 54. 7.100
/Gene Roddenberry's Andromeda_COMET_2017_12_14_20_05_51.wtv: No such file or directory
El primer archivo funciona, pero el segundo archivo pierde el punto inicial, cambiando la ruta relativa a una ruta absoluta. Probé 3 archivos en la carpeta y 2 funcionan. 4 archivos 2 trabajos. 6 archivos 3 trabajos.
Respuesta1
El líder "." está siendo consumido por ffmpeg
(cuando pregunta sobre el mapeo de flujo), que comparte su entrada estándar con read
.
Deberías usar find
las capacidades de en su lugar:
find . -type f -name '*wtv' -ls -exec ffmpeg -i {} -f ffmetadata {}.txt \;
Esto busca archivos cuyo nombre termina en wtv
, muestra su información detallada (que es una extensión GNU; utilícela -print
si find
no es compatible con ls
) y ffmpeg
los ejecuta.