Plex and WTV Files

I'm hoping I can get an answer to two questions that are related to the above. I run a Windows 7 Media Center PC, (WMC), on which I watch and record DTV programs, (UK Standard Definition Freeview). I have also, in the last few months, started running Plex on a Ubuntu 12.10 based server - and I'm moving my video collection into Plex. But, I'd like to also watch my TV recordings via Plex. Specifically, I'd like to use a WD TV Live device to watch WTV files via Plex DLNA.

 

Having read the forums, I know there are problems with what I want to do, especially if I want to read the WTV directly, rather than using a trigger on the WMC PC to instigate a transcode/copy/delete in response to WMC events. I was hoping to:-

 

1. Mount \\win7pc\Public\Recorded TV using CIFS on the Ubuntu server, (so that the recorded WTV files appear local to Plex).

2. Write a custom Plex scanner to select the WTV files.

3. Write a custom metadata agent to read the metadata embedded in the WTV file.

4. Play the WTV via DLNA to the WD TV Live device.

 

I've had some success, but two principle problems, may mean I will need to use a different approach:-

 

1. The mount seemed to work fine, although it did cause very long delays in network file reads on the WMC PC. I think it was due to having foolishly created a circular reference. Whereby, the mount point of the WMC recordings directory on the Ubuntu server, was also part of a mapped drive on the WMC PC. But, I haven't investigated this further yet, and I've been using 8 test WTV files copied to the Ubuntu server for development purposes.

 

2. The scanner just picked up files with a WTV extension, (all the recordings are stored in one directory by WMC). I imported the recordings as movies, since they are a mix of show types, and the episode/season information isn't stored in the WTV metadata. The imported files play fine via HLS in the web player and via the previous version of the Android application. (If Plex allowed grouping by program name/recording time, as a substitution for season/episode number, then a TV shows like presentation might be possible).

 

3. I was able to use the information from http://wiki.multimedia.cx/index.php?title=WTV, (and to a lesser extent the source files for ffmpeg WTV support - I can't read C), to read the metadata in the WTV file. I wrote it in Java, (which I know), and then translated it into Python, (which I started learning just for this task). After a few tweaks, (plug-ins don't seem to support __private class variables), I've encountered the following error in the plug-ins log:-

 

2013-06-02 14:46:12,919 (7fbed0ff9700) : ERROR (__init__:93) - global name 'open' is not defined

 

and I latterly, read this entry in the Plex Plug-in Framework Documentation Release 2.1.1 on page 78:-

 

Plug-ins are generally not allowed to access the user’s file system directly, ...

 

which I'm assuming means I won't be able to read the metadata from the WTV files directly. My plugin needs these statements:-

 

f = open(self.filename, "rb")
f.seek(offset)
extract = f.read(length)
 

 

4. Play back of the WTV files via Plex DLNA on the WD TV Live can be a bit hit and miss. Since they play fine via HLS, I'm perplexed. I noticed that the dlnaclientprofiles.xml file has this line, which seems to be what is being used to transcode the WTV files for transmission via DLNA:-

 

 

 

Typical output for a Freeview WTV file, using ffmepg's -i option, is:-

 

Stream #0:0[0x28](eng): Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16, 256 kb/s (hearing impaired)

Stream #0:1[0x2a](eng): Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16, 256 kb/s

Stream #0:2[0x2b]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb/s, 30.25 fps, 25 tbr, 10000k tbn, 50 tbc

Stream #0:3[0x2c](eng): Subtitle: dvb_subtitle

Stream #0:4[0x0]: Attachment: mjpeg

 

The default options to ffmpeg will often pick the hearing impaired track, and on occasion I think its picked the mjpeg as the video. A generic line like:-

 

ffmpeg -i "Pointless Celebrities_BBC ONE_2013_04_06_17_18_28.wtv" -map 0:a -map 0:v -vcodec copy -acodec copy Test.mpg

 

produces playable mpg files, but I couldn't see anything like these options for a dlnaclientprofiles.xml line, maybe something like:-

 

 

 

but perhaps this isn't possible.

 

In summary - I'd very much appreciate a developer telling me:-

 

1. Are metadata plug-ins forbidden from reading the media file, that's passed into the update() method, from disc?

 

2. Is it possible to extract/copy the contents of the WTV file for transmission, rather than transcode, via DLNA?

 

If I can find out the answers to these, I will know whether its worth pursuing my current plan, or looking for an alternative.

 

Thanks, and sorry for the long post!

Hi

Have you made any more progress on your WTV support?

I havent been able to get any WTV files to show up in Plex at all.  I really need this to be able to dump WMC for play back once & fro all.

Cheer,

Geoff.

I just tried an experiment.  I mapped a drive on the Plex server to the UNC path that holds my Recorded TV and then added that drive letter as the location for files in the section.  I used the Plex Video Files Scanner, and the Personal Media agent. 

These settings made Plex server find the WTV files!

Now to see how well they stream...

Hi Clowg,
 
