Opened 10 years ago
Closed 10 years ago
#4170 closed defect (invalid)
ffmpeg is modifying shell memory?
Reported by: | MisterE2002 | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | ffmpeg |
Version: | unspecified | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | yes |
Description
Summary of the bug: using ffmpeg in a bash script is changing the outcome
How to reproduce:
I am using this command:
./del.sh -d "/home/test/_TESTENDEL/"
In this folder are a couple of mp4 files.
if the "ffmpeg" line is commented the script works correct
expected output:
[test@laptop _SCRIPTS]$ ./del.sh -d "/home/test/_TESTENDEL/" listing of list: /home/test/_TESTENDEL/film2.mp4 /home/test/_TESTENDEL/film.mp4 INFO: processing file (1/2): "/home/test/_TESTENDEL/film2.mp4" 0 listing of list: /home/test/_TESTENDEL/film2.mp4 /home/test/_TESTENDEL/film.mp4 INFO: processing file (2/2): "/home/test/_TESTENDEL/film.mp4" 0
if i enabled the "ffmpeg" line the script gives wrong outputs:
[test@laptop _SCRIPTS]$ ./del.sh -d "/home/test/_TESTENDEL/" listing of list: /home/test/_TESTENDEL/film2.mp4 /home/test/_TESTENDEL/film.mp4 INFO: processing file (1/2): "/home/test/_TESTENDEL/film2.mp4" 0 listing of list: /home/test/_TESTENDEL/film2.mp4 /home/test/_TESTENDEL/film.mp4 INFO: processing file (2/2): "film.mp4" 1
notice, the path is dissapeared. Sometimes letters of the filename itself are gone too.
In some cases the loop itself refuses to iterate to the next file.
If i add more files all odd filename are wrong.
ffmpeg is doing something to the shell?
extra info:
Fedora: Linux laptop.local 3.17.4-200.fc20.x86_64 #1 SMP Fri Nov 21 23:26:41 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
ffmpeg version 2.1.6, built on Nov 29 2014 12:07:56 with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-7)
the bash script:
#!/bin/bash # $1: complete path to directory process () { list=$(find "$1" -maxdepth 1 -type f -name "*.mp4") amount=$(echo "$list" | sed '1{/^$/d}' | wc -l) currentindex=0 rm -f log.LOG echo "$list" |sort | while read file; do #while read file; do echo "listing of list:" echo "$list" currentindex=$((currentindex+1)) echo "INFO: processing file (${currentindex}/${amount}): \"$file\"" #log=$(ffmpeg -y -i "$file" -t 00:02:30 "${file}.mp3" 2>&1) #ffmpeg -y -i "$file" -t 00:02:30 "${file}.mp3" log=$(ffmpeg -y -v 9 -loglevel 99 -i "$file" -t 00:02:30 "${file}.mp3" 2>&1) echo $? echo $log >> log.LOG echo "*** $currentindex ***" >> log.LOG #done < <(echo "$list"|sort) done } DIR= while getopts ":d:cevlA" opt; do case $opt in d) DIR="$OPTARG" ;; \?) echo "Invalid argument: -$OPTARG" >&2 exit $E_ARGS ;; esac done process "$DIR"
Change History (1)
comment:1 by , 10 years ago
Analyzed by developer: | set |
---|---|
Component: | undetermined → ffmpeg |
Keywords: | bash loop strange output removed |
Resolution: | → invalid |
Status: | new → closed |
ffmpeg
reads on its standard input, and in this script, the standard input is connected toecho "$list" |sort
; therefore,ffmpeg
is competing withread file
for the output ofsort
.By the way, I hope you realize that this script will break utterly when certain special characters. If you can not do your task with a simple
*.mp4
, then you should drop the shell and use a real language.