Judd Apatow has revealed that HBO refused to allow Lena Dunham to film controversial sex scenes for her hit show “Girls,” which he says may have included a male erection.

Speaking to an audience of university students in Los Angeles, Apatow said, “There have been things on ‘Girls’ where HBO has said to us, ‘If we put this on TV, we literally could lose our licence to broadcast,’” he said.

Asked to elaborate further, Apatow said, “Let’s just say it’s something you see in adult film — elements of sexual intercourse. The high points of sexual intercourse.”

Of dealing with nudity in his past work, Apatow said, “We’ve experimented with the limits of what people can handle. We’ve had a male organ in movies. We found out that 20 seconds of someone naked is probably too much, and people will leave the theater if you have full frontal nudity for an extended period of time. But if you make it five seconds, they’ll laugh and say it was great. So basically that’s the ratio of how much penis people can handle in a movie. Five seconds yes, 20 seconds no. We’re always going too far and then deciding where the line is.”

When asked how long fans could expect “Girls” to run for, Apatow said, “We expect it to run for six seasons. I guess that could change. It’s not set. I think we’re all committed that we’ll do six.”

He added that no ending has worked out, “but we’ve talked about it. It makes you respect the ending of ‘The Sopranos.’ You think about, how do you end a series? The idea that you just stop and leave people there is so genius, it’s such a great idea. It’s such a great way of saying, ‘It doesn’t matter. This is their life and now we’re just going to leave them to it.’”