Results 1 to 3 of 3

Thread: strange script behaviour

  1. #1
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    strange script behaviour

    background: I have my main box running as a headless server while we are staying with family for the summer, which I SSH to if I need to use RDP or do anything other than use MPD, Samba, DLNA, or Deluged.

    issue: I'm experiencing some odd behaviour with a shell script, which I'm using to convrrt some videos with ffmpeg. it runs fine if I don't specify a framerate or flags in advance. the issue is, that the '-z' test is reporting the variable empty even though it isn't, as seen here:
    here's the script:
    Code:
    #!/bin/bash
    # new file name
    if [ -z "$rate" ]; then
     rate="29.985"
    fi
    echo rate="$rate"
    
    if [ -z "$flags" ]; then
     flags="+aic+mv4"
    fi
    echo flags="$flags"
    
    F="converted/${1%.*}.mp4"
    if [ ! -d "converted" ]; then
     mkdir converted
    fi
    
    if [ ! -f "$F" ]; then    
     ffmpeg -i "$1" -r "$rate" -acodec libvo_aacenc -b 128k -vcodec mpeg4 -b 1200k -flags "$flags" "$F"
    fi
    Last edited by HiImTye; May 22nd, 2013 at 11:10 PM.

  2. #2
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: strange script behaviour

    If you don't export the variable, the script doesn't see it. Invoke it as
    Code:
    rate=25 avi2mp4 test

  3. #3
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: strange script behaviour

    thanks, I did thst before when I had the test inverted and it didn't work (for obvious reasons), and I had forgotten jntil just now. /embarassed

    edit: the new way to solve threads is a pain lol
    Last edited by HiImTye; May 22nd, 2013 at 11:11 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •