View Full Version : MythTV Jerky


quantumstate
12-21-08, 09:35 PM
Running a Myth frontend on a laptop which is remote from the HTPC. Watching recordings, sometimes they get so jerky it is impossible to watch. The video & audio stops, then starts, then stops, then starts, randomly. Sometimes I get through a whole half-hour show with no problem, and sometimes it's every few seconds like on Independence Day right now.

CPU on the client is not the problem. Network is 802.11g and is running about 1Mb/s, so that shouldn't be the problem. What exactly is all this bandwidth being used for anyway?

Video is always ATSC mpeg2 at around 16Mb/s and AC-3 sound. The jerkyness is very pronounced, and doesn't seem to be related to CPU, memory, or network usage on either machine.

How would I go about narrowing down the problem? Is there a buffer I can increase or something? Driving me nuts.

Troubleshooter
12-21-08, 10:48 PM
I'm totally not a fan of Myth as a frontend since .21 hit the streets but at the same time, you sure it's not your network? You say that the video is 1mb/s and then say it's 16mb/s so I can't tell. I can tell you this, ATSC or QAM HD are on the ragged edge of real throughput on wireless. The one thing I've learned.....WIRELESS CANNOT BE TRUSTED. Seriously. Some moth farts or your ****** neighbor turns on a toaster and throughput is in the gutter. The best thing I've done is to figure a way to get a damn cable up to my theater. I deluded myself for years with wireless. Hate to be negative but I'd blame that wireless first....That 54 mbit rating is total BS in the real world in one direction.

newlinux
12-22-08, 12:08 AM
Me too, wireless is probably the problem. I have a decent wireless connection, and sometimes it's still choppy for HD... You need a good steady 20Mbps for a solid connection (in my experience).

CityK
12-22-08, 12:54 AM
- what type of nic adapter is the laptop using -- native built in, or USB dongle ... if the later, I could see the inefficencies of having an USB middleman as being a potential source

- what about the video driver...what you have set up ?

On a lighter note, I was soooooooooo tempted to fire off a "to store all my porn' response, after quickly browsing this Wife asking.."Why do you need a Blu-ray burner?" (http://www.avsforum.com/avs-vb/showthread.php?t=1098763) thread....alas I resisted the call for dumbassness ... and, yet, on another related note - optical discs suck. I hardly ever burn anything anymore. hdd and flash storage is so much more convenient...$90 for a pagkage of BR blanks ! now that deserves a Edna Krabappel "Ha!"

quantumstate
12-22-08, 08:09 AM
you sure it's not your network? You say that the video is 1mb/s and then say it's 16mb/s so I can't tell. I can tell you this, ATSC or QAM HD are on the ragged edge of real throughput on wireless. The one thing I've learned.....WIRELESS CANNOT BE TRUSTED.
Me too, wireless is probably the problem. I have a decent wireless connection, and sometimes it's still choppy for HD... You need a good steady 20Mbps for a solid connection (in my experience).
May well be right. It does behave just like this sort of random interference, sometimes stalling for 5 seconds, and in fact I reliably get this when I microwave something.

For standard def I'm seeing a throughput of ~1.3Mb, and there's no visible disturbance of the signal in either kwireless or kdevmon, but that doesn't mean it's not happening. When I microwave something I do see the kwireless bars go crazy though. With high-def I run over 2Mb often with no problem, but same intermittent jerkiness.

So actual network use is ~1.3Mb for standard def, but when I examine the file itself with mplayer, it says it's 16Mb mpeg2. (ATSC) So I guess it's getting delivered to the remote machine as compressed mpeg2, and then decoded there.

On another note, I can not understand why in transcoding setup, Myth limits you to a max bitrate of 8Mb/s? Need at least 10 for no disturbance of HD quality. And which mpeg4 is the transcoder using? x264, or something else? And for audio, why are the only two choices uncompressed or mp3? mp3 is not compatible with Bluray. I only want to transcode to Bluray, preserving any 5.1 or 7.1.


- what type of nic adapter is the laptop using -- native built in, or USB dongle ... if the later, I could see the inefficencies of having an USB middleman as being a potential source

