kodi-svtplay / xbmc-svtplay

Unofficial addon for watching SVT Play on Kodi
GNU General Public License v3.0
66 stars 34 forks source link

No cache/buffer is used for m3u8 svt play streams, results in choppy/stuttering playback #58

Closed dataolle closed 11 years ago

dataolle commented 11 years ago

Is it possible for the plugin to force xbmc to use cache/buffer (like cachemembuffersize) when playing video? when i play video from a plugin no cache is used (cache 0B 100% is displayed in the cideo information) and the video is choppy/stutters.

Log from playback: https://gist.github.com/4649698

If i download the video stream to a local webserver (with ffmpeg) and stream from that then the cache is used and it plays perfectly fine.

When I playback one of the segments in the m3u8 file it is cached/buffered and it plays perfectly (cache is used). Log from playing single segment segment:

20:03:53 T:2757493824 NOTICE: Thread CGUIDialogCache start, auto delete: true 20:03:53 T:3037683712 NOTICE: COMXPlayer: Opening: http://svtplay9q-f.akamaihd.net/i/world/open/20130125/1278818-005A/STJARNORNA_PA_S-005A-363fe074b865ae35_,900,348,564,1680,2800,.mp4.csmil/segment20_4_av.ts?null=&e=b2a7ace1bf661c32&id=

I use raspberry pi (raspbmc) with rc3 build of xbmc frodo.

linqcan commented 11 years ago

The choppyness you are experiencing is not related to cache, it is related to RPi not being able to handle the avc1.77.30 H264 profile used by SVT to encode their streams. Neither the RPi or the Apple TV2 can handle this profile. To resolve this you have to select "Don't use avc1.77.30" in the advanced settings for the add-on. Pleas try enabling that option and report your result here.

I am basing by answer on the stream URL you pasted above. "...4_av.ts..:" is the usually the high resolution stream (1280x720) which SVT is encoding using the avc1.77.30 profile (for maximum iOS compatibility).

Source: http://forum.stmlabs.com/showthread.php?tid=6328

dataolle commented 11 years ago

Wierd, My rasppi can play the svtplay 720p streams when cached/buffered when i use it now. This is video information for the saved stream (ffprobe from ffmpeg used):

[STREAM] index=0 codec_name=h264 codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 profile=Main codec_type=video codec_time_base=1/50 codec_tag_string=avc1 codec_tag=0x31637661 width=1280 height=720 has_b_frames=2 sample_aspect_ratio=1:1 display_aspect_ratio=16:9 pix_fmt=yuv420p level=31 timecode=N/A is_avc=1 nal_length_size=4 id=N/A r_frame_rate=25/1 avg_frame_rate=25/1 time_base=1/90000 start_pts=7200 start_time=0.080000 duration_ts=316720800 duration=3519.120000 bit_rate=2699584 nb_frames=87978 nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 TAG:language=und TAG:handler_name=VideoHandler [/STREAM] [STREAM] index=1 codec_name=aac codec_long_name=AAC (Advanced Audio Coding) profile=unknown codec_type=audio codec_time_base=1/24000 codec_tag_string=mp4a codec_tag=0x6134706d sample_fmt=fltp sample_rate=48000 channels=2 bits_per_sample=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 time_base=1/48000 start_pts=0 start_time=0.000000 duration_ts=168923136 duration=3519.232000 bit_rate=94358 nb_frames=82482 nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 TAG:language=und TAG:handler_name=SoundHandler [/STREAM] ffprobe version N-49352-gc46943e Copyright (c) 2007-2013 the FFmpeg developers built on Jan 26 2013 12:12:14 with gcc 4.7.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 17.100 / 52. 17.100 libavcodec 54. 91.100 / 54. 91.100 libavformat 54. 61.104 / 54. 61.104 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 34.101 / 3. 34.101 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c:\dl\stars.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf54.25.104 Duration: 00:58:39.23, start: 0.000000, bitrate: 2798 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2699 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 94 kb/s Metadata: handler_name : SoundHandler

When i point the ffprobe to the m3u8 file (grabbed from the xbmc log, avc1.77.30 is enabled) i get the following info:

