in_opus icon indicating copy to clipboard operation
in_opus copied to clipboard

opus streams embedded into mp4 containers support

Open byblo opened this issue 2 years ago • 10 comments

Please support opus streams embedded into mp4 containers like in this sample:

https://www49.zippyshare.com/v/VP3KEjwX/file.html (opus_stream_in_mp4_container.zip)

byblo avatar Nov 18 '22 13:11 byblo

Would be nice indeed, Unfortunately it would require a lot of work because in_opus is based on the libopusfile library that can only handle ogg container.

For now when I encounter such files I use ffmpeg to fix it:

ffmpeg -i opusfileinMP4.mp4 -acodec copy opusfile_in_OGG.opus

With the latest version of ffmpeg even tags get converted properly so this is what I use. It is perfectly lossless as well.

If I get more time for this project I might support more containers in the future.

RamonUnch avatar Nov 18 '22 14:11 RamonUnch

That would be nice.

I save some opus alone into mp4 container since it is allowing to keep both thumbnail and chapters time positions+chapters titles from youtube videos for instance.

I did not tried ogg container yet, will try ASAP. (edit: does not work with ogg or ogm containers)

byblo avatar Nov 18 '22 14:11 byblo

.opus files are ogg containing opus stream so it must work. The proper way to name those files is .opus even though the container is .ogg Y=The rason is that .ogg files are assumed to be ogg/vorbis files instead of ogg/opus files.

Use the above command line and it should work as long as the extension is .opus If for some reason you want to use the .ogg extension for your ogg/opus files, there is a dirty hack that you can enable in the .ini file (have a look at the in_opus.txt for more details.

RamonUnch avatar Nov 20 '22 09:11 RamonUnch

Keep in mind that for a Winamp plugin the file filter is only based on file extension so if the extension is not .opus, Winamp will not even try to call the in_opus.dll plugin.

RamonUnch avatar Nov 20 '22 09:11 RamonUnch

The problem is the thumnail PNG seems to be lost at the conversion mp4 to opus. Is there a way to preserve it?

byblo avatar Nov 20 '22 10:11 byblo

Try to add -map 0 so that all channels are kept.

RamonUnch avatar Nov 20 '22 10:11 RamonUnch

-map 0 seems to convert the thumbail from png to video stream, which makes it hard to read on some player like MPV Same for -c:v libtheora -q:v 10

It seems that there is a fix available for ffmpeg to force it to keep the png format but no idea how to compile it: https://trac.ffmpeg.org/ticket/4448#comment:6

byblo avatar Nov 20 '22 10:11 byblo

more info about this:

https://stackoverflow.com/questions/64561570/ffmpeg-convert-audio-to-ogg-and-keep-album-cover https://trac.ffmpeg.org/ticket/4448

Actually try with:

~~ffmpeg -i input.mp4 -acodec copy -vcodec libtheora output.opus~~

EDIT:

ffmpeg -i input.mp4 -map 0 -acodec copy -vcodec libtheora -q:v 10 output.opus

EDIT2: Sorry I hand not seen your latest post

RamonUnch avatar Nov 20 '22 10:11 RamonUnch

Well indeed it is a shame that such a simple matter of embedding a cover image in an ogg stream is not supported. I guess we should look for other encoders.

RamonUnch avatar Nov 20 '22 11:11 RamonUnch

I think I will keep for now the current format of opus into mp4 container and keep playing them with MPV, since it mainly allows me to keep everything into one file while being able to save youtube streams+posted dates using yt-dlp_x86.exe and youtube-dl-FE.exe(a frontend i wrote for the first one)

But thank you for your efforts, having an opus plugin for winamp is great :)

byblo avatar Nov 20 '22 11:11 byblo