[vlc-devel] [FOUND] Fix for AAC decoding in Japanese DTV

Juha Jeronen juha.jeronen at jyu.fi
Thu Jul 28 20:23:42 CEST 2011


Hi all,

Below is the Japanese ReadMe for the patch, and my English translation
of it. Original supplied in case someone else (e.g. Cyril) also wants to
have a go at it.

There are at least two authors, but no author information.

-J


Original Japanese:

---8<---8<---8<---

v 0.02:     2011-04-02
    faad.c内部でデコードエラーが発生した場合
    デコーダを再初期化する処理を追加。
    これによりステレオ->DualMono->ステレオとモードが変化
    するパターンで無音にならないことを確認。
    vlc-1.1.8で確認。

    以下はオリジナル作成者の方のReadMe
************************************************************
* VLC パッチ for デジタル放送 音声チャンネル構成切り替え対応
************************************************************

v 0.01:     2010-01-23 JST




概略
========================================================
生TSを取り出せるチューナー各種でデジタル放送を視聴・録画する
とき,音声(MPEG-2 AAC)のチャンネル構成が切り替わるタイミングで
再生・トランスコードを行うソフトウェアが落ちる現象が各所で
報告されており,鬼門となっています.

本パッチはVLC(video LAN client)を音声チャネル構成切り替えに
対応させるためのものです.

VLCは再生アプリケーションとして機能だけでなく,リアルタイムに
トランスコードを行いながらストリーミング送信も行えるのが
持ち味です.


なお,本パッチを適用なされる前に,この下に書いた既知の問題点,
および現状での制限事項をお読み下さい.


本パッチが,皆さんのLinuxデジタル放送ライフがより良くなるための
一助になれば幸いです.




既知の問題点
========================================================
・頻繁にチャンネル構成が変わる(ステレオ<->モノラル)と
  映像と音のズレが目で見て分かる(声と口の動きがズレる)
  程度まで酷くなる.




既知の制限事項
========================================================
・デュアルモノラルの場合,2chのペアのうちの一方が主音声,
  もう一方が副音声,として出力される.
  ↓
  再生アプリケーションの方で,左側だけのモノラル再生に
  切り替える,などして対処してほしい.




動作確認内容
========================================================
● 音声チャネル構成切り替え
  下記チャネル構成間の切り替え (総当たりではない)
  - ステレオ
    これが一番多い
  (- ステレオ バイリンガル : 不明)
    (2つのPIDにそれぞれステレオで日本語と外国語)
  - 5.1chサラウンド
    時々放送される.番組表に「5.1chサラウンド」と
    明記されることが多い.
  - モノラル
    NHK BS-1で定時放送される「BSニュース」など
  - デュアルモノラル
    二ヶ国語放送でこの構成が結構ある.
    NHK総合の「ニュース7」(月-金 19:00~),
    NHK BS-1の海外ニュース番組,など.

  NHK BS-1の海外ニュース番組では,モノラルとデュアルモノラルが
  番組中に何度も切り替わることがある.
  (海外からのニュース映像とスタジオ撮り部分との行き来)


● 機能
  - 再生
    NHK BS-1/BS-2の生TSキャプチャを使って,
    ステレオ,モノラル,デュアルモノラルについて.
  - トランスコード,ストリーム出力
    ステレオ,モノラル,デュアルモノラル,5.1ch をひと通り

  5.1chの再生は試してない.(再生するための機材がないので)




動作確認環境
========================================================
・kernel-2.6.31.11
・Fedora 12 / x86
・VLC gitソースコード 16cb266.....
・faad2-2.7




パッチ充て~ビルド
========================================================
  先にfaadのインストールを済ませておくこと.

  1) gitソースコード取得
    git clone git://git.videolan.org/vlc.git
  2) リビジョンを合わせる
    git checkout 16cb266
  3) パッチを充てる
    cd vlc
    patch -p1 < vlc_patch.txt
  4) ビルド
    ./configure
    make
  5) インストール
    sudo make install




VLCを使う上でのtips
========================================================

サービス番号を指定して取り出す
---------------------------------------------------
  現状のNHK BS-1/BS-2は1つの周波数にSDサイズ映像で
  BS-1とBS-2の両方の放送が送信されているので,一方だけを
  取り出すために使う.
  また,地上デジタル放送でワンセグ放送部分を除いて本放送だけを
  取り出すのにも使う.

・1つだけ
  --program <サービスID>
  例) NHK BS-1を取り出す場合
      --program 101

・複数
  --programs <サービスIDをカンマ区切りで列挙>
  例) NHK BS-1/BS-2 を取り出す場合
      --programs 101,102


PIDを指定して取り出す (ストリーム出力時)
---------------------------------------------------
  NHK BS-1/BS-2では主放送の他に降雨対応として低解像度・低ビットレートの
  映像が同時に送信されてくる.
  その映像を取り除いた状態で出力させるために使う.

  ストリーム出力のサブコマンド"duplicate"のオプションで
  「select="es=xxx,es=yyy,es=zzz"」という書式で,
  取り出したいPIDを列挙しする.
  例) PID = 256,272 を取り出す場合 (NHK BS-1の映像とプライマリ音声)
  --sout '#duplicate{dst=std{access=file,dsts=/tmp/temp1.mpg},select="es=256,es=272"}'


TS出力時のPIDを固定する
---------------------------------------------------
  通常ステレオ <-> 5.1chサラウンド の構成切り替えを含むストリームを
  トランスコードに通す場合,そのままだと,通常ステレオと5.1chサラウンドが
  別々のPIDで出力されるようである.
  (詳細は調べていない)

  例えば,
     ---------|--------------------------------|-------
    2ch stereo           5.1ch surround         2ch stereo
    PID=69               PID=70                 PID=69
  ということ.

  この状態で録画したものを再生する場合,VLCはその時点で存在する
  オーディオのPIDを探してよきに計らってくれるが,例えば素のmplayerでは
  先に2ch stereoのオーディオPID=69を見つけてそれを再生し始めるが,
  5.1chサラウンドの区間ではPIDが異なるため音が鳴らない.

  このようにチャネル構成ごとに別々のPIDに分けて出力しないように
  固定させるオプションがある.
  音声: --sout-ts-pid-audio <PID>
  (映像: --sout-ts-pid-video <PID>)


ログ取り
---------------------------------------------------
  不具合の調査のときにログ取りを行える.
  特に,"-d"をつけてデーモン扱いでトランスコード・ストリーム出力を
  行う場合には標準出力を持たないので,ログファイルに書き出さないと
  何のエラーで不具合が出ているのか分からない.

  --extraintf logger --logfile <filename> [--verbose <0,1,2>]

  "--extraintf logger"を指定しないとログファイル出力機能は
  有効にならない.
  単に"--logfile <filename>"だけ付けてもログはファイルに
  書き出されない.

  "--verbose <0,1,2>" はログファイルそのものとは関係ないが
  ログに出力する冗長度を指定するものである.
  0: エラーのみ
  1: エラー,ワーニング
  2: エラー,ワーニング, デバッグ
  デフォルトは0になっている.


*********************************************** ここまで

---8<---8<---8<---


English translation:
---8<---8<---8<---

===
v 0.02:     2011-04-02

faad.c: added restarting of the decoder in case of a decoder error. This
fixes a bug where switching modes in the pattern "stereo -> DualMono ->
stereo" caused the sound to mute itself. Confirmed [i.e. tested?] in
vlc-1.1.8.

Below is the ReadMe of the original author.


=============================================================================
VLC patch for digital broadcasting; support for switching between mono/stereo
=============================================================================

v 0.01:     2010-01-23 JST


Summary
=======

When watching digital broadcasts on a digital tuner that outputs live TS
streams, there have been reports that the software crashes when the
stream switches audio channels composition* while in playback or
transcoding.

* Here "audio channels composition" means mono, dual mono, stereo, etc.

This patch for VLC makes it work with such switching.

VLC has the special characteristic that it's not just a player, but it
can also transcode in realtime and stream the result.

Before applying the patch, please observe the known issues and
limitations explained below.

I hope this patch helps to make everyone's life easier with digital
broadcasts in Linux.


Known issues
============

- If the audio channels composition (stereo<->mono) switches frequently,
artefacts appear in the video and audio (lip sync will be lost). The
more often the switch happens, the worse this issue becomes.


Known limitations
=================

- In the case of dual mono, i.e. a 2-channel pair, one should be played
back, while the other is available as a supplementary audio channel.
-> On the player application side, this switches to mono playback of the
left channel only. It would be nice to fix this.


How it was tested
=================

* Audio switch
 Switched between the following audio channel compositions (not round-robin)
- Stereo
  This is the most common
