ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login
    1. Topics
    2. Alexis
    3. Best
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 3
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Calling Complex System Commands from Python

      @Alexis said:

      cmdstr2 = """ffmpeg -i " + moviespec + " 2>&1 | sed -n 's/., (.) fp.*/\1/p'"""

      Okay, I forgot to escape one of the backslashes in the sed string. The proper python-fu is:

      cmdstr3 = "\"\"ffmpeg -i " + moviespec + " 2>&1 | sed -n 's/.*, \(.*\) fp.*/\\1/p'\"\""
      

      ...which properly returns the FPS of the movie file.

      Thanks so much for getting me started on this! I'm converting my bash scripts to python and learning the language in the process!

      posted in Developer Discussion
      A
      Alexis
    • RE: Calling Complex System Commands from Python

      [My editor changed the simple quotes into “smart” quotes for the posting, sorry.]

      Anyway, the code below works to obtain the movie resolution. It returns the string “640x480” for the moviespec var I’m using:

      cmdstr1 = "\"\"ffmpeg -i " + moviespec + " 2>&1 | sed -n 's/.*, \(.*\) \[.*/\\1/p'\"\""
      stdoutstr1 = subprocess.check_output(
          cmdstr1,
          shell=True, universal_newlines=True)
      

      However, in translating the following bash line to obtain the frames/second:

      fps=$(/opt/local/bin/ffmpeg -i $moviespec 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p")
      

      The above line, translated into pythonese, returns null:

      cmdstr2 = "\"\"ffmpeg -i " + moviespec + " 2>&1 | sed -n 's/.*, \(.*\) fp.*/\1/p'\"\""
      stdoutstr2 = subprocess.check_output(
          cmdstr2,
          shell=True, universal_newlines=True)
      

      I can’t spot what my error might be here.

      posted in Developer Discussion
      A
      Alexis
    • 1 / 1