I've considered a Brazilian TL that sees the Empire last longer. A big part of what ended the Empire was Pedro II losing interest in his rule. Although that happened after abolition, the end of slavery saw the landowning class become quite alienated, while the War of the Triple Alliance alienated the officer class.
So I suggest, Pedro's son survives from 1848, this makes him more confident in his Imperial legacy, this makes him more confident in fighting slavery. Combine that with a tenser crisis over the Aberdeen Act (Britain clamping down on the slave trade), say Pedro pushes through abolition shortly after the American Civil War.
Pedro is still liked by the mostly liberal officer class, and have a live male heir to encourage his generally high popular support. The slave-owners decide to lash out and attempt a coup. Rather than a ACW analogue, it would be a Spanish Civil War analogue - a failed coup leads to growing upheaval, say the rebels are able to muster the support of various local figures and militias, leading to full blown war. Say the Confederados, who IOTL ended up joining the Brazilian slavers effectively become mercenaries, brining over more ACW veterans.
Eventually the government troops win, Pedro confirms abolition and wides off into a sunset made of benign industrialisation and parliamentary democracy.