Camilla Cabello, who played the lead in Amazon Prime's "Cinderella," has revealed she wrote the film's hit song, "Million to One," while going through a rather tough period in her life.

The 24-year-old singer opened up about her struggle during a conversation with Kid Cudi, Anderson Paak and the Sparks Brothers for The Hollywood Reporter's "Songwriter Roundtable."

"When I was working on 'Million to One' for Cinderella, to be totally honest, I was going through a really hard time with my mental health," she said.

The response came when she was asked if she felt "jarring to have to write about something that's not [personal], given how she is known to write about things that are close to her heart."

"I don't think I know how to write in any way that isn't personal to me," she revealed. "It was just a period of a lot of anxiety and sadness for me, and that song had me feeling like, 'I can overcome this. I know that I can make my life better.' I feel like I channeled my personal journey into one of the characters. The character was super confident — everybody was telling her no, but she knew."

The "Senorita" singer had previously opened up about the anxiety and stress she faced while filming the musical — it had to be stopped mid-shoot due to the pandemic.

"Before the pandemic, I felt really burnt out. I had been working pretty nonstop since I was 15. And the rigor with which I started working, there was just no time off," she revealed on Apple Fitness+'s "Time to Walk" last month, PEOPLE reported. "I was barely home. I didn't have time to get to know who I was outside of my career. Pile that onto struggles with mental health, with anxiety, with these toxic levels of stress, it wasn't even a meltdown because I would just work through it."

But when she got back home after the shoot was halted, she "would just break down crying once a day at least."

"I felt so anxious, cripplingly anxious. I just felt really unstable, and I just felt a mess because suddenly, this thing that was distracting me, my work and filming, was not there," Cabello said. "And so I was just left with my anxiety and my mind. And it was getting in the way of my relationship. It was getting in the way of my friendships, my time at home."

Thankfully, the singer realized it was time for her to "shift her priority" and focus on her own wellbeing. And it helped her.

"I definitely asked for help. I asked for time. And I learned a lot of tools," she said. "I tried a lot of different things, different kinds of therapy, meditation, exercise, changing the way I eat, definitely changing the way I schedule my time and making sure that there's balance, that I have time for friendships and connection with people and I'm not just nose to the grindstone, not paying attention to my body and my needs."

Cabello noted that the small changes made a huge difference.

"It gave me the gift of finding new hobbies and other things that soothe me," she added.

camila cabello tour 2018
Camila Cabello, who attended the 60th Annual Grammy Awards at Madison Square Garden on Jan. 28, 2018 in New York City, is going out on tour later this year. Jamie McCarthy/Getty Images