Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#5866 closed patch (fixed)

HD-PVR update to mpegrecorder

Reported by: jppoet@… Owned by: Janne Grunau
Priority: minor Milestone: 0.22
Component: MythTV - General Version: head
Severity: medium Keywords: HD-PVR
Cc: Ticket locked: yes

Description

Some optimizations to mpegrecorder for the HD-PVR device.

Checks input resolution and sets bitrates *before* starting encoding. Doing that after encoding would always require a recovery by the poll-timeout patch in ticket #5604 (unless the input resolution happened to be 720x480). By moving the check before starting encoding, the poll-timeout recovery is only needed if the input resolution changes.

Also add a few usleeps, which *seemed* to make ioctl communications with the HD-PVR more reliable in the past. It is possible that they are not needed anymore, but I decided to error on the side of caution.

Patch also contains Janne's "hack" to prefer AC3, if available. I can remove that part, if needed.

Attachments (10)

mpegrecorder-hdpvr.patch (13.5 KB) - added by jppoet@… 15 years ago.
check resolution and set bitrate before starting encoding
hdpvr-fix-channel-changes.patch (13.2 KB) - added by jppoet@… 15 years ago.
Fix HD-PVR channel changes on the backend
hdpvr-v4lchannel-tweak.patch (4.8 KB) - added by jppoet@… 15 years ago.
hack to keep v4lchannel from aborting on HD-PVR channel changes
mpegrecorder-hdpvr-v1.1.patch (18.1 KB) - added by jppoet@… 15 years ago.
Update for trunk r19054. Replaces mpegrecorder-hdpvr.patch *and* hdpvr-fix-channel-changes.patch
mpegrecorder-hdpvr-v2.patch (18.5 KB) - added by jppoet@… 15 years ago.
This version should always get the bitrate right.
5866-livetvchain-v1.patch (1.8 KB) - added by danielk 15 years ago.
Just an add on, LiveTVChain should treat HDPVR streams like it does DVB streams..
hdpvr-livetv.patch (3.7 KB) - added by jppoet@… 15 years ago.
Fix LiveTV for the HD-PVR
live_tv_channel_chnge_issue.log (4.5 KB) - added by kevin 15 years ago.
Log of problem with changing live TV channels
mythbackend_live_tv_channel_change_prob.txt (50.5 KB) - added by kevin 15 years ago.
mythbackend log -v record,channel of live tv channel change problem
mpegrecorder-hdpvr-v2a.patch (19.3 KB) - added by jppoet@… 15 years ago.
Minor refresh to mpegrecorder-hdpvr-v2 so applies to current trunk.

Download all attachments as: .zip

Change History (28)

Changed 15 years ago by jppoet@…

Attachment: mpegrecorder-hdpvr.patch added

check resolution and set bitrate before starting encoding

comment:1 Changed 15 years ago by jppoet@…

Adding a new patch which "fixes" Live TV channel changes, when the input resolution changes on the HD-PVR. Unfortunately, it only fixes the problem on the backend. If the input resolution changes, the frontend will hang, while the backend is happy recording the new channel. Also, unfortunately, it increases the time it takes to change channels by a couple of seconds -- the delay is required to fix the problem. Note: this does not impact recordings, only Live TV

On the frontend, if you bring up Live TV shows in the playback screen, and choose the channel that you changed to (with the new resolution), it will playback just fine.

This patch also eliminates the hard-codes usleeps in mpegrecorder-hdpvr.patch, and replaces them with "as needed" usleeps to make sure ioctls succeed.

This patch depends on the mpegrecorder-hdpvr.patch.

Changed 15 years ago by jppoet@…

Fix HD-PVR channel changes on the backend

Changed 15 years ago by jppoet@…

hack to keep v4lchannel from aborting on HD-PVR channel changes

Changed 15 years ago by jppoet@…

Update for trunk r19054. Replaces mpegrecorder-hdpvr.patch *and* hdpvr-fix-channel-changes.patch

comment:2 Changed 15 years ago by jppoet@…

Replaced mpegrecorder-hdpvr.patch and hdpvr-fix-channel-changes.patch with a single patch which will apply against r19054. With these patches, you still need hdpvr-v4lchannel-tweak.patch to have any prayer of using LiveTV.

Also still recommended: http://svn.mythtv.org/trac/attachment/ticket/5604/DeviceReadBuffer-polltimeout.2.patch

Changed 15 years ago by jppoet@…

Attachment: mpegrecorder-hdpvr-v2.patch added

This version should always get the bitrate right.

comment:3 Changed 15 years ago by jppoet@…

Added mpegrecorder-hdpvr-v2.patch. Replaces all previous patches on this ticket.

It should always get the bitrate right. It also fixes the problem with setting the input on the HD-PVR during channel changes -- the right way. Do not apply hdpvr-v4lchannel-tweak.patch any more.

http://svn.mythtv.org/trac/attachment/ticket/5604/DeviceReadBuffer-polltimeout.2.patch must be applied first.