(- stereo bilingual: unknown)
  (Two different PIDs, stereo audio, one of which Japanese, one foreign
language)
- 5.1 channel surround
  Sometimes used in broadcasts. The text 「5.1chサラウンド」 ("5.1 ch
surround") will often be displayed during the broadcast when this is the
case.
- Mono
  The 「BSニュース」 ("BS News") on NHK BS-1, etc.
- Dual mono
  Often used for dual-language broadcasts.
  The 「ニュース7」 ("News 7") on NHK (Mon-Fri 19:00-)
  Foreign news on NHK BS-1, etc.

During the foreign news on NHK BS-1, the broadcast often switches
between mono and dual mono many times over.
(When switching between footage filmed abroad and the news studio.)


* Functionality
- Playback
  Using live TS capture of NHK BS-1/BS-2,
  stereo, mono, dual mono
- Transcoding, stream output
  stereo, mono, dual mono, 5.1; each briefly

5.1 playback has not been tested (I don't have the required hardware)


Testing environment used
========================

- kernel-2.6.31.11
- Fedora 12 / x6
- VLC git source code, commit 16cb266...
- faad2-2.7


Applying the patch and building
===============================

First, make sure that faad is installed.

1) Get the sources from git
git clone git://git.videolan.org/vlc.git

2) Choose the correct revision
git checkout 16cb266

3) Apply the patch
cd vlc
patch -p1 < vlc_patch.txt

4) Build
./configure
make

5) Install
sudo make install


Usage tips
==========


Selecting by service number
===========================

In current NHK BS-1/BS-2 broadcasts, SD size video is broadcast on a
single frequency for both BS-1 and BS-2, so this can be used to pick
only one of them.

Furthermore, in terrestrial digital broadcasts this can be used e.g. for
picking just the main program, omitting other segments.

* just one
--program <service ID>
Example) To get just NHK BS-1:
  --program 101

* several
--programs <comma-separated list of service IDs>
Example) To get both NHK BS-1 and BS-2:
  --programs 101,102


Selecting by PID (for stream output)
====================================

In addition to the main broadcast, NHK BS-1/BS-2 send also a
low-resolution/low-bitrate video at the same time to cope with rain [?].
The additional stream can be omitted from stream output by using this
feature.

Set the PID you want to choose in the options for the "duplicate"
subcommand of stream output, as "select="es=xxx,es=yyy,es=zzz".
Example) If you want to choose PIDs 256 and 272 (NHK BS-1 video and
primary audio), use:
--sout
'#duplicate{dst=std{access=file,dsts=/tmp/temp1.mpg},select="es=256,es=272"}'


Fixing a single PID for TS output
=================================

When outputting a stream which switches between stereo<->5.1, if this
stream is passed to the transcoder as-is, each audio stream gets a
different PID.
(I haven't investigated the details)

For example, like this:
     ---------|--------------------------------|-------
    2ch stereo           5.1ch surround         2ch stereo
    PID=69               PID=70                 PID=69

When a stream that has been recorded like this is played back, VLC
searches for the PID of the audio that exists during each segment and
works fine. However, e.g. MPlayer locks on to the initial 2-channel
audio PID=69, and when it arrives at the 5.1-channel section, the sound
does not play back at all because the PID of the audio in that section
is different.

There is an option that can be used to fix the PID to a single value,
avoiding this problem:

Audio: --sout-ts-pid-audio <PID>
(Video: --sout-ts-pid-video <PID>)


Logging
=======

For troubleshooting, it is possible to use the logger.
Note that during transcoding or streaming as a daemon, a log file must
be used for the "-d" switch, because in this case stdout will not be
accessible and it will not be possible to see what the error was.

--extraintf logger --logfile <filename> [--verbose <0,1,2>]

Note that the "--extraintf logger" switch is needed to enable logging to
a file. Specifying just "--logfile <filename>" alone is not enough to
produce a log file.

The "--verbose <0,1,2>" is not related to the logfile itself, but it
controls the verbosity of the messages output to the log.
0: Errors only
1: Errors, warnings
2: Errors, warnings, debug
The default is 0.

************************************* [End quote / EOF]

---8<---8<---8<---



On 07/27/2011 11:56 AM, Jean-Baptiste Kempf wrote:
> On Wed, Jul 27, 2011 at 10:54:03AM +0200, Rémi Denis-Courmont wrote :
>> Has no copyright and authoring informations so cannot be used?
> I am trying to solve that point.
> Help from a native japanese speaker would help quite a bit, to be
> honest.
>
> Best Regards,
>




More information about the vlc-devel mailing list