Skip to main content

Topic: Dumped opus streams have incorrect "Durations". (Read 5954 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • bat_guano
  • [*]
Dumped opus streams have incorrect "Durations".
Hi
I've tried dumping some opus streams to file, but the results are strange. 
Dumped files have incorrect "Durations".
This makes confusion when the files are played with VLC or SMPlayer etc.

What causes opus streams to create files with incorrect "Durations"?
And how can I fix it?

For example, a 30 second sample:-
Code: [Select]
timeout 30 ffmpeg -y -i http://radioserver1.delfa.net/64.opus -c copy SmoothJazz1.opus


MediaInfo shows incorrect Duration 4mn 17s.

Quote
General
Complete name                            : SmoothJazz1.opus
Format                                  : OGG
File size                                : 258 KiB
Duration                                : 4mn 17s
Overall bit rate                        : 8 227 bps
Writing application                      : Lavf54.61.102

Audio
ID                                      : 36710742 (0x2302956)
Format                                  : Opus
Duration                                : 4mn 17s
Channel(s)                              : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Compression mode                        : Lossy
Writing library                          : Lavf54.61.102



Similar results using MPlayer

Code: [Select]
rm -f fifo && mkfifo fifo; \
timeout 30 \
mplayer -nocache -noconsolecontrols -dumpstream -dumpfile fifo \
"http://radioserver1.delfa.net/64.opus" -demuxer lavf \
& ffmpeg -y -i fifo -c copy SmoothJazz2.opus \
&& rm -f fifo


MediaInfo shows incorrect Duration 2mn 18s.

Quote
General
Complete name                            : SmoothJazz2.opus
Format                                  : OGG
File size                                : 254 KiB
Duration                                : 2mn 18s
Overall bit rate                        : 15.0 Kbps
Writing application                      : Lavf54.61.102

Audio
ID                                      : 2098600889 (0x7D161BB9)
Format                                  : Opus
Duration                                : 2mn 18s
Channel(s)                              : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Compression mode                        : Lossy
Writing library                          : Lavf54.61.102
  • Last Edit: 24 January, 2013, 05:32:12 PM by bat_guano

  • Dynamic
  • [*][*][*][*][*]
Dumped opus streams have incorrect "Durations".
Reply #1
These sound like raw streams, not Ogg-encapsulated Opus files. Raw streams will be of unknown length, so most tools, unless they walk through the file in full will make some kind of guess of duration based on initial bitrate and file size, for example. Have you tried opusinfo from the official libopus?

Very nice sounding Opus stream, by the way.
Dynamic – the artist formerly known as DickD

  • bat_guano
  • [*]
Dumped opus streams have incorrect "Durations".
Reply #2
... Raw streams will be of unknown length, so most tools, unless they walk through the file in full will make some kind of guess of duration...

Yes, similar incorrect duration when treating stream as "raw":-
Code: [Select]
timeout 30 \
mplayer -nocache -dumpstream -dumpfile SmoothJazz3.opus \
"http://radioserver1.delfa.net/64.opus"


(Though we don't have incorrect duration when we dump "raw" mp3 streams) 

So maybe it is necessary to dump the raw opus stream to file then mux it into ogg without "guessing" the duration.
Which mux software will do this with accurate duration?
  • Last Edit: 25 January, 2013, 05:29:36 AM by bat_guano

  • 2012
  • [*][*][*]
Dumped opus streams have incorrect "Durations".
Reply #3
1st of all, those are Ogg-encapsulated Opus files.

Generally speaking, life streams are implemented in a way that clients can connect at arbitrary offsets.

In this case, the duration you see is correct! It's just the stream does not start from 0!

You can see that instantly if you play the saved file in mplayer, or if you run opusinfo:

Code: [Select]
WARNING: sequence number gap in stream 1. Got page 257 when expecting page 2. Indicates missing data. (normal for live streams)
WARNING: discontinuity in stream (1)
WARNING: EOS not set on stream 1 (normal for live streams)
saldl: A lightweight well-featured CLI downloader optimized for speed and early preview.
https://saldl.github.io

  • bat_guano
  • [*]
Dumped opus streams have incorrect "Durations".
Reply #4
In this case, the duration you see is correct! It's just the stream does not start from 0!

OK, thanks for explanation. 
I can see message in MPlayer "Could not update timestamps for skipped samples"

And opusinfo shows "Playback length: 0m:32.992s" (which is near enough 30 seconds).

And this message explains why SMPlayer plays with slider not at start position:-
"WARNING: sequence number gap in stream 1. Got page 215 when expecting page 2. Indicates missing data."

But is there a method to clean up the offset/timestamps so that the files do start at 0 and behave well with SMPlayer etc? 

Quote
@ubuntu:~$ mplayer SmoothJazz3.opus
MPlayer SVN-r35829-4.5.2 © 2000-2013 MPlayer Team

Playing SmoothJazz3.opus.
libavformat version 54.61.103 (internal)
libavformat file format detected.
[lavf] stream 0: audio (libopus), -aid 0, Bring It!
Load subtitles in ./
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 54.90.100 (internal)
[libopus @ 0x8d2fb80]Could not update timestamps for skipped samples.
AUDIO: 48000 Hz, 2 ch, s16le, 0.0 kbit/0.00% (ratio: 0->192000)
Selected audio codec: [fflibopus] afm: ffmpeg (FFmpeg libopus)
==========================================================================
AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 235.7 (03:55.6) of 246.0 (04:06.0)  1.9%


Quote
@ubuntu:~$ opusinfo SmoothJazz3.opus
Processing file "SmoothJazz3.opus"...

New logical stream (#1, serial: 183abf41): type opus
Encoded with libopus 1.0.2
User comments section follows...
   ENCODER=scripts
   TITLE=Bring It!
   TRACKNUMBER=6
   TRACKTOTAL=10
   GENRE=Smooth Jazz
   DATE=2011
   COMMENT=From RAW PCM to opus
   ARTIST=Richard Elliot
   ALBUM=In The Zone
WARNING: sequence number gap in stream 1. Got page 215 when expecting page 2. Indicates missing data. (normal for live streams)
WARNING: discontinuity in stream (1)
WARNING: EOS not set on stream 1 (normal for live streams)
Opus stream 1:
   Pre-skip: 356
   Playback gain: 0 dB
   Channels: 2
   Original sample rate: 44100Hz
   Packet duration:  20.0ms (max),  20.0ms (avg),  20.0ms (min)
   Page duration:  1000.0ms (max), 1000.0ms (avg), 1000.0ms (min)
   Total data length: 257706 bytes (overhead: 1.1%)
   Playback length: 0m:32.992s
   Average bitrate: 62.49 kb/s, w/o overhead: 61.8 kb/s



  • bat_guano
  • [*]
Dumped opus streams have incorrect "Durations".
Reply #5
But is there a method to clean up the offset/timestamps so that the files do start at 0 and behave well with SMPlayer etc?

Bump

  • NullC
  • [*][*][*]
  • Developer
Dumped opus streams have incorrect "Durations".
Reply #6
In this case, the duration you see is correct! It's just the stream does not start from 0!


I don't think thats correct— unless there is some special mplayer convention it should be reporting the real duration of the provided file.  There is no requirement that the times start at zero in a stream— I could, if I wanted, make opusenc choose random start times and I wouldn't expect it to break anything.


  • bat_guano
  • [*]
Dumped opus streams have incorrect "Durations".
Reply #7
Hi
I've just tried this command again with a newer version of FFmpeg:-
Code: [Select]
ffmpeg -y -i http://radioserver1.delfa.net/64.opus -t 30 -c copy SmoothJazz1.ogg


ffmpeg version git-2013-05-10-b2cf655 Copyright © 2000-2013 the FFmpeg developers built on May 10 2013 22:14:21

Now ....

SMPlayer plays the file OK - and it is seekable. 

And mediainfo shows the correct duration. 

Maybe there has been a change to FFmpeg to fix this problem. 

Quote
@ubuntu:~$ mediainfo SmoothJazz1.ogg
General
Complete name      : SmoothJazz1.ogg
Format              : OGG
File size          : 234 KiB
Duration            : 30s 13ms
Overall bit rate    : 63.9 Kbps
Writing application : Lavf55.4.101

Audio
ID                  : 507024822 (0x1E3895B6)
Format              : Opus
Duration            : 30s 13ms
Channel(s)          : 2 channels
Channel positions  : Front: L R
Sampling rate      : 44.1 KHz
Compression mode    : Lossy
Writing library    : Lavf55.4.101
  • Last Edit: 13 May, 2013, 08:32:12 PM by bat_guano