[STREAM] index=0 codec_name=h264 codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 profile=Main codec_type=video codec_time_base=1/50 codec_tag_string=[27][0][0][0] codec_tag=0x001b width=1280 height=720 has_b_frames=2 sample_aspect_ratio=1:1 display_aspect_ratio=16:9 pix_fmt=yuv420p level=31 timecode=N/A is_avc=0 nal_length_size=0 id=N/A r_frame_rate=25/1 avg_frame_rate=25/2 time_base=1/90000 start_pts=16290 start_time=0.181000 duration_ts=N/A duration=N/A bit_rate=N/A nb_frames=N/A nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 [/STREAM] [STREAM] index=1 codec_name=aac codec_long_name=AAC (Advanced Audio Coding) profile=unknown codec_type=audio codec_time_base=1/48000 codec_tag_string=[15][0][0][0] codec_tag=0x000f sample_fmt=fltp sample_rate=48000 channels=2 bits_per_sample=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 time_base=1/90000 start_pts=9060 start_time=0.100667 duration_ts=N/A duration=N/A bit_rate=105937 nb_frames=N/A nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=0 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 [/STREAM] ffprobe version N-49352-gc46943e Copyright (c) 2007-2013 the FFmpeg developers built on Jan 26 2013 12:12:14 with gcc 4.7.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 17.100 / 52. 17.100 libavcodec 54. 91.100 / 54. 91.100 libavformat 54. 61.104 / 54. 61.104 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 34.101 / 3. 34.101 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [h264 @ 0000000002127a40] non-existing SPS 0 referenced in buffering period [h264 @ 0000000002127a40] non-existing SPS 32 referenced in buffering period [h264 @ 0000000002127a40] non-existing SPS 0 referenced in buffering period [h264 @ 0000000002127a40] non-existing SPS 32 referenced in buffering period [mpegts @ 00000000021299c0] Estimating duration from bitrate, this may be inaccurate [h264 @ 0000000004637da0] non-existing SPS 0 referenced in buffering period [h264 @ 0000000004637da0] non-existing SPS 32 referenced in buffering period Input #0, hls,applehttp, from 'http://svtplay9q-f.akamaihd.net/i/world/open/20130125/1278818-005A/STJARNORNA_PA_S-005A-363fe074b865ae35_,900,348,564,1680,2800,.mp4.csmil/index_4_av.m3u8?null=&e=b2a7ace1bf661c32&id=': Duration: 00:58:40.00, start: 0.100667, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 12.50 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 105 kb/s [h264 @ 00000000021cae00] non-existing SPS 0 referenced in buffering period [h264 @ 00000000021cae00] non-existing SPS 32 referenced in buffering period

H264 info looks identical to me. File (when played over upnp and http) works great, m3u8 stutters. single segment from the same .m3u8 file works great, no stuttering, and cache works in this case.

So looks like the pi is able to handle the video when cache is enabled.

linqcan commented 11 years ago

As you are mentioning yourself, this is ffmpeg/XBMC related and not plugin related. You should file an issue for XBMC instead. Seems like the predefined behavior for applehttp input can be tweaked a little maybe (?).

Again, not plugin related. An add-on for XBMC merely gives the XBMC Player a file URL and XBMC then resolves the URL and take measures depending on the file the URL resolves to.

Interesting find however! =)

Update: This is the PR that introduced HLS passthrough in XBMC. Maybe you can find something interesting there: https://github.com/xbmc/xbmc/pull/1152

dataolle commented 11 years ago

You are correct. Btw thanks for the for the reference to the xbmc pull request. Closing this issue and start talking with the xbmc devs instead. Thanks for your response!

FlyingRat commented 11 years ago

Currently there are some general issues with the XBMC H264 codec that is not related to the SVT Play add-on per see, but just to be clear on the Raspberry Pi H264 supported levels:

The RPI GPU supports avc1.77.30 H264 level 3 as the current included license for the BCM2835 supports up to level 4.1. Higher hardware levels are available with additional licensing. Ref 1: "Raspberry pi h.264 decoding levels" Ref 2: "SVT Play (Plugin) Video Addon - Sveriges Television (Swedish TV)"

dataolle commented 11 years ago

created a forum thread for this: http://forum.xbmc.org/showthread.php?tid=154016

linqcan commented 11 years ago

Read the thread and I have a small addition, that might be of interest: If you enable the avc1.77.30 stripping in the advanced settings, the add-on will create a m3u8 file which is stored locally on the XBMC device. So any functionality looking for "http" etc in the path will fail (because the protocol is "file", I believe). However, if you do not use the avc1.77.30 stripping you will get a path to SVT's akamai servers.

Referenced code: https://github.com/nilzen/xbmc-svtplay/blob/frodo/default.py#L668

Update: Looking at the log in the first post, it does not look like you are using "the stripper".