Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opus file duration cannot be calculated #26

Open
msalikhov opened this issue Apr 12, 2018 · 14 comments
Open

Opus file duration cannot be calculated #26

msalikhov opened this issue Apr 12, 2018 · 14 comments

Comments

@msalikhov
Copy link
Contributor

So the created opus file duration cannot be determined by players. Probably because of granule position which is used for this by specs

@andrm
Copy link

andrm commented Apr 20, 2018

Please give more information. VorbisJava can't produce Opus file by itself, it can "transcode" them. I have used it quite a bit for that and did write some of the code for it. Can you use the opusinfo command from opus-tools on the bad file and give us the output of it?

@msalikhov
Copy link
Contributor Author

msalikhov commented May 7, 2018

i have created OpusFile like that:

    val tf = File.createTempFile("test", ".opus")

    val ot = OpusTags()

    val oi = OpusInfo()

    oi.setSampleRate(48000)

    oi.numChannels = 1

    oi.preSkip = 3840

    val of = OpusFile(tf.outputStream(), oi, ot)

than writting opus packets 20ms length:
of.writeAudioData(OpusAudioData(packet))
after that closing file:
of.close()

and OpusInfoTool gives the following output:
Opus Headers:
Version: 1
Channels: 1
Rate: 48000Hz
Pre-Skip: 3840
Playback Gain: 0dB
User Comments:
Logical stream 19fb (6651) completed
Opus Audio:
Total Data Packets: 217
Total Data Length: 35745
Audio Length Seconds: 0.0
Audio Length: 00:00:00.00
Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min)
Page duration: 4340.0ms (max), 0.0ms (avg), 4340.0ms (min)
Total data length: 35745 (overhead: 0.81%)
Playback length: 00:00:00.00
Average bitrate: Infinity mb/s, w/o overhead: Infinity mb/s

@andrm
Copy link

andrm commented May 7, 2018

Thanks. The packets are not parsable it seems. Can you also try the opusinfo command from the native opus-tools from xiph? What is the output here?

@msalikhov
Copy link
Contributor Author

so the problem were in granule position, i'll try to make pr later

@sepehr1014
Copy link

Any updates on this?

@msalikhov
Copy link
Contributor Author

#31

@sepehr1014
Copy link

@msalikhov Thanks, that did the trick.

@sepehr1014
Copy link

The duration is rounded to seconds. It'd be great if it had precision down to milliseconds.

@Gagravarr
Copy link
Owner

I've merged the code from #31, with a few tweaks, so hopefully that'll work as standard. Thanks to @msalikhov for the help with this!

@sepehr1014 How are you getting the duration that's rounded, so I can see if we can fix it / the info you need is already available elsewhere?

@sepehr1014
Copy link

sepehr1014 commented Sep 7, 2018

@Gagravarr I was referring to duration tag in file metadata. Record an audio with OPUS codec and save it using OGG container. The duration tag of the OGG file is set to 4 instead of 3.251 for instance.

@Gagravarr
Copy link
Owner

I've just added a unit test TestOpusStatistics#testReadWriteReadInfo which shows we're able to correctly read the duration, including partial seconds, after loading a file + saving it to a new one + reading again.

How are you doing your reading of the duration where you are finding it truncated?

@sepehr1014
Copy link

cc @Sdghasemi

@mozzbozz
Copy link

mozzbozz commented Apr 2, 2019

Pull request which fixes a bug introduced in one of the commits related to this bug report: #33

@sebma
Copy link

sebma commented Nov 1, 2021

@Gagravarr Android-Audio-Recorder is using Gagravarr.org Java Vorbis Tools v0.8 20160217.

Can you please merge mozbozz PR #33 and do a v0.9 release tag so that the bug may also be fixed in applications using Gagravarr.org Java Vorbis Tools (such as Android-Audio-Recorder) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants