Opened 13 years ago

Closed 12 years ago

#2439 closed patch (fixed)

Add support for ivtv-generated bilingual dual audio MPEG

Reported by: anonymous Owned by: Janne Grunau
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: medium Keywords:
Cc: szermatt@… Ticket locked: no

Description

The Hauppauge PVR250+ cards can record bilingual broadcasts and flag them properly as containing a DUAL audio stream (= a stereo stream with left for one language and right for another language)

This patch adds support for this feature to mythtv:

  1. switch the flag on in the recording profile
  2. play MPEG files with dual streams properly, as if they contained two independent streams

This only works with PRV250/350 cards when using the X output (not the PVR 350 output)

background, history and usage information: http://us.geocities.com/szermatt/bilingual.html#step2

The patch attached is meant both for the 0.20 branch and the head.

Attachments (6)

language_04_myth_0_20_patch.txt (16.2 KB) - added by szermatt@… 13 years ago.
language4_0.20.patch
2439-v1.patch (10.0 KB) - added by danielk 13 years ago.
Update patch (presentation portion)
2439-v2.patch (10.6 KB) - added by szermatt 13 years ago.
2439-v2.patch
2439-v3.patch (453 bytes) - added by szermatt 13 years ago.
2439-v3.patch
2439-v4.patch (476 bytes) - added by Adolfo R. Brandes <arbrandes@…> 12 years ago.
2439-ivtv-1.0.0.patch (467 bytes) - added by Adolfo R. Brandes <arbrandes@…> 12 years ago.
To make SAP work with ivtv 1.0.0 or greater.

Download all attachments as: .zip

Change History (29)

Changed 13 years ago by szermatt@…

language4_0.20.patch

comment:1 Changed 13 years ago by Stephane Zermatten <szermatt@…>

Cc: szermatt@… added

comment:2 Changed 13 years ago by Stuart Auchterlonie

The same thing is present in dvb streams in Norway/Finland?... They broadcast multiple stereo streams which have different languages in each channel.

Whether they are identified in the dvb tables in a way we can make use of them is a different question...

comment:3 Changed 13 years ago by danielk

Milestone: unknown0.21
Owner: changed from Isaac Richards to danielk

comment:4 Changed 13 years ago by danielk

(In [11377]) Refs #2439. Record side of PVR-x50 SAP support patch from szermatt at gmx dt net.

This allows you to record either the main audio, SAP audio, or both (with recent ivtv drivers).

There is another part of the patch which makes it easier to select the streams, but it's not quite ready yet.

Changed 13 years ago by danielk

Attachment: 2439-v1.patch added

Update patch (presentation portion)

comment:5 Changed 13 years ago by danielk

Resolution: invalid
Status: newclosed

The avformatdecoder portion of the patch as is does not work correctly when there are multiple streams some of which have the dual flag set. I've sent a more detailed problem report to Stephane via e-mail.

comment:6 Changed 13 years ago by szermatt

Resolution: invalid
Status: closedreopened

I fixed the patch so that it accepts several stereo/dual streams. It would work, but since I don't have mpeg files configured like that, I couldn't test it...

Changed 13 years ago by szermatt

Attachment: 2439-v2.patch added

2439-v2.patch

comment:7 Changed 13 years ago by danielk

Resolution: fixed
Status: reopenedclosed

(In [11493]) Fixes #2439. Applies UI portion of "dual audio" patch.

This splits up a dual audio stream in the audio stream selection code, so you can listen to only one language at a time without using the left/right mute hack.

comment:8 Changed 13 years ago by arbrandes@…

I hate to break this to you guys, but attachment:2439-v2.patch (and the subsequent revision [11493]) breaks SAP for me: the dual audio track is detected properly when available on a channel, but regardless of which one I choose (from the menu or hitting "+") I still hear both languages simultaneously. Reverting [11493] and applying attachment:2439-v1.patch fixes the problem.

Also, probably due to the fact that I'm running the head revision of video4linux and ivtv, in addition to reverting [11493] I had to hack a one-liner based on [11377] to prompt ivtv to mark the mpeg stream as dual when appropriate. It seems the new version of ivtv wants V4L2_TUNER_MODE_LANG1_LANG2 (as opposed to V4L2_TUNER_MODE_STEREO) in order to properly detect bilingual transmissions.

Should I try to open a new bug for these issues, or reopen this one?

Pertinent info on my setup:

  • Hauppauge PVR150
  • standard US-type cable (no multiple dual streams per channel, just the usual stereo/mono/sap).
  • Ubuntu Edgy 6.10 (2.6.17 kernel family)
  • video4linux head
  • ivtv head
  • mythtv head

comment:9 Changed 13 years ago by szermatt

V4L2_TUNER_MODE_LANG1_LANG2 is indeed what the newest versions of the driver want, yet the currently released versions will work only with MODE_STEREO (the meaning of both flags must have been switched at some point). http://v4l2spec.bytesex.org/spec/r9122.htm To fix that, myth will need to check the driver version... I'll have a look and see what can be done, but it's definitely going to be a pain.

