Opened 9 years ago

Closed 9 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


Summary of the bug: using ffmpeg in a bash script is changing the outcome
How to reproduce:
I am using this command:

./ -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]$ ./  -d "/home/test/_TESTENDEL/" 
listing of list:
INFO: processing file (1/2): "/home/test/_TESTENDEL/film2.mp4"
listing of list:
INFO: processing file (2/2): "/home/test/_TESTENDEL/film.mp4"

if i enabled the "ffmpeg" line the script gives wrong outputs:

[test@laptop _SCRIPTS]$ ./  -d "/home/test/_TESTENDEL/" 
listing of list:
INFO: processing file (1/2): "/home/test/_TESTENDEL/film2.mp4"
listing of list:
INFO: processing file (2/2): "film.mp4"

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:


# $1: complete path to directory
process () {

  list=$(find "$1" -maxdepth 1 -type f -name "*.mp4")
  amount=$(echo "$list" | sed '1{/^$/d}' | wc -l)

  rm -f log.LOG
  echo "$list" |sort | while read file; do
  #while read file; do
    echo "listing of list:"
    echo "$list"

    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)


while getopts ":d:cevlA" opt; do
  case $opt in

      echo "Invalid argument: -$OPTARG" >&2
      exit $E_ARGS

process "$DIR"

Change History (1)

comment:1 by Cigaes, 9 years ago

Analyzed by developer: set
Component: undeterminedffmpeg
Keywords: bash loop strange output removed
Resolution: invalid
Status: newclosed

ffmpeg reads on its standard input, and in this script, the standard input is connected to echo "$list" |sort; therefore, ffmpeg is competing with read file for the output of sort.

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.

Note: See TracTickets for help on using tickets.