简体   繁体   English

LG 电视 UPnP/DLNA 错误非法 mime 类型

[英]LG TV UPnP/DLNA error illegal mime-type

I'm trying to write a python script that plays an video file on my LG Smart television.我正在尝试编写一个在我的 LG 智能电视上播放视频文件的 python 脚本。 So far I've set up minidlna server that can stream audio and video.到目前为止,我已经设置了可以流式传输音频和视频的minidlna服务器。 It works from other devices on the same lan.它适用于同一局域网上的其他设备。 Then I have the following code to play something on my TV:然后我有以下代码可以在我的电视上播放一些东西:

#import requests
#import sys


def upload_file(location, filename, controlURL):
    headers = {
        'Content-Type': 'text/xml; charset=utf-8',
        'SOAPAction': '"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"',
    }
    #<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/"><item id="0" parentID="-1" restricted="0"><dc:title>Video</dc:title><dc:creator>Anonymous</dc:creator><upnp:class>object.item.videoItem</upnp:class><res protocolInfo="http-get:*:video/mp4:*" sec:URIType="public">"http://' + location + '/' + filename + '"</res></item></DIDL-Lite>
    data = '<?xml version "1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI><![CDATA[http://' + location + '/' + filename + ']]></CurrentURI><CurrentURIMetaData></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>'
    print "[*] Sending request"

    try:
        response = requests.post(controlURL, headers=headers, data=data, timeout=2)
    except Exception as ex:
        print "[x] Request failed!"
        sys.exit(ex)
    print response.status_code
    print response.text


upload_file("192.168.22.217:8200", "MediaItems/22.mp4", "http://192.168.22.198:1498/AVTransport/8167b8fc-bf78-da40-9070-5663d70a8a40/control.xml")

It doesn't work with or without the metadata in the request.无论是否有请求中的元数据,它都不起作用。 I can access 192.168.22.217:8200/MediaItems/22.mp4 and it plays the video normally and the controlURL is a valid one (I actually get it a little differently, but that is out of scope for this question).我可以访问192.168.22.217:8200/MediaItems/22.mp4并且它可以正常播放视频并且 controlURL 是一个有效的(我实际上得到的有点不同,但这超出了这个问题的范围)。

The TV successfully contacts the minidlna server (I can see it from the logs responding with HTTP 200 and starting serving the file), but the TV doesn't play anything and responds with HTTP 500:电视成功联系了 minidlna 服务器(我可以从以 HTTP 200 响应并开始提供文件的日志中看到它),但电视不播放任何内容并以 HTTP 500 响应:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
            <faultcode>s:Client</faultcode> 
            <faultstring>UPnPError</faultstring>
            <detail>
                <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"> 
                    <errorCode>714</errorCode>
                    <errorDescription>Illegal MIME-type</errorDescription> 
                </UPnPError>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

Why is it happening?为什么会发生? video/mp4 is a valid mime-type. video/mp4是有效的 MIME 类型。 I've also tried several other mime-types and file formats, same result every time.我还尝试了其他几种 MIME 类型和文件格式,每次都得到相同的结果。

TV: LG 43UJ635V电视:LG 43UJ635V

Laptop: MacBook Pro笔记本电脑:MacBook Pro

minidlnad version: minidlnad -V -> Version 1.1.5 minidlnad 版本: minidlnad -V -> Version 1.1.5

I struggled on this issue as well but finally did find a solution that works on WebOS LG TV.我也在这个问题上苦苦挣扎,但最终找到了一个适用于 WebOS LG TV 的解决方案。

I have tried a lot of upnp/dlna imlementation but none was working with my brand new WebOS LG TV.我已经尝试了很多 upnp/dlna 实现,但没有一个适用于我全新的 WebOS LG 电视。

So I have installed the LG software and inspected the packets using Wireshark, more specifically, the SetAVTransport packet.所以我安装了 LG 软件并使用 Wireshark 检查了数据包,更具体地说,是 SetAVTransport 数据包。

Based on my findings, I took an existing basic upnp/dlna streaming utility written in Python called nano-dlna , forked it and adapted the payload to work with my LG TV.根据我的发现,我采用了一个现有的用 Python 编写的基本 upnp/dlna 流实用程序,称为nano-dlna ,将其分叉并调整有效负载以与我的 LG 电视一起使用。 You can find my fork here , and the working payload here .你可以找到我的叉子在这里,工作负载在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM