简体   繁体   中英

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. So far I've set up minidlna server that can stream audio and video. 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).

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:

<?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. I've also tried several other mime-types and file formats, same result every time.

TV: LG 43UJ635V

Laptop: MacBook Pro

minidlnad version: 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.

I have tried a lot of upnp/dlna imlementation but none was working with my brand new WebOS LG TV.

So I have installed the LG software and inspected the packets using Wireshark, more specifically, the SetAVTransport packet.

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. You can find my fork here , and the working payload here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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