To answer my own question above first. You don't seem to be able to use the 'open' method when writing a plugin, although there is a 'load' method that will read in a whole file. Obviously, this won't work for multi-gigabyte WTV files. See here:-
 
Opening files
 
Now in response to your question, from memory, I did a similar thing to yourself to test support for WTV files. Newer ffmepg versions seem to support WTV files, and it is possible to transcode them using it. When I added them to Plex, it was possible to play them via the Plex android client, (the few that I tested anyway). But, it would not play them via the WDTV, which is what I wanted to achieve. Sorry, I can't remember whether playing them via Plex/DLNA worked for other third party android clients, such as the BubbleUPNP/MX Player combination. Certainly, MX player will play the WTV files via a mapped drive/UNC path.
 
About a month ago I wrote a PowerShell script to transcode WTV recordings on the Media Center PC, and group them into sub-directories based on the programme name, each time a programme is recorded or deleted. My reasoning being that the majority of the programmes will be watched and then deleted, and as they weren't going to be kept, there was no need to place them into Plex. I designated the directory that contained the transcoded files as a media library in Media Center, and let Windows stream the files using its DLNA capabilities.
 
After a months use of this arrangement, I'm not that happy with it, and am again considering copying the programmes into Plex. I've experienced the following problems:-
 
1. When all episodes of a programme are deleted, the directory containing them is removed too. However, Media Center sometimes won't release the directory, and it remains in a kind of limbo. It is visible in file manager, but cannot be opened. So, when the next episode is transcoded and new directory, with the programmes name needs to be created, it cannot be, because the old directory still exists. Unloading Media Center results in these limbo directories immediately being deleted. Intermintent and annoying, and it may be something I am doing, but I can't see what.
 
2. Although, the resulting MPEG files stream better to the WDTV, they are still often flaky.
 
So, I'm reconsidering transferring the WTV files into Plex as MPEGs. The PowerShell script already outputs the file property details as an XML file, so I could use the Plex 'load' method to write a Metadata Agent that will pickup that information. It's missing some the metadata that is available when directly reading the WTV, most notably the MJPEG thumbnail image, so I need to decide whether to use the Windows file properties or read the metadata directly out of the WTV file - or a combination of the two.
 
Sorry to go off topic somewhat from your question. But, I hope that by providing these details it will help others not to repeat my mistakes, or be able to improve upon them.
 
If I remember correctly Plex works with WTV files, if you use Plex on the server and as the client, (Android/web browser). Using other clients, it's variable, (as to be expected I suppose).
 
If I get my plans implemented I'll post an update.

Thanks for the detailed response.  Your powershell script sounds interesting.  I would like to try it to convert my WTVs into MP4 and see if I get a better result from playing/streaming them with PHT and XBox360.  Let me know if you would give me a copy to try.

I found that the native support for WTV streaming worked OK to a web browser (Firefox 23) but not to PHT.  On PHT (on Windows 7) it was choppy - looked like frames being dropped.

Cheers,

Geoff.

Hi Geoff,
 
Sorry, the script is a work in progress, and wasn't written with being released into the wild in mind. For example, when you link a command line action, (PowerShell script), to be triggered when an event occurs. The EventRecordID is not generally passed through to the script, so it is difficult to identify the triggering event. It is possible to hand craft the XML and import it to create an event, which should enable this functionality, but I found it only intermittently worked.
 
I, therefore, worked around it by keeping a list of the last several processed EventRecordIDs, and comparing those with a query that returns the events triggered in the last 60 seconds. To avoid a race condition, where several events are triggered close together, access to the processed list is serialised using a lock file. My script merely extracts the embedded mpeg video and mp2 audio, which is quick process that can run in parallel. Encoding to mp4 you would probably want to run sequentially, which could take a few minutes to an hour. Consequently, my method of deducing the EventRecordID from the events triggered in the last 60 seconds would fail.
 
I'm sure there are other subtle assumptions I have made that would make the script awkward to use. You are probably better off manually transcoding a few files to test.
 
If/when I rewrite the script, I'll endeavour to make it more generic, with the intention of releasing it.
 
I placed a few WTV files into a Plex library to test, and played a couple through the Plex client on my Win7 Media Center, which I think is running on a  Core2 Duo E7400 . Also on a Core i3 laptop over WiFi, and via BubbleUPnP/MX Player on a Nexus 10.  They played fine, but it was  a very small test. I'm using version 0.9.7.22 of the server on Ubuntu 64bit, and used the latest version of the client on the laptop.
 
Probably not much help to let you know a small test worked for me!

IMHO, I'd go ahead and start moving off of WTV file format and converting them to mp4 (or your other preferred format) for the following reasons:
* they take up way too much space
* it's next to impossible to get anyone else to support them
* the DRM encoding sux IMO and ya can't even watch copyrighted movies on other devices in your own home
* MSFT is phasing Media Center out in favor of cloud based xBox1
   which I assume that wtv format support is on it's way out as well
I'd suggest downloading and start converting with this free/support appreciated app

MCEBuddy
http://mcebuddy2x.codeplex.com/

~Raptor
 

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.