def transcode(filename, enc_data):
 base = os.path.splitext(filename)[0]
 exe = (g.muxapp if (g.transcoder_path == 'auto') else g.transcoder_path)
 if ((not exe) or (not os.path.exists(exe)) or (not os.access(exe, os.X_OK))):
  util.xprint("Encoding failed. Couldn't find a valid encoder :(\n")
  time.sleep(2)
  return filename
 command = shlex.split(enc_data['command'])
 (newcom, outfn) = (command[::None], '')
 for (n, d) in enumerate(command):
  if (d == 'ENCODER_PATH'):
   newcom[n] = exe
  elif (d == 'IN'):
   newcom[n] = filename
  elif (d == 'OUT'):
   newcom[n] = outfn = base
  elif (d == 'OUT.EXT'):
   newcom[n] = outfn = ((base + '.') + enc_data['ext'])
 returncode = subprocess.call(newcom)
 if ((returncode == 0) and g.delete_orig):
  os.unlink(filename)
 return outfn

def transcode ( filename , enc_data ) : base = os . path . splitext ( filename ) [ 0 ] exe = ( g . muxapp if ( g . transcoder_path == 'auto' ) else g . transcoder_path ) if ( ( not exe ) or ( not os . path . exists ( exe ) ) or ( not os . access ( exe , os . X_OK ) ) ) : util . xprint ( "Encoding failed. Couldn't find a valid encoder :(\n" ) time . sleep ( 2 ) return filename command = shlex . split ( enc_data [ 'command' ] ) ( newcom , outfn ) = ( command [ : : None ] , '' ) for ( n , d ) in enumerate ( command ) : if ( d == 'ENCODER_PATH' ) : newcom [ n ] = exe elif ( d == 'IN' ) : newcom [ n ] = filename elif ( d == 'OUT' ) : newcom [ n ] = outfn = base elif ( d == 'OUT.EXT' ) : newcom [ n ] = outfn = ( ( base + '.' ) + enc_data [ 'ext' ] ) returncode = subprocess . call ( newcom ) if ( ( returncode == 0 ) and g . delete_orig ) : os . unlink ( filename ) return outfn
transcode a text string .