- what about the video driver...what you have set up ?
It's a built-in miniPCI Intel 4965. Solid enough to transfer multigigabyte files, although who knows how many retries.
# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:1d:e0:7b:df:72
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25794824 errors:0 dropped:0 overruns:0 frame:0
TX packets:13376284 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:38179092429 (35.5 GB) TX bytes:1191319075 (1.1 GB)
It does look clean though. I guess I could run a hardwire to test and see whether I get the problem. I wonder if there's also a cache setting I could increase?

Video card is fine. It's an nVidia Quadro 1600 with nVidia 180.11 driver. CPU typically runs at 35% (I guess much of one core) for standard def. CPU on the remote machine runs at like 5%.

I just wish I could examine that bandwidth to see what it's comprised of.


On a lighter note, I was soooooooooo tempted to fire off a "to store all my porn' response, after quickly browsing this Wife asking.."Why do you need a Blu-ray burner?" (http://www.avsforum.com/avs-vb/showthread.php?t=1098763) thread....alas I resisted the call for dumbassness ... and, yet, on another related note - optical discs suck. I hardly ever burn anything anymore. hdd and flash storage is so much more convenient...$90 for a pagkage of BR blanks ! now that deserves a Edna Krabappel "Ha!"
Ya, I agree. I'm holding off on Bluray indefinitely. Have a temporary DVD 40wire ribbon run out the top of my HTPC. Hard disk is the way to go.

Troubleshooter
12-22-08, 10:02 AM
If you grab ATSC or QAM HD streams, you record them at the actual bitrate of the stream since you actually are recording the mpeg2 transport stream itself so the bitrate setting on record isn't used for that.
-Trouble

quantumstate
12-22-08, 10:51 AM
Right, but I'm talking about bitrate settings in transcode. I've set High Quality to mpeg4 (whatever that means... x264?), and bitrate and quality to max. Bitrate only goes up to 8Mb/s, inexplicably, when we need more for HD.

And audio is a real question. I believe ATSC sends audio in stereo, 5.1 or 7.1, and maybe this is encoded with AC-3? How can I transcode audio while preserving stereo, 5.1 or 7.1? Into E-AC3, or something else? What would be compatible with Bluray players?

How do I make x264 available to Myth? How do I make the proper audio codec(s) available to Myth? No one seems to know, and it's not in the Myth Wiki HD page.

Troubleshooter
12-22-08, 12:15 PM
It's mpeg4 but I believe it's XVID/DIVX. It's not H.264. Based on my rules that run a transcode job on every recording, I'd think that my HD recordings should auto transcode but I find that they don't. Haven't really looked into it though.

-Trouble

quantumstate
12-22-08, 01:57 PM
Ya, I just transcoded "It's a Wonderful Life", and it went from 13GB to 16GB, LOL, even as I stepped it down from 16GB/s to 8GB/s.
VIDEO: [DIVX] 1920x1088 10bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)

Wonder how you make x264 internal to MythTV. Seems to already be one of the build dependencies.

CityK
12-23-08, 01:26 AM
So actual network use is ~1.3Mb for standard def, but when I examine the file itself with mplayer, it says it's 16Mb mpeg2. (ATSC)
...
So I guess it's getting delivered to the remote machine as compressed mpeg2, and then decoded there.
...
CPU typically runs at 35% (I guess much of one core) for standard def. CPU on the remote machine runs at like 5%.

I just wish I could examine that bandwidth to see what it's comprised of.I'm not really following your setup, but what I believe you are doing is:
- dumping a Transport Stream to disk on your remote machine
- performing a transcode of the file stored on your remote machine while at the same time watching the content in real time and having difficulty doing so.

If that is the case, the file on the remote machine is just being feed to your laptop and is simultaneously being decoded and then transcoded to a another format and that this new file is itself in turn being decoded (which is necessary because its content has been saved in a compressed format) for live viewing. If this is the case, then it is no wonder you are seeing such high CPU for just SD and are having hiccups! You need to cut out the last step -- transcode in the background, but use the original for viewing.

