RamonUnch / in_opus

Winamp 2.x and 5.x input plugin for Opus file
38 stars 0 forks source link

opus streams embedded into mp4 containers support #3

Open byblo opened 1 year ago

byblo commented 1 year ago

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)

RamonUnch commented 1 year ago

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.

byblo commented 1 year ago

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)

RamonUnch commented 1 year ago

.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 commented 1 year ago

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.

byblo commented 1 year ago

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

RamonUnch commented 1 year ago

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

byblo commented 1 year ago

-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

RamonUnch commented 1 year ago

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 commented 1 year ago

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.

byblo commented 1 year ago

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 :)