It depends. Some container formats (notably
.mkv, but there are others) allow you to embed subtitles as text files/subtitle streams, but that is not a guarantee that one particular video has done so. You try playing the video in VLC media player, you can see embedded subtitle streams under
The other commonly used method is to write the subtitles into the video stream itself, which is usually an irreversible operation unless you want to manually transcribe them.
Then, once you have verified that the container has a separate subtitle stream, you can extract it. The method is specific to the container format and there are many guides and tools available online for such a purpose; a quick search on Super User itself has revealed guides for OSX here.