Can't you use a setting that won't be transcoded by YouTube? That will always be the best option.By "lossless" do you mean "perceptually transparent"?Lossless = impossible with the format you are choosing.Perceptually transparent? is something only you can answer.
I am not sure that is possible, but try to upload a format that YouTube supports so that YouTube won't transcode it.It seems like MP3 is out of the question when looking at the table at: http://en.wikipedia.org/wiki/YouTubeThere are no open source AAC encoders that can make an acceptable sounding file unless the bitrate is extremely high. OGG Vorbis might be the best option, but you will have to mux the Vorbis stream into a WebM container before uploading I think.
Well, with my own tests of Vorbis, I got transparency at about -q 4 or -q 5. But that's going directly from lossless to Vorbis. When you upload stuff to YouTube, you're not in control of the entire signal chain, and it goes through an extra transcoding step. Lossless -> Vorbis -> AAC (or whatever YouTube uses). So even though Vorbis by itself is probably transparent at -q 4, it wouldn't hurt to keep using -q 7 or even -q 10 to give yourself a little extra headroom for the transcoding YouTube does.Now the best thing to do, quality-wise, would be to use FLAC (assuming YouTube supports FLAC uploads). Once the video gets to YouTube, how they encode it is out of your hands. So really the only thing you can do to maximize quality is to feed YouTube the highest possible quality to work with - which means lossless. It might take a few extra minutes to upload a video, but I'd say its worth it.It actually won't make the overall A/V stream much larger. I'm not sure what kind of bit rates you're using on your videos but it's likely to be several megabits... lets say 3,500 kb/s. Going from high-bitrate Vorbis to FLAC is only going to add an extra ~400 kb/s on top of that... something like an 11% increase. You only need to upload once, so just take the extra couple minutes of upload time, if you want maximal audio quality.