What determines how long you meditate for?
Solution 1:
Your meditation duration appears to be random, but it increases based on your Meditation skill. How many people there are nearby doesn't appear to affect it.
Solution 2:
The amount of time you will keep the mediation going is random except that you can't hit your keyboard or try to do anything with your Glitch while meditating. You can look through your bags and organize things though, just don't try to chop, make anything, or harvest anything while meditating or you will lose it. Gaining meditation skills will increase your ability to meditate (minute plus even), and allow you to focus meditating on increasing mood or energy, as well as 'levitating', which lets you jump higher and better for a little while. Imagined Levitation is the only kind of mediation that you actually should be trying to move your Glitch for.