Image copyright Lil Dicky Image caption The video features cameos from 30 celebrity musicians

An all-star animated environmental music video featuring the voices of Justin Bieber, Ed Sheeran and Ariana Grande has gone viral on social media.

The song Earth, by comedian and rapper Lil Dicky, also has cameos from Katy Perry, Snoop Dogg and Miley Cyrus.

Speaking to Time, Dicky - aka David Burd - said: "What started as a silly joke of an idea along the way became the most important thing I'll ever do."

A share of proceeds will go to the Leonardo DiCaprio Foundation.

DiCaprio, who campaigns on environmental issues, also makes an animated appearance towards the end of the seven-minute long video.

In Earth has had more than 2.5 million views on YouTube since going live early on Friday.

Burd and his celebrity friends including Halsey, Snoop Dogg and Rita Ora urge people to fight against climate change.

Hey, I'm a zebra / No one knows what I do, but I look pretty cool / Am I white or black? sings Ariana while Ed Sheeran, voicing an animated marsupial, adds: I'm a koala and I sleep all the time / So what? It's cute / How did you wrangle all of these superstars to be on the song?

Image copyright Tim Mosenfelder Image caption Burd is a musician and comedian

"It was me, my manager Scooter Braun [who also represents Bieber and Grande] and Benny Blanco, who is a true producer in every sense of the world," said Burd. "We're all such competitive people that we all kept tabs on who got who.

"We all had our own relationships, and together, in a three-pronged attack, we got 30 artists.

Burd admits he did have an issue trying to land one famous voice, belonging to mercurial rapper and producer Kanye West.

Image copyright Kevin Geoghegan Image caption A share of proceeds will go to Leonardo DiCaprio's environmental charity

"I'm friendly with Kanye - I used to play basketball with him," he said.

"But I left myself like three days to get Kanye on the phone and couldn't get in touch with him. He was pretty unreachable; he changed his email and his cell phone.

"So I reached out to Kevin Hart and asked, "Would you play Kanye?" and he said 'yes'."