Page 1 of 1

Problem with get_position and get_length on transport stream

Posted: 11 Apr 2013 11:24
by slasktrat
Hi

I use vlc as PVR for dumping multicast TV to .ts files. Sometimes i start playback of the recording before the program has ended. In earlier versions of VLC the libvlc_media_player_get_position and libvlc_media_player_get_length would always give me correct result, even as the source file grows. But now (don't know which version of vlc that changed this behaviour) libvlc_media_player_get_length will always return the lenght that the video had when the playback started, and libvlc_media_player_get_position will en up returning a float larger than 1 when passing initial lenght.

Is there a good reason why this no longer works as before? And is there any other way i can get libvlc to give me updated lenght and pos as the source grows?


Thanks

Re: Problem with get_position and get_length on transport stream

Posted: 19 Jun 2016 12:00
by maharg
This is an issue I'll be interested in also.

A thought regarding a possible workaround - it should be possible to approximate the position given the original file size, the current file size, and the mis-reported position.

Re: Problem with get_position and get_length on transport stream

Posted: 20 Jun 2016 10:41
by maharg
I've recreated this using the Python bindings to libvlc as shown below.

The file which is being played back is being captured using multicat, and is growing (confirmed with watch ls -l ....).

Notes:
- The output from VLC is left intact. I didn't create a context for the player so only the audio was rendered, but this was sufficient for the test.

Findings:
- get_position reports positions > 1.0 when playback passes the original duration of the file
- it is NOT possible to set a position > 1.0 - VLC simply plays from position 1.0
- get_length consistently reports the original length of the clip

Code: Select all

$ export VLC_PLUGIN_PATH=/Applications/VLC.app/Contents/MacOS/plugins/ $ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import vlc >>> instance = vlc.Instance() >>> player = instance.media_player_new() >>> media = instance.media_new("file:///Volumes/captures/bbcnew_1_1466406091/407336.ts") >>> player.set_media(media) >>> player.play() 0 >>> [00007fc802f544c8] macosx vout display error: No drawable-nsobject nor vout_window_t found, passing over. [00007fc80389deb8] core video output error: video output creation failed [00007fc8030a62b8] core decoder error: failed to create video output >>> vlc.libvlc_media_player_get_position(player) 0.10156689584255219 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> vlc.libvlc_media_player_get_length(player) 1176666 >>> import time >>> while True: ... vlc.libvlc_media_player_get_position(player) ... time.sleep(1) ... 0.2612680494785309 0.262220561504364 0.2629339098930359 0.26387032866477966 0.26477792859077454 0.26570072770118713 0.2663840651512146 0.26731234788894653 0.2681690752506256 0.268882691860199 0.2698352336883545 0.27076664566993713 0.271470308303833 0.2724232077598572 0.2733567953109741 ^CTraceback (most recent call last): File "<stdin>", line 3, in <module> KeyboardInterrupt >>> vlc.libvlc_media_player_set_position(player, .98) >>> [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 4, expected 13) for PID 0 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 0, expected 9) for PID 500 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 1) for PID 17 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 8, expected 2) for PID 20 >>> >>> while True: ... vlc.libvlc_media_player_get_position(player) ... time.sleep(1) ... 0.9883562326431274 0.9893091917037964 0.9900230169296265 0.9909444451332092 0.9918898940086365 0.9927594661712646 0.9932050704956055 0.9943660497665405 0.9952577352523804 0.9959721565246582 0.9968942999839783 0.9978464245796204 0.9985599517822266 0.999513566493988 1.0004348754882812 1.0011491775512695 1.002070426940918 1.0027828216552734 ^CTraceback (most recent call last): File "<stdin>", line 3, in <module> KeyboardInterrupt >>> vlc.libvlc_media_player_set_position(player, 1.05) >>> [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 8, expected 7) for PID 0 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 4, expected 3) for PID 500 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 14) for PID 17 vlc.while True: ... vlc.libvlc_media_player_get_position(player) ... time.sleep(1)[00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 11) for PID 20 ... 1.0063832998275757 1.0073349475860596 1.0080195665359497 1.0088791847229004 1.0098339319229126 1.0105475187301636 ^[[A^[[A1.0114997625350952 ^CTraceback (most recent call last): File "<stdin>", line 3, in <module> KeyboardInterrupt >>> vlc.libvlc_media_player_set_position(player, 1.4) >>> [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 6, expected 9) for PID 0 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 5) for PID 500 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 8) for PID 17 vlc. KeyboardInterrupt >>> >>> >>> >>> while True: ... vlc.libvlc_media_player_get_position(player)[00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 11) for PID 20 ... time.sleep(1) ... 1.0086743831634521 1.009626030921936 1.0105475187301636 1.0112614631652832 1.0121963024139404 1.0128976106643677 1.013848900794983 ^CTraceback (most recent call last): File "<stdin>", line 3, in <module> KeyboardInterrupt >>> vlc.libvlc_media_player_get_position(player) 1.0611735582351685 >>> vlc.libvlc_media_player_get_position(player) 1.0630782842636108 >>> vlc.libvlc_media_player_get_position(player) 1.0640308856964111 >>> vlc.libvlc_media_player_set_position(player, 1.06) >>> [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 15) for PID 17 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 15) for PID 0 [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 6, expected 11) for PID 500 vlc.libvlc_media_player_set_get_position(player) 1.0034089088439941 >>> [00007fc802d78ca8] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 0) for PID 20

Re: Problem with get_position and get_length on transport stream

Posted: 20 Jun 2016 12:21
by maharg
Tried again with latest nightly (vlc-3.0.0-20160620-0441-git)

Notes:
- had to specify option --no-video to get the playback to work

Findings:
- get_length doesn't reflect current duration of file as it grows
- get_position reports position > 1.0 as playback passes the original duration i.e. the duration when the file was opened
- set_position can be set to a value >1.0 but doing so results in playback stopping, and get_position then returns the same (~ floating point precision) value repeatedly.

Code: Select all

$ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import vlc >>> instance = vlc.Instance(['--no-video']) >>> player = instance.media_player_new() >>> media = instance.media_new("file:///Volumes/captures/bbcnew_1_1466406091/407338.ts") >>> player.set_media(media) >>> player.play() 0 >>> >>> >>> >>> vlc.libvlc_media_player_get_length(player) 343976 >>> vlc.libvlc_media_player_get_length(player) 343976 >>> vlc.libvlc_media_player_get_length(player) 343976 >>> vlc.libvlc_media_player_get_length(player) 343976 >>> vlc.libvlc_media_player_get_position(player) 0.06074704974889755 >>> vlc.libvlc_media_player_get_position(player) 0.06123490631580353 >>> vlc.libvlc_media_player_get_position(player) 0.0760301873087883 >>> vlc.libvlc_media_player_get_position(player) 0.07885760813951492 >>> vlc.libvlc_media_player_get_position(player) 0.08091051876544952 >>> vlc.libvlc_media_player_get_position(player) 0.0860622301697731 >>> vlc.libvlc_media_player_get_position(player) 0.09124723076820374 >>> vlc.libvlc_media_player_set_position(player, .98) >>> vlc.libvlc_media_player_get_position(player) 1.183619499206543 >>> vlc.libvlc_media_player_get_position(player) 1.1918147802352905 >>> vlc.libvlc_media_player_set_position(player, 1.18) >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> player.play() 0 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>> vlc.libvlc_media_player_get_position(player) 1.1799999475479126 >>>

Re: Problem with get_position and get_length on transport stream

Posted: 20 Jun 2016 13:27
by maharg
I have now raised this on the trac at https://trac.videolan.org/vlc/ticket/17085

Re: Problem with get_position and get_length on transport stream

Posted: 06 Mar 2017 17:21
by maharg

Re: Problem with get_position and get_length on transport stream

Posted: 14 Apr 2017 14:54
by Jean-Baptiste Kempf
Nice :)