quantumstate
12-23-08, 09:06 AM
Thanks CityK, but no I am happy to transcode at a later time. Myth records the OTA mpeg2 shows on the HTPC. From my laptop I set up reverse SSH tunnels from the HTPC, and serve the two remote Myth ports and MySQL port to the laptop as if they were local, then run mythfrontend on the laptop to watch TV in bed. So the Myth backend streams the mpeg2 to my laptop and the laptop decodes the video. 35% CPU isn't unreasonable, as it does not have hardware decode of mpeg streams.

Runs fine on SD and HD except about every 30min-hour I get these storms of jerkiness, where audio and video just stop... for up to 5 seconds... and then resume only to stop stop stop over and over, eventually healing itself.

Based on suggestions here, I've run a hardwire now and the problems have disappeared, so apparently the problem is interference on my Wifi. I am in the process now of setting up for 802.11n for that (or maybe better, 802.11a), getting the latest Intel 4965 driver for the laptop and a new router. This will improve throughput manyfold as well.

Thanks ppls.

As an aside I want to archive recordings in Bluray format, but no one seems to understand the processes nor formats. I know I need to use x264 to transcode video to H.264/AVC, but I also want to transcode audio to a Bluray format that players will understand and preserve any 5.1 or 7.1 that may be there, so have been trying to identify the codec.

Then the challenge is actually transcoding. I've been turned on to the mythnuv2mkv script, but it is not working for me and the reasons aren't clear.

waterhead
12-23-08, 09:52 AM
.... I am in the process now of setting up for 802.11n for that (or maybe better, 802.11a), getting the latest Intel 4965 driver for the laptop and a new router. This will improve throughput manyfold as well.

For the latest versions of wireless drivers, the best source is found here:

http://linuxwireless.org/en/users/Download

This "package" includes most of the free/open source wireless drivers. Of course, you could also pull from the Intel wireless git repository.

http://git.kernel.org/?p=linux/kernel/git/linville/wireless-testing.git

quantumstate
12-23-08, 10:57 AM
Thanks wh. Since June I've used the git, compiling it whenever I compiled a new kernel, but never updating the git. Recently I found that the driver is actually in the kernel now, but the version is ancient so I am forced to git once again.

The latest versions support draftn2, but all I can find is this compat-wireless mularkey which has scores of adapters including the kitchen sink. Don't trust any source much further than linux-wireless to have the requisite draftn2 version. I remember before I used svn or git, not the tarball, so trying to figure out what's what now.

Troubleshooter
12-23-08, 11:20 AM
Quantumstate, you're tunneling all your network connectivity over ssh? The encryption certainly takes overhead in terms of throughput and CPU. On a laptop, I'd think that would be considerable. Are you super paranoid or a KGB agent or something?

Take a look at the dstat command. You can see if you are in IO wait, waiting for disk or network.

-Trouble

mythmaster
12-23-08, 12:15 PM
dstat rocks! Thanks, TS -- first I've heard of it. Been looking for something like this. :)

quantumstate
12-23-08, 12:33 PM
Yeah, dstat is nice, thanks!

I've got a pretty high-end laptop (HP 8710w), and ssh is not an issue judging by overhead for file transfer. I can stream HD through Myth with no problem most of the time, except in times of interference.

I downloaded the compat-wireless tarball, and it gifts me with a kernel panic on boot when the iwl module loads. Thank you. {said like Homey the Clown} Had lots of problems before getting a working version from intelwireless, and clung to that like grim death. So now trying the git version, and the one intended for kernels >2.6.26.

Troubleshooter
12-23-08, 04:36 PM
Yeah dstat is cool. One of the first things I install on all my machines. Another goodie to look at is atop. You'll need to take a gander at the manual page for it, but it's damn sweet too.
-Trouble

quantumstate
12-23-08, 08:07 PM
Now I remember why I stuck with the same kernel and wifi driver for so long...

