In 19 out of 24 states for which data was available in 2015, African American motorists were more likely to be stopped by police than white drivers – three times more likely in some places. When they were pulled over, black travelers were more likely to suffer abuse in the form of taunts, harassment by dogs, gratuitous searches and more, the ACLU has documented.

Just last year, the NAACP issued a travel advisory for the entire state of Missouri, calling on African American visitors to the state and residents to “pay special attention and exercise extreme caution” owing to racist incidents. The group issued a separate advisory for American Airlines, later lifted.

The NAACP had received reports from travelers of racist verbal and physical attacks, its director of communications, Malik Russell, told the Guardian – “all type of encounters where people get the sense that they’re not being valued as an individual, as a person, as a customer.

“These advisories are examples of the distance between our nation and true freedom, true democracy.”

It used to be even worse. Beginning in the 1930s, highway travel by African Americans, like all Americans, increased – but black families had to plan for their trips in a way white families did not, by packing extra food and gasoline, and by plotting a course through relatively friendly territory. Helping them do so were specialty guidebooks listing roadside hotels, restaurants and gas stations that accommodated black travelers, the best-known of which was called The Negro Motorist Green-Book, after its compiler and publisher, the Harlem-based postal employee Victor H Green.

The Green Book (23 digitized editions are here) has been the subject of cultural fascination for years. But it is about to hit the mainstream, with a feelgood, Oscar-tipped movie that appears on its way to being a holiday smash.

Green Book, starring Viggo Mortensen and Mahershala Ali, tells the story of an unlikely friendship between an Italian American driver and an African American pianist on a concert tour from New York through the deep south in 1962, one year after the Freedom Riders. They carry a Green Book in an attempt (spoiler alert: ill-fated) to stay out of trouble.

The story is based on a tour the virtuoso Don Shirley, born in Florida to Jamaican parents, undertook with a Bronx native called Tony Lip at the wheel. As family legend had it, Lip began the trip with prejudices incubated in the Italian American streets of his youth that he found scrambled when confronted by Doctor Shirley, as he was known.

The real-life characters upon which the film characters are based were extraordinary. Shirley debuted playing Tchaikovsky at age 18 with the Boston Pops in Chicago but was diverted from a classical career, he told his family and friends, by the impresario Sol Hurok, who advised him that “colored” performers had to work elsewhere. (Hurok’s influence was such that he died between lunch with Andrés Segovia and a meeting with David Rockefeller.)

Shirley’s career in classical, jazz and popular music included appearances on the world’s biggest stages, a collaboration with Duke Ellington, a turn playing Gershwin at the Metropolitan Opera in New York accompanied by the Alvin Ailey company, a Billboard Top 40 hit (Water Boy, 1961) and, later, a symphonic tone poem based on Finnegans Wake. He lived in a resplendent apartment above Carnegie Hall until his death in 2013. “His virtuosity is worthy of the gods,” Igor Stravinsky said.

Tony Lip, left, and Don Shirley. Composite: WireImage/Getty Images

Lip, born Frank Vallelonga, was a minor-league baseball player and soldier in postwar Germany who became a manager at Manhattan’s Copacabana club, where he later (post-road-trip) met Francis Ford Coppola, landed a bit part in The Godfather and parlayed his connections into an acting career that culminated with The Sopranos, in which he played the mobster Carmine Lupertazzi. He also died in 2013.

Lip’s son, Nick Vallelonga, co-wrote the Green Book script based on stories he grew up hearing from his father about the trip, which he tape-recorded, and on interviews with Shirley himself, because by then Lip and Shirley were friends. After the events depicted in the movie, in fact, the pair kept traveling together, Vallelonga told an audience in Toronto. “They went on for another year together and went to Canada too,” he said.

“My father’s a character, you can’t make him up, everything in there you saw was true,” Vallelonga said. “A lot of the words were right from his mouth when he was telling the story from when I taped him, a lot of the dialogue was right from there.”

The movie, directed by Peter Farrelly – he of seminal social critiques Dumb and Dumber and There’s Something about Mary – at one point places the heroes in a so-called sundown town, where no African American was allowed after dark, by custom or ordinance enforceable by you-don’t-want-to-find-out.

Mahershala Ali in Green Book. Photograph: Universal Pictures/AP

“Most often there was no formal ordinance,” said James Loewen, a sociologist and author of Sundown Towns: A hidden dimension of American racism. “Most often there was no posted sign. But in many, many cases there was a sign, and in at least some cases there was an ordinance, or people thought there was an ordinance. And if you think there’s an ordinance, then there is, to all intents and purposes.”

One historical inaccuracy in Green Book may be that it sends its pair through Pennsylvania and Indiana and into the deep south before they encounter such a place, when in fact Indiana was replete with sundown towns, Loewen said, and “Pennsylvania had maybe 700 sundown towns, maybe taking the prize for the most anywhere. It has whole river valleys that were all sundown towns.”

“We still have a long way to go,” said Russell, of the NAACP. “While we’ve traveled that distance from enslavement and Jim Crow to what people have desired as an equal playing field, there still is that distance to travel to eliminate the vestiges of racism and oppression in this country towards people of color.”

The movie presents Shirley as an activist by his decision to tour the south, and Shirley himself described his efforts to capture “the black experience”.

‘‘I am not an entertainer,” Shirley told the New York Times in 1982. “But I’m running the risk of being considered an entertainer by going into a nightclub because that’s what they have in there. I don’t want anybody to know me well enough to slap me on the back and say ‘Hey, baby.’ The black experience through music, with a sense of dignity, that’s all I have ever tried to do.’’

But critical acclaim could be elusive. In 1986 the music critic Jon Pareles dismissed a Shirley concert at Carnegie Hall as “a harmless exercise in pretty, pompous, pseudoclassical mood music”.

Today – before the movie, at least – Shirley’s fame is in eclipse. “There really hasn’t been any particular fan club,” said Nathan Kramer, who maintains a Shirley tribute site. “It’s just been a couple oddballs like us who just wanted to share things with our friends.”

Kramer saw Shirley play at a 1985 concert in Blair, Nebraska, and later corresponded with him. There was “an element of flamboyance” in Shirley’s performances, Kramer said.

Viggo Mortensen and Mahershala Ali in Green Book. Photograph: Universal Pictures/AP

“There was one time at the concert where he started the piece off – he sat way, way back from the piano. And he held up one finger. It was almost like a mime. The audience saw this one finger. And he put this one finger kind of dramatically down on the keyboard, and we listened to that one note.

“And then he built a second note. Then brought his left arm up and hit a third note, and developed this chord. And this chord turned into a little fugue. And then all of a sudden, he kept on going – and it was just like this flywheel going around and around, and somewhere in this process you realized that we were listening to Gershwin.”

Ali presents Shirley with physical flair, and the screenwriters put Shirley’s words verbatim in Ali’s mouth, including a riff about jazz piano players demeaning themselves.

They “smoke while they’re playing, and they’ll put the glass of whisky on the piano, and then they’ll get mad when they’re not respected like Arthur Rubinstein”, Ali-as-Shirley says, verbatim from a 1982 interview.

“You don’t see Arthur Rubinstein smoking and putting a glass on the piano.”