Changed 15 years ago by danielk

Attachment: 5866-livetvchain-v1.patch added

Just an add on, LiveTVChain should treat HDPVR streams like it does DVB streams..

comment:4 Changed 15 years ago by danielk

Owner: changed from Isaac Richards to danielk
Status: newaccepted

comment:5 Changed 15 years ago by danielk

(In [19508]) Refs #5866. Make sure HD-PVR is treated like other recorders that can change resolution and/or aspect ratio on channel changes.

Changed 15 years ago by jppoet@…

Attachment: hdpvr-livetv.patch added

Fix LiveTV for the HD-PVR

comment:6 Changed 15 years ago by jppoet@…

Added hdpvr-livetv.patch. This patch applies after mpegrecorder-hdpvr-v2.patch.

It fixes using the HD-PVR for LiveTV by eliminating the test for the input resolution. If LiveTV is detected, the max defined bitrate will always be used, regardless of the input resolution.

This saves ~2 seconds on channel changes, and avoids the occasional time-out.

Changed 15 years ago by kevin

Log of problem with changing live TV channels

comment:7 Changed 15 years ago by kevin

I'm still having an issue with changing Live TV channels, even after I apply the hdpvr-livetv.patch. I have attached a log with -v record,channel to this ticket. Please let me known if you need anything else.

Changed 15 years ago by kevin

mythbackend log -v record,channel of live tv channel change problem

comment:8 Changed 15 years ago by jppoet@…

Kevin's problem with hdpvr-livetv was that he only applied it to his FE computer. This patch does it's magic on the BE.

Changed 15 years ago by jppoet@…

Minor refresh to mpegrecorder-hdpvr-v2 so applies to current trunk.

comment:9 Changed 15 years ago by jppoet@…

Updated mpegrecorder-hdpvr-v2 so it will apply to current trunk. hdpvr-livetv still needs applied after this patch.

comment:10 Changed 15 years ago by Janne Grunau

Resolution: fixed
Status: acceptedclosed

(In [19989]) HD PVR optimizations, closes #5866

checks the input resoution before starting encoding and set bitrates accordingly always use the max bitrate for LiveTV since checking the resolution with the device takes too long after channel switches.

based on patch by John Poet <jppoet at gmail dot com>

comment:11 Changed 15 years ago by Janne Grunau

Component: mythtvMythTV - General
Milestone: unknown0.22
Owner: changed from danielk to Janne Grunau
Version: unknownhead

comment:12 Changed 15 years ago by mythdev@…

The patch in [19989] seems to break recording with the PVRUSB2 device:

2009-03-28 10:33:29.770 TVRec(2): Changing from None to Watching WatchingLiveTV
2009-03-28 10:33:29.777 TVRec(2): HW Tuner: 2->2
2009-03-28 10:33:31.058 AutoExpire: CalcParams(): Max required Free Space: 2.0 GB w/freq: 15 min
2009-03-28 10:33:31.148 MPEGRec(/dev/video1) Error: StartEncoding
                        eno: Invalid argument (22)
2009-03-28 10:33:31.167 MPEGRec(/dev/video1) Error: Failed to start recording
2009-03-28 10:33:31.169 MPEGRec(/dev/video1) Error: StopEncoding
                        eno: Invalid argument (22)

On the user mailing list somebody already saw this patch is the problem:

http://www.gossamer-threads.com/lists/mythtv/users/372739?do=post_view_flat

I think it is in this part:

1047	 	    needs_resolution = (driver == "hdpvr"); 

This line was removed, but maybe it is still needed?

comment:13 Changed 15 years ago by jppoet@…

Can you please attach a more complete log with "-v record"?

comment:14 Changed 15 years ago by mythdev@…

This is the output from -v record:

2009-03-30 10:11:20.194 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PMT @43590808 + 636192
2009-03-30 10:11:20.428 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PAT @60714976 + 1696512
2009-03-30 10:11:20.430 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PAT @43830320 + 671536
2009-03-30 10:11:20.510 TVRec(2): RecordPending on inputid 27
2009-03-30 10:11:20.527 TVRec(2): StartRecording(Teleshop 8: Tel sell)
2009-03-30 10:11:20.528 TVRec(2): ASK_RECORDING 2 0 0 0
2009-03-30 10:11:20.652 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PMT @60975920 + 848256
2009-03-30 10:11:20.655 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PMT @44051032 + 742224
2009-03-30 10:11:20.681 TVRec(2): StartedRecording(0xc11250) fn(/mnt/store/1098_20090330101100.mpg)
2009-03-30 10:11:20.683 TVRec(2): ClearFlags(CancelNextRecording,) -> RunMainLoop,
2009-03-30 10:11:20.687 TVRec(2): Changing from None to Watching RecordingOnly
2009-03-30 10:11:20.688 TVRec(2): ClearFlags(FrontendReady,CancelNextRecording,) -> RunMainLoop,
2009-03-30 10:11:20.690 TVRec(2): Request: Program(yes) channel() input() flags(Recording,)
2009-03-30 10:11:20.693 TVRec(2): HW Tuner: 2->2
2009-03-30 10:11:20.694 TVRec(2): ClearFlags(PENDINGACTIONS,) -> RunMainLoop,
2009-03-30 10:11:20.697 TVRec(2): No recorder yet, calling TuningFrequency
2009-03-30 10:11:20.734 TVRec(2): ClearFlags(NeedToStartRecorder,) -> RunMainLoop,
2009-03-30 10:11:20.736 TVRec(2): SetFlags(NeedToStartRecorder,) -> RunMainLoop,NeedToStartRecorder,
2009-03-30 10:11:20.737 TVRec(2): Starting Recorder
2009-03-30 10:11:20.787 Using profile 'Default' to record
2009-03-30 10:11:20.802 RecBase(2:/dev/video1): SetRingBuffer(0x7e2c40) '/mnt/store/1098_20090330101100.mpg'
2009-03-30 10:11:20.820 RecBase(2:/dev/video1): SetRecording(0xc11250) title(Teleshop 8: Tel sell)
2009-03-30 10:11:20.840 MPEGRec(/dev/video1): usingv4l2(1) has_v4l2_vbi(1) has_buggy_vbi(1)
2009-03-30 10:11:20.857 AutoExpire: CalcParams(): Max required Free Space: 3.0 GB w/freq: 5 min
2009-03-30 10:11:20.915 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PAT @61215996 + 812912
2009-03-30 10:11:20.928 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PAT @44291860 + 247408
2009-03-30 10:11:20.979 DevRdB(/dev/video1): buffer size 9400 KB
2009-03-30 10:11:20.981 MPEGRec(/dev/video1): DRB ready
2009-03-30 10:11:20.983 MPEGRec(/dev/video1): Initial startup of recorder
2009-03-30 10:11:20.984 MPEGRec(/dev/video1): StartEncoding
2009-03-30 10:11:20.985 MPEGRec(/dev/video1) Error: StartEncoding
                        eno: Invalid argument (22)
2009-03-30 10:11:20.986 MPEGRec(/dev/video1) Error: Failed to start recording
2009-03-30 10:11:20.987 MPEGRec(/dev/video1): StartRecording finishing up
2009-03-30 10:11:20.987 TVRec(2): SetFlags(RecorderRunning,RingBufferReady,) -> RunMainLoop,NeedToStartRecorder,RecorderRunning,RingBufferReady,
2009-03-30 10:11:20.989 TVRec(2): ClearFlags(NeedToStartRecorder,) -> RunMainLoop,RecorderRunning,RingBufferReady,
2009-03-30 10:11:20.990 MPEGRec(/dev/video1): StopEncoding
2009-03-30 10:11:20.996 MPEGRec(/dev/video1) Error: StopEncoding
                        eno: Invalid argument (22)
2009-03-30 10:11:20.999 MPEGRec(/dev/video1): SetStreamData(0x0) -- begin
2009-03-30 10:11:21.009 MPEGRec(/dev/video1): SetStreamData(0x0) -- end 0
2009-03-30 10:11:21.124 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PMT @61476376 + 848256
2009-03-30 10:11:21.126 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PMT @44512384 + 388784
2009-03-30 10:11:21.379 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PAT @61706864 + 424128
2009-03-30 10:11:21.381 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PAT @44744188 + 1519792
2009-03-30 10:11:21.598 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PMT @44965276 + 954288
2009-03-30 10:11:21.610 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PMT @61960476 + 1767200
2009-03-30 10:11:21.850 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PAT @62190776 + 1484448
2009-03-30 10:11:21.854 DVBRec(4:/dev/dvb/adapter0/frontend0): Wrote PAT @45198396 + 388784
2009-03-30 10:11:22.084 DVBRec(3:/dev/dvb/adapter0/frontend0): Wrote PMT @62456608 + 247408

comment:15 Changed 15 years ago by Janne Grunau

The problem is that the pvrusb2 driver doesn't support VIDIOC_ENCODER_CMD. I'll fix this.

comment:16 Changed 15 years ago by Janne Grunau

(In [20293]) Hopefully fixes pvrusb2 recording after [19989]

the pvrusb2 driver does not support VIDIOC_ENCODER_CMD i.e. StartEncoding? and StopEncoding? will always fail. corrects the incorrectly set requires_special_pause in [18143] and makes sure VIDIOC_ENCODER_CMD is only called if requires_special_pause is true Refs #5619, Refs #5866

comment:17 Changed 15 years ago by anonymous

Will these updates require the latest HDPVR driver?

comment:18 in reply to:  17 Changed 15 years ago by Janne Grunau

Ticket locked: set

Replying to anonymous:

Will these updates require the latest HDPVR driver?

trac is no message board, ask per email

Note: See TracTickets for help on using tickets.