Hi, this is a followup on Andrew Harkman's original post about dvbcut not 
finding the AC3 audio track in some TS files.

I have similar files, recorded from the cable TV Comcast's Universal HD 
(UHD) channel. I was excited to see the patch in response to Andrew's 
report, so I tried the SVN version but it didn't work for me. 

Here're the program and tracks in the TS file I was trying to decode, 
obtained with the Project-X program 
(http://sourceforge.net/projects/project-x):

---

-> Input File 0:  'J:\rip\recorded\hunt-for-red-october (no pvas).ts' 
(8,837,374,844 bytes)
-> Filetype is TS (generic PES Container)
-> demux
-> Service ID 0x1
-> PMT 0x31 refers to these usable streams:
Video:
PID: 0x800
Audio:
n/a
Teletext:
n/a
Subpict.:
n/a

!> PID 0x0 (PAT) (0 #1) -> ignored
!> PID 0x31 (PMT) (188 #2) -> ignored
ok> PID 0x801 has PES-ID 0xBD (private stream 1) (24440 #131) 
ok> PID 0x800 has PES-ID 0xE0 (MPEG Video) (117312 #625) 

---

I included a 30MB sample from the beginning of this file at
http://cengique.2y.net/~cengiz/dvbcut-sample/hunt-for-red-october%20-%20sample.ts

You can see that the PMT contains the video PID but not the audio. 
However, Project-X correctly recognizes the "private stream 1" PID as AC3, 
as does MPlayer. This is where dvbcut fails. So here's my hack to fix it 
in dvbcut:

---
[EMAIL PROTECTED]:~/work/dvbcut/src$ svn diff tsfile.cpp
Index: tsfile.cpp
===================================================================
--- tsfile.cpp  (revision 138)
+++ tsfile.cpp  (working copy)
@@ -28,6 +28,7 @@
 
 tsfile::tsfile(inbuffer &b, int initial_offset) : mpgfile(b, 
initial_offset)
 {
+  int verbose=1;
   for(unsigned int i=0;i<8192;++i)
     streamnumber[i]=-1;
 
@@ -65,12 +66,19 @@
       continue;
 
     if ((sid&0xe0) == 0xc0) {  // mpeg audio stream
+      if(verbose) fprintf(stderr,"Found mpeg audio stream: SID=%x\n", 
sid);
       audios.push_back(std::pair<int,int>(sid,pid));
       apid[pid]=true;
     }
     else if (sid==0xbd) {      // private stream 1, possibly AC3 audio 
stream
       const uint8_t *payload=(const uint8_t*) p.payload();
       const uint16_t plen = p.payload_length();
+      if(verbose) fprintf(stderr,"Found private stream 1: SID=%x\n"
+                         "Payload len=%d, \n"
+                         "payload[8]=%x\n"
+                         "payload[9 + payload[8]]=%x\n"
+                         "payload[10 + payload[8]]=%x\n", sid, plen, 
payload[8], 
+                         payload[9 + payload[8]], payload[10 + 
payload[8]]);
       if (plen >= 9
        && plen >= 11 + payload[8]
        && payload[9 + payload[8]] == 0x0b
@@ -79,6 +87,11 @@
         apid[pid]=true;
       }
       else if (plen == 184
+              && payload[8] == 0x05) { // CG hack to recognize AC3 stream 
in UHD TS files
+       audios.push_back(std::pair<int,int>(sid,pid));
+       apid[pid]=true;
+      }
+      else if (plen == 184
        && payload[8] == 0x24
        && (payload[45] & 0xf0) == 0x10
        && payload[47] == 0x2c) {
---

Unfortunately my hack only stems from naively analyzing the few files I 
had with this problem. I'm not sure if it's acceptable for general use. I 
looked at how Porject-X does this, but the PES parser is so complicated 
that I couldn't locate a similar place in the code. The closest I got was 
in the checkPES and AC3Audio functions in 
src/net/sourceforge/dvb/projectx/parser/Scan.java. Maybe you can make 
sense of them.

Last but not least, thanks for providing dvbcut. Same with Andrew I depend 
on this tool to encode files that I was never able to keep audio sync 
after cutting commercials out. My previous routine for these files was 
using a Windows approach: cut with Mpg2Cut2, correct timings with 
Pvastrumento to get usable mpeg and AC3 streams. The audio will still get 
in and out of sync and pvastrumento is out of development and does not 
work for all files. Project-X recognizes my files, but as Andrew pointed 
out, drops GOPs because of missing frames. I discussed with the Project-X 
admins and apparently this is due to the weird use of B-frames in these 
files. Here's the forum where we discussed this: 
http://forum.dvbtechnics.info/showthread.php?p=27583#post27583

Yes, I know, too much information. So I'll stop now.

Best,
Cengiz Gunay
--
[EMAIL PROTECTED]  [EMAIL PROTECTED] (MSN)      [EMAIL PROTECTED]
Lab: +1-404-727-3565    Home/Cell: +1-678-559-8694
http://userwww.service.emory.edu/~cgunay/
IMs: ICQ# 21104923, [EMAIL PROTECTED],yahoo.com,Skype}
--

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to