Hi y'all,

because it was really bugging me, I just took a closer look at my
problem with swapped audio channels (see original message below).

My 1st surprise was, that I am not dealing with TS streams, as I
had thought (data source is DVB-T recordings made with VDR),
but actually with PS streams.

It seems to me (I am no MPEG-expert and don't normally do C++ ..)
like in psfile::psfile, the sequence of audio streams is merely
determined by the order in which they are seen in the file,
so whenever the 1st audio packet belongs to what would be considered
audio track 2 by other programs (id 0xc1 as I know now), trouble
starts.

There are certainly more elegant solutions, but the attached
crude little hack pretty much straightens it out for me ...

Regards,
                      Peter Daum


On 2007-12-28, Peter Daum wrote:
> For quite a while I occasionally got bitten by an annoying problem
> (I am not sure, whether the behavior of dvbcut actually changed;
> maybe I was just lucky before):
> 
> At least here (Berlin), many TV stations provide more than 1 audio
> stream. Usually, in addition to the "normal" sound (track 0, 192 kbit)
> there is a second track with a lower bitrate carrying a description
> for visually impaired people or the like). For "arte" for example, it
> looks like this:
> 
> [tcprobe] MPEG packetized elementary stream (PES)
> [tcprobe] summary for test.ts, (*) = not default, 0 = not detected
> import frame size: -g 720x576 [720x576]
>      aspect ratio: 16:9 (*)
>        frame rate: -f 25.000 [25.000] frc=3
>                    PTS=2961.4172, frame_time=40 ms, bitrate=15000 kbps
>       audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x50 [0x2000] (*)
>                    PTS=2960.7474, bitrate=192 kbps
>                    -D 16 --av_fine_ms 29 (frames & ms) [0] [0]
>       audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x50 [0x2000] (*)
>                    PTS=2960.7325, bitrate=128 kbps
>                    -D 17 --av_fine_ms 4 (frames & ms) [0] [0]
> 
> (I put a little data snippet on http://user.cs.tu-berlin.de/~gator/tmp/test.ts
> for illustration).
> 
> Every other program sees the tracks in this order (and uses track 0 by
> default).In dvbcut however, the tracks are sometimes swapped, so if I
> export just track 0, I actually end up with the second track. Furthermore,
> in some cases when I notice the problem in time and explicitly choose only
> track 1, I get (at least as far as my DVD player is concerned) 2 audio tracks,
> of which track 0 (which is played by default) is empty.
> 
> Any idea, what is the problem here and what to do about it?
> 
> Regards,
>                         Peter Daum

Index: src/psfile.cpp
===================================================================
--- src/psfile.cpp      (revision 120)
+++ src/psfile.cpp      (working copy)
@@ -111,6 +113,17 @@
     continue;
   }
 
+  // sort audio streams by id:
+  for (int i2=audiostreams-1; i2 > 0; i2--) {
+    for (int i1=audiostreams-2; i1 >= 0; i1--) {
+      int sid1=s[i1].id; int sid2=s[i2].id;
+      if (sid2 < sid1) {
+        streamnumber[sid1]=i2; streamnumber[sid2]=i1;
+       stream ts=s[i1]; s[i1]=s[i2]; s[i2]=ts;
+       fprintf(stderr, "psfile: swapped %d(%x) %d(%x)\n",i1,sid1,i2,sid2);
+      }
+    }
+  }
   initcodeccontexts(vid);
 }
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to