Sir Paul McCartney replaced Keith Richards in 'Pirates of the Caribbean: Dead Men Tell No Tales'.

Keith plays the father of the pirate Captain Jack Sparrow in the movie franchise but when scheduling issues meant he couldn't fly to Australia to film a cameo in the latest film, the filmmakers decided to have Paul play Sparrow's Uncle Jack instead.

Directors Joachim Ronning and Espen Sandberg told Entertainment Weekly: ''We had even written a scene for Keith. And then because of some scheduling issues, he couldn't come to Australia to shoot, so we sat down with Johnny and kind of brainstormed, like, 'Okay, who could fill his shoes?' Because we felt like we should have something. We should honour the tradition of showing a Jack Sparrow family member. And we made a very short list, and of course, at the very top of that list was Sir Paul McCartney.''

And Johnny, 53, managed to get the 74-year-old Beatles legend involved in the project by simply texting him.

Ronning said: ''I don't know what kind of club these people are a member of, but he had the phone number.''

And fans of Paul will be delighted to hear that he even sings in the film, performing a sea shanty in one memorable scene.

Ronning added: ''The scene starts with him singing a song, and at the very end of the day, we needed to do a wild take to just record him singing. Nobody else is working on the set so on the soundstage, it's completely quiet, and we're only rolling sound. So I'm sitting there behind the monitors, listening in with earphones and basically recording Paul McCartney. That was a big, big moment.''