How does Opus differ from MP3 when comparing both in relation to the file size and quality. For example if I were to convert a 320kbps or 128kbps file that is 10MB or 4MB in mp3 format to opus, what will I get?
Opus is a much newer, state of the art technology than MP3. Any time you encode audio into MP3 or Opus, you never get a perfect, exact copy of the original file. There is always some distortion added and some things missing. This is by their design. They are not meant to perfectly preserve all of the information, they are meant to make small files. To answer your question, you would get a file that has all of the distortion as the MP3 did, plus whatever distortion Opus encoding added on top of that. This article is very relevant. You're getting further and further from the original each time.
Assuming your ripping from lossless source to Opus/MP3, Opus is definitely superior sound quality as this is shown in listening tests from Hydrogenaudio website.
as a general rule... Opus/AAC(standard AAC-LC)/Vorbis(.ogg) etc are superior to MP3 in terms of sound quality simply because they need less bit rate to achieve a certain standard of audio quality. MP3's only real advantage is it's the most commonly used lossy format so it has the most hardware support.
or another thing I can say is this... Opus or AAC @ 96kbps is superior to MP3 @ V5 (130kbps) etc.
in my opinion here are some good general minimum guidelines for use with the following lossy encoders...
Opus = 64kbps or 96kbps
AAC = 96kbps (Apple or FhG(Winamp) encoders using Foobar2000 for conversion)
MP3 (LAME v3.100) = V5 (130kbps average)
or another way to put it... most people would struggle to notice a difference between the lossless source file and a Opus file @ 96kbps. basically if your using lossy audio, Opus would be the lossy format of choice if ones device can use Opus. even perfectionist types who are really picky with sound quality, won't need more than 192kbps TOPS with Opus given it scored perfectly by user IgorC in a Oct 2020 listening test over on the Hydrogenaudio website.
but when using Opus, if a person has any concern for storage space, 64kbps is definitely a viable option since sound quality will still be easily 'good enough' overall and it will allow a person to store plenty of songs with minimal storage space used up.
one can test these things by doing a ABX test (using Foobar2000 with ABX plugin) by comparing their original lossless file (i.e. WAV/FLAC etc) to the lossy file they created. this removes any bias someone may have and proves whether they can hear a difference or not since many assume lower bit rate audio is crap, which is simply not true. even MP3 (LAME v3.100) @ V5 (130kbps average) will easily be good enough for most people even though one can ABX it (I can the last I checked), it's not likely I would notice the difference at all in sound quality when just sitting back and listening to the music to enjoy it. but if one wants to play it a bit safer with MP3 on sound quality, I suggest using V2 (190kbps). even by Hydrogenaudio's LAME recommendations for MP3, 'high quality' starts @ V3 (175kbps).
I think 320kbps CBR on MP3 is pretty much pointless to use as it's a very inefficient use of bit rate as even for the paranoid users of sound quality you won't need to use any higher than V0 (245kbps average) TOPS which is the highest quality VBR mode of LAME encoder as it's basically the same as 320kbps but gives more efficient use of bit rate/storage space. although I am more of the mindset that V2 (190kbps) is probably the sweet spot of sound quality/file size (for MP3) for the more picky types of listeners in terms of sound quality. although, like I was saying, many people will be happy with MP3 @ V5 (130kbps average) even though, on the side of caution with sound quality, it would not hurt to use a higher bitrate especially in today's world were storage space is no longer at a premium price.
Opuse bitrates and qualities can be compared in real-time. 96 kbit seems to be an excellent size/quality ratio: https://opus-bitrates.anthum.com/