2015-01-29, 12:21
(2015-01-28, 20:21)bromix Wrote:(2015-01-27, 19:58)constrainer Wrote: As far as I know, the plugin works by downloading the video and playing it as a local temporary file (correct me if I'm wrong). I made an experiment and downloaded one video with issues from YouTube via third-party software, resulting in a 360p mp4 file. I played this file on XBMC (Gotham, 13.2, working on an MX Linux), and it plays smoothly and fine. Is it possible that the plugin is using different file format for the data, which triggers the issue with the decoding? If the plugin is providing an mp4 stream in 360, I think we're good.Go to the Addon-Settings and select for video quality "360p"
Do you really think this was not the first thing I did on initial setup?
![Smile Smile](https://forum.kodi.tv/images/smilies/smile.png)
Anyway, I dug deeper into the problem and found a solution. Here is a full report on it.
First, what do we know up to now:
1. The problem is that some videos are playing glitchy on some devices with XBMC/Kodi installed on embedded Linux.
2. The problem is not in the plugin itself, it is due to problems in some versions of FFMPEG library with the VP8 media format.
3. This problem is brought up by the plugin using this format when fetching a video from YouTube.
4. The problem is avoidable if we request the video from YouTube in MPEG-4 format.
Upon playing such a video among other things in the log file we have this:
Code:
DEBUG: FactoryCodec - Video: - Opening
NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: On2 VP8
DEBUG: FactoryCodec - Video: ff-vp8 - Opened
NOTICE: Creating video thread
The result is glitchy playback.
Enter the file ~/.xbmc/addons/plugin.video.youtube/resources/lib/youtube/helper/video_info.py. This is part of the Bromix YouTube plugin for XBMC/Kodi. In it on line 13 and further we have this:
Code:
DEFAULT_ITAG_MAP = {'5': {'format': 'FLV', 'width': 320, 'height': 240},
'17': {'format': '3GP', 'width': 176, 'height': 144},
'18': {'format': 'MP4', 'width': 480, 'height': 360},
'22': {'format': 'MP4', 'width': 1280, 'height': 720},
'34': {'format': 'FLV', 'width': 480, 'height': 360},
'35': {'format': 'FLV', 'width': 640, 'height': 480},
'36': {'format': '3GP', 'width': 320, 'height': 240},
'37': {'format': 'MP4', 'width': 1920, 'height': 1080},
'38': {'format': 'MP4', 'width': 2048, 'height': 1080},
'43': {'format': 'WEB', 'width': 480, 'height': 360},
'44': {'format': 'WEB', 'width': 640, 'height': 480},
'45': {'format': 'WEB', 'width': 1280, 'height': 720},
'46': {'format': 'WEB', 'width': 1920, 'height': 1080},
'82': {'format': 'MP4', 'width': 480, 'height': 360, '3D': True},
'83': {'format': 'MP4', 'width': 640, 'height': 480, '3D': True},
'84': {'format': 'MP4', 'width': 1280, 'height': 720, '3D': True},
'85': {'format': 'MP4', 'width': 1920, 'height': 1080, '3D': True},
'100': {'format': 'WEB', 'width': 480, 'height': 360, '3D': True},
'101': {'format': 'WEB', 'width': 640, 'height': 480, '3D': True},
'102': {'format': 'WEB', 'width': 1280, 'height': 720, '3D': True},
'133': {'format': 'MP4', 'width': 320, 'height': 240, 'VO': True},
'134': {'format': 'MP4', 'width': 480, 'height': 360, 'VO': True},
'135': {'format': 'MP4', 'width': 640, 'height': 480, 'VO': True},
'136': {'format': 'MP4', 'width': 1280, 'height': 720, 'VO': True},
'137': {'format': 'MP4', 'width': 1920, 'height': 1080, 'fps': 30},
'140': {'format': 'audio/mp4'},
'160': {'format': 'MP4', 'width': 256, 'height': 144, 'VO': True},
'171': {'format': 'audio/webm'},
'242': {'format': 'WEB', 'width': 320, 'height': 240, 'VOX': True},
'243': {'format': 'WEB', 'width': 480, 'height': 360, 'VOX': True},
'244': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'245': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'246': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'247': {'format': 'WEB', 'width': 1280, 'height': 720, 'VOX': True},
'248': {'format': 'WEB', 'width': 1920, 'height': 1080, 'VOX': True},
'264': {'format': 'MP4', 'width': 1920, 'height': 1080, 'VOX': True},
'298': {'format': 'video/mp4; codecs="avc1.4d4020', 'width': 1280, 'height': 720, 'fps': 60},
'299': {'format': 'video/mp4; codecs="avc1.64002a', 'width': 1920, 'height': 1080, 'fps': 60},
'302': {'format': 'video/webm; codecs="vp9', 'width': 1280, 'height': 720, 'fps': 60},
'303': {'format': 'video/webm; codecs="vp9', 'width': 1920, 'height': 1080, 'fps': 60}}
This regulates the format in which we request the video from the YouTube server. Now, if we make a slight adjustment in it in the form of commenting out the options that are not MPEG-4 based, we get this code (only for 360p!):
Code:
DEFAULT_ITAG_MAP = {'5': {'format': 'FLV', 'width': 320, 'height': 240},
'17': {'format': '3GP', 'width': 176, 'height': 144},
'18': {'format': 'MP4', 'width': 480, 'height': 360},
'22': {'format': 'MP4', 'width': 1280, 'height': 720},
#'34': {'format': 'FLV', 'width': 480, 'height': 360},
'35': {'format': 'FLV', 'width': 640, 'height': 480},
'36': {'format': '3GP', 'width': 320, 'height': 240},
'37': {'format': 'MP4', 'width': 1920, 'height': 1080},
'38': {'format': 'MP4', 'width': 2048, 'height': 1080},
#'43': {'format': 'WEB', 'width': 480, 'height': 360},
'44': {'format': 'WEB', 'width': 640, 'height': 480},
'45': {'format': 'WEB', 'width': 1280, 'height': 720},
'46': {'format': 'WEB', 'width': 1920, 'height': 1080},
'82': {'format': 'MP4', 'width': 480, 'height': 360, '3D': True},
'83': {'format': 'MP4', 'width': 640, 'height': 480, '3D': True},
'84': {'format': 'MP4', 'width': 1280, 'height': 720, '3D': True},
'85': {'format': 'MP4', 'width': 1920, 'height': 1080, '3D': True},
'100': {'format': 'WEB', 'width': 480, 'height': 360, '3D': True},
'101': {'format': 'WEB', 'width': 640, 'height': 480, '3D': True},
'102': {'format': 'WEB', 'width': 1280, 'height': 720, '3D': True},
'133': {'format': 'MP4', 'width': 320, 'height': 240, 'VO': True},
'134': {'format': 'MP4', 'width': 480, 'height': 360, 'VO': True},
'135': {'format': 'MP4', 'width': 640, 'height': 480, 'VO': True},
'136': {'format': 'MP4', 'width': 1280, 'height': 720, 'VO': True},
'137': {'format': 'MP4', 'width': 1920, 'height': 1080, 'fps': 30},
'140': {'format': 'audio/mp4'},
'160': {'format': 'MP4', 'width': 256, 'height': 144, 'VO': True},
'171': {'format': 'audio/webm'},
'242': {'format': 'WEB', 'width': 320, 'height': 240, 'VOX': True},
'243': {'format': 'WEB', 'width': 480, 'height': 360, 'VOX': True},
'244': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'245': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'246': {'format': 'WEB', 'width': 640, 'height': 480, 'VOX': True},
'247': {'format': 'WEB', 'width': 1280, 'height': 720, 'VOX': True},
'248': {'format': 'WEB', 'width': 1920, 'height': 1080, 'VOX': True},
'264': {'format': 'MP4', 'width': 1920, 'height': 1080, 'VOX': True},
'298': {'format': 'video/mp4; codecs="avc1.4d4020', 'width': 1280, 'height': 720, 'fps': 60},
'299': {'format': 'video/mp4; codecs="avc1.64002a', 'width': 1920, 'height': 1080, 'fps': 60},
'302': {'format': 'video/webm; codecs="vp9', 'width': 1280, 'height': 720, 'fps': 60},
'303': {'format': 'video/webm; codecs="vp9', 'width': 1920, 'height': 1080, 'fps': 60}}
After that, we play the same video as above and in the log file we get this:
Code:
NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
Obviously we forced the server to return an MPEG-4. Now the video is playing fine, no more glitches.
This is a very crude and probably flawed way to fix this issue, but it works fine on my device.
What I am suggesting to Bromix is to probably include an option in the configuration of the plugin in the manner of "Use MPEG-4 whenever possible" or something in that matter so that people with this issue could work around the problem and enjoy the otherwise excellent experience this plugin delivers.