Page 1 of 1

TS duration is always 0 if use libvlc_new_media_callbacks

Posted: 14 Apr 2021 12:59
by someusername
Hi! I would like to know if this is a bug or by design.
libvlc_new_media_callbacks:
TS duration - 0 (why?)
mp4 duration - perfectly
mkv duration - perfectly
avi duration - perfectly

libvlc_media_new_path, libvlc_media_new_fd:
TS duration - perfectly
mp4 duration - perfectly
mkv duration - perfectly
avi duration - perfectly

I only use libvlc_new_media_callbacks for local files.

Re: TS duration is always 0 if use libvlc_new_media_callbacks

Posted: 14 Apr 2021 16:36
by RĂ©mi Denis-Courmont
TS duration is just a rough estimate from file size. Using callbacks, the file size is unknown.

Re: TS duration is always 0 if use libvlc_new_media_callbacks

Posted: 14 Apr 2021 21:27
by someusername
TS duration is just a rough estimate from file size. Using callbacks, the file size is unknown.
but

Code: Select all

libvlc_media_t* libvlc_media_new_callbacks ( libvlc_instance_t * instance, libvlc_media_open_cb open_cb, //<-- libvlc_media_read_cb read_cb, libvlc_media_seek_cb seek_cb, libvlc_media_close_cb close_cb, void * opaque )
libvlc_media_open_cb
int(* libvlc_media_open_cb) (void *opaque, void **datap, uint64_t *sizep)
sizep byte length of the bitstream or UINT64_MAX if unknown [OUT]

the file size is known. I assign it to the *sizep argument

Re: TS duration is always 0 if use libvlc_new_media_callbacks

Posted: 15 Apr 2021 10:37
by InTheWings
TS need to read some data from start and from end. There's no stored information like MP4 or MKV.
Unsure if the callbacks can provide that.

Re: TS duration is always 0 if use libvlc_new_media_callbacks

Posted: 16 Apr 2021 01:20
by someusername
TS need to read some data from start and from end. There's no stored information like MP4 or MKV.
Yes, that is right. In my implementation, libvlc_new_media_callbacks has direct access to the file and should also find the duration quickly as if I were opening the file using the path.
I tried to find the code where this condition (pseudocode: IF file is mpeg-ts and used libvlc_new_media_callbacks THEN duration = 0) is, but with no success so far.