So codecs compress and decompress videos, right?
COmpress DECompress. Yep. Just like with text encoding, e.g. ascii or unicode, but with video you take a raster (grid of pixels) and turn that into a stream of data. Often the goal is to make the size of the data as small as possible, though sometimes it's to make sure that the pixels that are reconstructed when the file is read are exactly the same as the pixels that went in, or a combination of the two.
The decompressing happens on the client side in the media player. But where does the compressing happen?
Is it also in the media player?
Or can it be specified in the asx file?
Or does the video file pick which codec it uses to compress and decompress.
The decompression takes place in the client, beit the browser or a media player or a plugin. The compression happens once, when you compress the video, i.e when you make the mp4, mkv etc files.
The different file types are indeed different containers, and containers can contain streams encoded in different codecs. Take an mp4 file. The video will usually be encoded in h.264 while the audio is probably aac, and there might be a subtitle stream encoded as movtext. Often container formats have the capability to hold many different codecs. The quicktime (mov) container is compatible with dozens of codecs, as is mkv.
Once a file is compressed using a certain codec you will need something that can read that codec to play it. The details of what the codec is, as well as the parameters that tell the player how to decode it are in the container. So the player will also have to know how to read the container.
The .asx file will just point to the stream, it's up to the player to decode it.
Can I chose which codec to use?
I know there are better codecs for certain situations than others. Can someone explain that?
Yes, different codecs are useful for different things. If you're streaming video you'll want good quality but for the smallest possible bitrates. Often that means using a lossy compression - one where the compressed video has lost quality compared to the uncompressed original. The trick is to lose the quality in a way that it's less obvious to humans. h.264 is probably the right tool for the job, unless the patent restrictions or licensing costs are an issue.
However, if I'm rendering an intermediate file in my post production chain I want high bit depth and lossless or minimally lossy quality. I might go for lossless 12-bit 4:4:4, or compromise and use a codec like cineform or proRes, depending on my OS. While they maintain quality and dynamic range, they'd be awful codecs for streaming, lossless 12 bit 4:4:4:4 has ~2500 MB/s data rate. Other codecs are a compromise between file size and quality, others work really well at ultra-low bitrates or require less CPU, others are good because they are unencumbered by patents or licensing.
I've seen a couple of my videos using LAV to decompress while some use H264/5 (can't remember which).
LAV is a software library which is used by compression and decompression software. It is capable of reading and writing many codecs. H.264/5 are codecs.
As for the streaming side, is there a way to say: if the network speed is slow, change the video from 1080p to 480p?
yes, I think so - youtube does it, but out of my field of expertise, and probably a better question for Superuser.
Are there certain settings that I should be aware of in either of my media players to help with buffering, streaming, codecs, etc?
Not really, it's the compression side of things that you want to optimise. You need to be aware of your client's capabilities and encode with that in mind.
Just saw in the tags at the bottom that there is a codec and transcoding. Is there a difference? Does a codec specify how transcoding happens? I realize these are a lot of questions, but if someone has answers to any of them, please let me know. Again, I'm just trying to learn
Transcoding is converting from one codec to another. So say I've mastered to one of my lossless 12-bit codecs. I've now got a video file that runs into hundreds of gigs. I might want to make a copy for the internets, so I fire up my transcoding app and tell it to take the master and compress it to an mp4 file, which will take up a fraction of the space.