I can compile and boot to 2.6.24-22, and I can compile the iwl4965 driver to it. I can even load the module, although the interface won't connect to the AP for some reason. But when I reboot the kernel crashes and burns, right after it loads the module. Where exactly, I can't tell as it's scrolled off the screen, and there's no evidence in the kernel logfile. Recompile without the iwl driver, and it's fine.

How the hell does a wifi driver module, bring down a 64bit kernel?!

I've tried the old tar iwl driver, the git, the newer iwl driver and the git... all the same symptoms.

2.6.27-11.22 crashes in compile, for reasons I can't understand. Next I'm going to try 2.6.28 and .22. At the moment I have no way of using wifi. Having to string a wire.

Kernel compiles are taking forever because most all of my cores are occupied with these zombies:
4 root 15 -5 0 0 0 R 99% 0.0 293:16.47 ksoftirqd/0
8275 root 20 0 26056 776 568 R 97% 0.0 244:21.41 kdm

Well, I guess this is what I get...
For eh... daring to impinge on its prerogative?

quantumstate
12-24-08, 11:20 AM
Well, I simply can not compile any version of kernel 2.6.27 or .28 on the laptop. Always fails the same way:

OFFSETS arch/x86/boot/offsets.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Root device is (8, 1)
Setup is 11916 bytes (padded to 12288 bytes).
System is 2904 kB
CRC 30db084d
Kernel: arch/x86/boot/bzImage is ready (#1)
ERROR: "snd_hwdep_new" [ubuntu/misc/media/snd-bt-sco.ko] undefined!
WARNING: modpost: Found 4 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
Hydra:/usr/src/linux-source-2.6.27#

I can compile them on the HTPC though. Looks like I'm stuck on .22 for the laptop. In a few years I might as well be Amish.

On .22 the 4965AGN wifi card will not associate with the AP, with the exact same configuration as worked in the git driver of 6 June. I suspicion the new n and a functionality is the problem. Of course Intel provides absolutely no instructions for configuration.

I need to put it in g mode and WPA with key, but the wpa-ssid and wpa-psk commands no longer seem to work. Neither does pre-up /sbin/iwpriv wlan0 network_type g anymore. iwpriv now sees no private ioctls for this card.

Joining the fscking mailing list.

Troubleshooter
12-24-08, 11:35 AM
Looks like it's bluetooth audio - One suggestion. add snd-emu10k1 to your kernel config as a module and try building again.

-Trouble

quantumstate
12-24-08, 01:10 PM
Looks like it's bluetooth audio - One suggestion. add snd-emu10k1 to your kernel config as a module and try building again.
I'll be damned... it worked. I never would have guessed that in 1,000 years, and was too freaked out to notice the snd-bt-sco.ko. Thanks TS.

Trying the new kernel and wifi...

quantumstate
12-24-08, 04:16 PM
Well by Jove's good will, I finally got wifi working.

Thanks to a tip by Troubleshooter I got 2.6.27-11.22 to compile, but it threw a kernel exception when it was time to pivot to sda1. Finally traced that to a controller being set as a module, so set it as compiled into kernel, and rebooted.

I then had the nice little blue wifi light which I'd never had before, and it twinkled, apparently with network access. iwconfig, and indeed it was associated as it should be, showing 54Mb/s. All right, so the kernel iwl modules are working with this version, good enough for me... although iwconfig shows:
wlan0 IEEE 802.11abgn ESSID:"Hex"
Mode:Managed Frequency:2.462 GHz Access Point: 00:11:50:2B:4D:A2
Bit Rate=54 Mb/s Tx-Power=5 dBm
Retry min limit:7 RTS thr:off Fragment thr=2352 B
Encryption key:AM32-52G0-50D6-130B-6AF0-201D-9450-H978 [2] Security mode:open
Power Management:off
Link Quality=100/100 Signal level:-33 dBm Noise level=-92 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Ehm, Security Mode 'Open'? Homey don't think so. The AP us set to WPA AES.

Whatever, it's wrong. Now to find a nice 802.11a AP. I presume the 4965 is promiscuous in whether it connects as a, b, g, or n, as long as the ESSID and WPA key match. I hope... as I haven't found a way to set mode with the new driver.