Please see your vet!
Guinea pigs don't suffer from constipation the way humans do as their digestive system is different. They digest what they eat twice; the poos that contain the not yet fully broken down fibre from the first run are eaten again; they are different from the poos that you normally see and are produced at a different time. You can often see piggies picking something up from their genitals - those are caecotrophs, redigested poos.
The pain that is causing the painful pooing usually sitting in the bladder/urinary tract (urinary tract infecton (UTI), bladder stones/sludge or cystitis = inflammation of the bladder walls) or in the reproductive system (ovarian cysts) in sows. It can make poos soft.
The size of the poos depends generally on the food intake 1-2 days ago. Pain is an appetite killer, so you need to always switch from the rgular once weekly weigh-in to weighing daily at the same time in order to monitor the food intake. Unlimited hay is making over 80% of what a piggy eats in a day; you cannot check it by eye. But it is often the first food group that is dropped.
Occasionally a mild tummy upset can cause poos like that, but they are generally not produced with painful squeaking.