For the other issue, it's really strange that you're having problems with an area that I would have said is common in v1 and v2, especially since we're practically using the same system. Which version of gcc/libstdc++ are you using ? Would you be willing to try out some alternative patches if I send you some ?

comment:10 Changed 13 years ago by szermatt

Resolution: fixed
Status: closedreopened

I could reproduce the problem. It is present in subversion, but not in the patch (that's why I hadn't seen it).

I'll attach another patch (one line, really) that should fix it.

You might also want to do: (>=, not <)

if (channel >= (uint)audioInfo->channels)

return

but since we're dealing with two channels here, by design, I prefer checking for 0 or 1.

Changed 13 years ago by szermatt

Attachment: 2439-v3.patch added

2439-v3.patch

comment:11 Changed 13 years ago by arbrandes@…

Cool, I'll test the new patch tonight (that's in a couple of hours; GMT-3).

(BTW, thank you for doing such an excellent job on the whole SAP deal. Regardless of these little tweaks at the end of the road, your work made my WAF increase at least an order of magnitude!)

comment:12 Changed 13 years ago by danielk

Resolution: fixed
Status: reopenedclosed

(In [11558]) Fixes #2439. Fix reversed logic in test used for MPEG dual audio support.

comment:13 Changed 12 years ago by arbrandes@…

Just as a general FYI, this feature is now broken in [14915] in conjunction with ivtv 1.0.0 (as included in kernel 2.6.22, or Ubuntu Gutsy). I'm not sure what is at fault, will investigate further.

comment:14 Changed 12 years ago by arbrandes@…

Ok, the dual flag of the mp2 stream is being set, so I'm guessing ivtv is not at fault. If I setup TV recording for "Dual", I hear both languages simultaneously. "Main" and "SAP" work as advertized. The problem is that I can't choose between languages using the "Next audio track" action when playing back or in Live TV.

comment:15 Changed 12 years ago by anonymous

The ivtv flags mythtv relies on for this feature has changed when itvt has been integrated into the kernel. The current implementation will definitely only work with ivtv version < 1.0.0

It's just a matter of setting different values... Unfortunately because of that this feature can work either with ivtv version >= 1.0.0 or with ivtv version < 1.0.0 (this could be chosen at compilation time, I guess), not both.

I still have an old kernel and I can't upgrade it because of other issues (with itvt tv out), so I can't really upgrade the patch to support ivtv 1.0

comment:16 Changed 12 years ago by arbrandes

Ok, that makes sense. As I noted in the comments about a year ago, I had to hack into mpegrecorder.cpp and replace V4L2_TUNER_MODE_STEREO with V4L2_TUNER_MODE_LANG1_LANG2 to make it work with the head revisions of ivtv. That one-liner is still in my checkout, but it is no longer sufficient. Any tips on where I should look?

comment:17 Changed 12 years ago by anonymous

Any tips on where I should look?

linux-2.6.23/include/media/v4l2-common.h http://www.linuxtv.org/downloads/video4linux/API/V4L2_API/spec-single/v4l2.html#VIDIOC-G-TUNER

Changed 12 years ago by Adolfo R. Brandes <arbrandes@…>

Attachment: 2439-v4.patch added

Changed 12 years ago by Adolfo R. Brandes <arbrandes@…>

Attachment: 2439-ivtv-1.0.0.patch added

To make SAP work with ivtv 1.0.0 or greater.

comment:18 Changed 12 years ago by Adolfo R. Brandes <arbrandes@…>

What happened was that [14800] resynced most of ffmpeg with upstream, and the initialization of avtcx->avcodec_dual_language got overlooked (the calling function, mpa_decode_header(), doesn't exist anymore as such). See attachment:2439-v4.patch, I tested it against [14915] and it works.

I also added attachment:2439-ivtv-1.0.0.patch, which is need if one wants this feature to work with the ivtv driver included in kernels 2.6.21 and up (a.k.a ivtv 1.0.0). It is not meant to be included in trunk, as what would be needed is a proper check for the current version of ivtv; it's more of a pointer in the right direction.

Should this ticket be reopened? After all, the SAP feature is undoubtedly broken after [14800], regardless of ivtv version.

comment:19 Changed 12 years ago by danielk

Resolution: fixed
Status: closedreopened

janne, can you look at this?

comment:20 Changed 12 years ago by Janne Grunau

Owner: changed from danielk to Janne Grunau
Status: reopenednew

comment:21 in reply to:  18 Changed 12 years ago by anonymous

Replying to Adolfo R. Brandes <arbrandes@gmail.com>: The patch works flawlessly. Thank you very much.

comment:22 Changed 12 years ago by Janne Grunau

(In [15556]) Fix ivtv dual language mode regression from [14800] ffmpeg sync

Refs #2439 Patch by Adolfo R. Brandes < arbrandes [a] gmail [p] com >

comment:23 Changed 12 years ago by Janne Grunau

Resolution: fixed
Status: newclosed

(In [15558]) Fixes #2439. Set correct audio mode for ivtv drivers using V4L2 MPEG encoding api

Note: See TracTickets for help on using tickets.