MPEG-2 Transport Stream Support

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Cavalicious
Moderator
Posts: 1804
Joined: Mon Mar 26, 2007 12:07 am

Post by Cavalicious »

van wrote:I bet the title = 0 instead of 1 was just an oversight - most of the stuff in the title struct is dvd specific & isn't initialized for transport streams. The following patch makes .ts, .mpg or .vob streams say title 1.

Code: Select all

Index: libhb/stream.c
===================================================================
--- libhb/stream.c      (revision 1043)
+++ libhb/stream.c      (working copy)
@@ -206,6 +206,7 @@
 {
     // 'Barebones Title'
     hb_title_t *aTitle = hb_title_init( stream->path, 0 );
+    aTitle->index = 1;
 
        // Copy part of the stream path to the title name
        char *sep = strrchr(stream->path, '/');
Thank You
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Post by van »

jbrjake,

That PMT dump is certainly interesting - I've never seen one like it. It violates the ATSC standard (A/53 part 3). There's no way to tell from just the PMT if it follows ISO 13818-1 but, if it does, the audio is very non-standard. Does VLC play this ok? If so I can see how its TS decoder figures it out.

I suspect PID 34 (stream type 6) isn't really audio - awk's code more-or-less ignores the PMT stream description and gets the audio type from the elementary stream header. This should be very robust. From the errors you report the PID 34 stream doesn't have an audio AC3 PES header. You could check this by doing "atscut -v1 foo.ts | head -40" which dumps the raw TS packet headers:

Code: Select all

PKT #      449 PID 0041 SC 0 AF 1 CC 0  START YES 00 00 01 E0 00 00 85 80 
PKT #      461 PID 0045 SC 0 AF 1 CC 6  START YES 00 00 01 BD 0A 08 87 80 
The 8 hex bytes at the end of the dump are the first 8 bytes of TS payload (excluding the 4 byte TS header & any adaptation bytes). Elementary streams will start with 00 00 01 followed by a E0 for video & BD for audio. So the above is a packet from a video ES followed by a packet from an audio ES.

In your stream it's possible the audio is included with the video under PID 31. This violates ISO 13818-1 (which says that the PID-PES mapping has to be 1-1) but will work with some decoders. But it would take some rework to handle this in stream.c. If this is the case you'd see it in the TS header dump since PID 31 would have payloads starting with both "00 00 01 E0" and "00 00 01 BD".

It's also possible that the audio stream is defined somewhere other than the PMT, e.g., the PSIP VCT. You could look at this by doing "atscut -a2 foo.ts | head -50" which gives output that looks something like:

Code: Select all

  VC01 [ENCORE ] 9.2 Modulation 4 TSID 017F Program ATSC DTV 9.2
   ETM Location 0 Access Control 0 Hidden 0 Hide Guide 1
   Service Type 2 Source 2 Program 2 DLen 1D
   TVCT DESCRIPTORS: DLen 1D
     VCT Tag A1 DLen 1B Service Location: PCR PID 0041, num ES 04
      Stream Type (81) A/52 Audio ES PID 0043 [eng]
      Stream Type (02) MPEG Video ES PID 0041 []
      Stream Type (81) A/52 Audio ES PID 0044 [fre]
      Stream Type (81) A/52 Audio ES PID 0045 [spa]
(there's a VCT entry for each virtual channel on the multiplex, I only included one of them above). If this is happening the TS pkt dump should show packets from the real audio stream. This would also violate ISO 13818-1 but would be easier to fix in stream.c - the missing PSIP code would just have to be added.

Anyway, sorry I can't offer a patch for this. If it's easy to put some portion of the stream (20-30MB should be enough) where I can grab it I'll be glad to try & make it work. I'm travelling all this coming week & will have limitted internet connectivity but some chunks of free time on the long airplane rides.

- Van
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

van wrote:That PMT dump is certainly interesting - I've never seen one like it. It violates the ATSC standard (A/53 part 3). There's no way to tell from just the PMT if it follows ISO 13818-1 but, if it does, the audio is very non-standard.
Hehe, for some reason I'm not surprised that BrightHouse Networks or the CW network would manage to break spec ;>
Does VLC play this ok?
Yep, passes through the AC3 to my amp and everything.
You could check this by doing "atscut -v1 foo.ts | head -40" which dumps the raw TS packet headers

Code: Select all

PKT #     9746 PID 0031 SC 0 AF 1 CC C  START YES 00 00 01 E0 00 00 85 80 
PKT #     9772 PID 0034 SC 0 AF 1 CC 0  START YES 00 00 01 BD 18 08 85 80 
Looks like it's correctly marking them...
It's also possible that the audio stream is defined somewhere other than the PMT, e.g., the PSIP VCT. You could look at this by doing "atscut -a2 foo.ts | head -50"
I don't think I'm getting PSIP info:

Code: Select all

Khaybet:~/Desktop/atscap-1.1rc9g jon$ ./atscut -a2 /Volumes/Walter/clip.ts | head -50

atscut 1.1.0 Copyright (C) 2004-2007 inkling@nop.org
Released under the GNU General Public License Version 2
ATSC timebase Sun Jan  6 00:00:00 1980: unix diff 315982800 TZ diff -18000
Input file name /Volumes/Walter/clip.ts
Input size 32,557,088 bytes, 173,176 packets
Testing packets in /Volumes/Walter/clip.ts

EOF


Packets 173,166, PES packet 0, Errors 0
Transport Errors: 0: Sync 0 Scrambled 0 Continuity 0

MPEG PIDs by Table Type:
MPEG---- -----PAT -----CAT -----PMT -----VID -----AUD ----NULL
  173166       28        0       28        0        0        0

MPEG PID counts:
    0000 #       28    0031 #   169556    0034 #     3526
    0100 #       28    0101 #       28
MPEG PID total:   173166

 IN    32555208 bytes
OUT           0 bytes

processed 32,555,208 bytes in 1.00 seconds, 32.56 MB/s
If it's easy to put some portion of the stream (20-30MB should be enough) where I can grab it I'll be glad to try & make it work.
31 meg clip:
http://www.mediafire.com/?fgzizlyqo0d
(warning: if viewed by a young child, it could cause him to develop a deep and abiding fear of the elderly and large knives)

Thanks for your help, van.
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Post by van »

Got it. I think there's a better fix than this but this might get you going:

Code: Select all

Index: libhb/stream.c
===================================================================
--- libhb/stream.c      (revision 1043)
+++ libhb/stream.c      (working copy)
@@ -206,6 +206,7 @@
 {
     // 'Barebones Title'
     hb_title_t *aTitle = hb_title_init( stream->path, 0 );
+    aTitle->index = 1;
 
        // Copy part of the stream path to the title name
        char *sep = strrchr(stream->path, '/');
@@ -790,7 +791,7 @@
        if (pos == 188)
                pos = 0;                // failed to find anything!!!!!?
 
-       fseek(f, start+pos, SEEK_SET);
+       fseeko(f, start+pos, SEEK_SET);
 
        return pos;
 }
@@ -1739,8 +1740,8 @@
                // Check sync byte
                if ((buf[0] != 0x47) && (buf[0] != 0x72) && (buf[0] != 0x29))
                {
-//                     __int64 pos = ftell64(fin);
-                       hb_log("hb_ts_stream_decode - Bad transport packet (no sync byte 0x47)!");
+                       off_t pos = ftello(stream->file_handle);
+                       hb_log("hb_ts_stream_decode - no sync byte 0x47 @ %ll",  pos);
                        for (i=0; i < stream->ts_number_video_pids + stream->ts_number_audio_pids; i++)
                        {
                //      stream->ts_skipbad[kAudioStream] = stream->ts_skipbad[kVideoStream] = 1;
@@ -1968,18 +1969,23 @@
                        {
                                // Curstream is a zero based index of streams and includes both video and audio streams, so we must subtract the numver of video streams
                                // from the indes value used here since ts_audio_stream_type is indexed only by audio streams.
-                               if ((stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids] == 0x04) || (stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids] == 0x81))
-                               {
-                                       write_ac3 = hb_ts_handle_ac3_audio(stream, curstream, buf, adapt_len);
+                switch (stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids])
+                {
+                    case 0x04:
+                    case 0x06:
+                    case 0x81:
+                        write_ac3 = hb_ts_handle_ac3_audio(stream, curstream,
+                                                           buf, adapt_len);
+                        break;
+
+                    case 0x03:
+                        hb_ts_handle_mpeg_audio(stream, curstream, buf, adapt_len);
+                        break;
+
+                    default:
+                        hb_log("hb_ts_stream_decode - Unknown Audio Stream type ! 0x%x (%d)", stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids], stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids]);
+                        break;
                                }
-                               else if (stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids] == 0x03)
-                               {
-                                       hb_ts_handle_mpeg_audio(stream, curstream, buf, adapt_len);
-                               }
-                               else
-                               {
-                                       hb_log("hb_ts_stream_decode - Unknown Audio Stream type ! 0x%x (%d)", stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids], stream->ts_audio_stream_type[curstream - stream->ts_number_video_pids]);
-                               }
                        }
 
                if (generate_output_data(stream, write_ac3, curstream, pid) != 0)
(this has my two previous changes plus the new change to take stream type 6 as audio. there's also a small change to the 'no sync byte' error message that I used to find the fseek problem - once you see where it is in the file it's obvious that the seek was messed up)

- Van
Cavalicious
Moderator
Posts: 1804
Joined: Mon Mar 26, 2007 12:07 am

Post by Cavalicious »

jbrjake wrote:(warning: if viewed by a young child, it could cause him to develop a deep and abiding fear of the elderly and large knives)
Great...now I have to cancel my Grandmother's invitation to Thanksgiving after watching that...
awk
Enlightened
Posts: 109
Joined: Sat Mar 31, 2007 11:55 pm

Post by awk »

These all look like good changes - thanks for taking care of the problems Van.

I've some distant memory of having issues building this code with other variants of the ftell/fseek etc functions on Windows - especially the 64 bit versions.

Has anyone tried this there ? It might need some conditional compilation changes to get it to build on other platforms.
evilpenguin
Posts: 21
Joined: Fri Oct 12, 2007 2:44 am

Post by evilpenguin »

evilpenguin wrote:Hi awk,

I've been following this thread and eagerly awaiting the next release so I could start encoding my HDhomerun HDTV streams w/handbrake, but I ran into a little snag. I'm using SageTV with my HDhomerun, and apparently Sage is recording the video through a graph which converts it from TS->PS on the fly. Then when I try and run that PS file though 9.1 I'm getting...

Code: Select all

[19:52:14] hb_init: checking cpu count
[19:52:14] hb_init: starting libhb thread
[19:52:14] thread ed2338 started ("libhb")
HandBrake 0.9.1 (2007100800) - http://handbrake.m0k.org/
4 CPUs detected
Opening D:\Videos\WindsorCastleARoyalYear-TheBanquet-718824-0.mpg...
[19:52:14] hb_scan: path=D:\Videos\WindsorCastleARoyalYear-TheBanquet-718824-0.mpg, title_index=1
[19:52:14] thread ed24c0 started ("scan")
[19:52:14] scan: trying to open with libdvdread
ERROR: dvd: DVDOpen failed (D:\Videos\WindsorCastleARoyalYear-TheBanquet-718824-0.mpg)[19:52:14] scan: trying to open as MPEG-2 Stream
[19:52:14] scan: decoding previews for title 0
[19:52:14] scan: preview 1
Scanning title 0...
[19:52:15] Warning: Could not read data for preview 1, skipped
[19:52:15] scan: preview 2
Scanning title 0...
[19:52:15] scan: preview 3
[19:52:15] scan: preview 4
Scanning title 0...
[19:52:15] scan: preview 5
[19:52:15] scan: preview 6
Scanning title 0...
[19:52:16] scan: preview 7
[19:52:16] scan: preview 8
Scanning title 0...
[19:52:16] scan: preview 9
[19:52:16] scan: preview 10
[19:52:16] scan: 1280x720, 59.940 fps, autocrop = 0/0/12/10
[19:52:16] hb_stream_update_audio: id=80bd, lang=Unknown (AC3) (2.0 ch), 3cc=und, rate = 0, bitrate = 0, flags = 0x0 (0)
[19:52:16] scan: removing audio with codec of 0x800 because of no bitrate
[19:52:16] thread ed24c0 exited ("scan")
[19:52:16] thread ed24c0 joined ("scan")
[19:52:16] libhb: scan thread found 0 valid title(s)
No title found.
[19:52:16] thread ed2338 exited ("libhb")
[19:52:16] thread ed2338 joined ("libhb")
HandBrake has exited.
I have a small video clip (8 mb) if you'd like to take a look.

Thanks,
Scott
While you guys are in the code anyway (;)), I was wondering if you could take a look at the quoted issue from above. Not sure if its related to and/or fixed by any of the stuff you're doing though.

Here's a link to an 8 mb sample...

http://perl2dvd.svn.sourceforge.net/vie ... 8824-0.mpg

MediaInfo:

Code: Select all

General #0
Complete name        :C:\WindsorCastleARoyalYear-TheBanquet-718824-0.mpeg
Format               : MPEG-2 Program
Format/Family        : MPEG-2
File size            : 8.44 MiB
PlayTime             : 7s 882ms
Bit rate             : 8984 Kbps

Video #0
Codec                : MPEG-2 Video
Codec profile        : Main@High
Codec settings/Matri : Custom
PlayTime             : 6s 717ms
Bit rate             : 39 Mbps
Bit rate mode        : CBR
Width                : 1280 pixels
Height               : 720 pixels
Aspect ratio         : 16/9
Frame rate           : 59.940 fps
Chroma               : 4:2:0
Interlacement        : Progressive
Bits/(Pixel*Frame)   : 0.703

Audio #0
Codec                : AC3
PlayTime             : 7s 882ms
Bit rate             : 384 Kbps
Bit rate mode        : CBR
Channel(s)           : 6 channels
Sampling rate        : 48 KHz
Video0 delay         : 1193h
ChannelPositions     : Front: L C R, Rear: L R, Subwoofer
FFmpeg reported info:

Code: Select all

Input #0, mpeg, from 'WindsorCastleARoyalYear-TheBanquet-718824-0.mpeg':
  Duration: 00:00:07.7, start: 0.009811, bitrate: 9098 kb/s
  Stream #0.0[0x81]: Audio: ac3, 48000 Hz, 5:1, 384 kb/s
  Stream #0.1[0x1e0]: Video: mpeg2video, yuv420p, 1280x720, AR: 16:9, progressive, 38810 kb/s, 59.94 fps(r)
-Scott
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Post by van »

awk wrote:I've some distant memory of having issues building this code with other variants of the ftell/fseek etc functions on Windows - especially the 64 bit versions.
Good point. fseeko/ftello are in IEEE Std 1003.1-2001 (POSIX.1) but Microsoft doesn't implement them despite claiming to be POSIX compatible. Cygwin has them but I don't know if Handbrake on Windows always uses cygwin (I view Windows as a highly contagious, nearly always fatal disease & stay as far from it as possible). This is what ffmpeg does for non-cygwin windows compiles:

Code: Select all

#ifdef __MINGW32__
#define fseeko(x,y,z)  fseeko64(x,y,z)
#define ftello(x)      ftello64(x)
#endif
and this is the relevant thread on ffmpeg-devel: http://lists.mplayerhq.hu/pipermail/ffm ... 09362.htmlI could add this to libhb/stream.c but don't have any way to test it.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

van wrote:Cygwin has them but I don't know if Handbrake on Windows always uses cygwin
Thankfully, it does. I'll tell sr55 to check this thread out.
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Post by s55 »

the fseeko line compiles just fine. It's already used in about a dozen other places in that file. Testing that 1 fseek change works fine.
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

I've found a transport stream (.eyetv file) that doesn't work once again. It doesn't work as .ts file either. It's been recorded with the EyeTV 250.

Code: Select all

Process:         HandBrake [19862]
Path:            /Users/rouven/OpenSource/HandBrake/corebackup/HandBrake.app/Contents/MacOS/HandBrake
Identifier:      org.m0k.handbrake
Version:         0.9.1 (2007100800)
Code Type:       X86 (Native)
Parent Process:  launchd [190]

Date/Time:       2008-01-18 15:58:19.332 +0100
OS Version:      Mac OS X 10.5.1 (9B18)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000011b2d000
Crashed Thread:  17

Thread 0:
0   libSystem.B.dylib             	0x92edf8e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x92ee70dc mach_msg + 72
2   com.apple.CoreFoundation      	0x963860fe CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x96386d38 CFRunLoopRunInMode + 88
4   com.apple.HIToolbox           	0x953848a4 RunCurrentEventLoopInMode + 283
5   com.apple.HIToolbox           	0x953846bd ReceiveNextEventCommon + 374
6   com.apple.HIToolbox           	0x95384531 BlockUntilNextEventMatchingListInMode + 106
7   com.apple.AppKit              	0x9356fd5b _DPSNextEvent + 657
8   com.apple.AppKit              	0x9356f6a0 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
9   com.apple.AppKit              	0x935686d1 -[NSApplication run] + 795
10  com.apple.AppKit              	0x935359ba NSApplicationMain + 574
11  org.m0k.handbrake             	0x00002316 start + 54

Thread 1:
0   libSystem.B.dylib             	0x92edfa06 mach_wait_until + 10
1   libSystem.B.dylib             	0x92f56abf nanosleep + 314
2   libSystem.B.dylib             	0x92f5697f usleep + 61
3   org.m0k.handbrake             	0x0002d0c0 thread_func + 355 (hb.c:1130)
4   org.m0k.handbrake             	0x00030b0a hb_thread_func + 80 (ports.c:288)
5   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
6   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 2:
0   libSystem.B.dylib             	0x92edf8e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x92ee70dc mach_msg + 72
2   com.apple.CoreFoundation      	0x963860fe CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x96386d38 CFRunLoopRunInMode + 88
4   com.apple.Foundation          	0x94714560 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 320
5   com.apple.Foundation          	0x946b104d -[NSThread main] + 45
6   com.apple.Foundation          	0x946b0bf4 __NSThread__main__ + 308
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 3:
0   libSystem.B.dylib             	0x92f2ef5a select$DARWIN_EXTSN + 10
1   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
2   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 4:
0   libSystem.B.dylib             	0x92edf8e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x92ee70dc mach_msg + 72
2   com.apple.CoreFoundation      	0x963860fe CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x96386d38 CFRunLoopRunInMode + 88
4   com.apple.CFNetwork           	0x917787ba CFURLCacheWorkerThread(void*) + 396
5   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
6   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 5:
0   libSystem.B.dylib             	0x92ee6ace __semwait_signal + 10
1   libSystem.B.dylib             	0x92f10ced pthread_cond_wait$UNIX2003 + 73
2   libGLProgrammability.dylib    	0x92281f32 glvmDoWork + 162
3   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
4   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 6:
0   libSystem.B.dylib             	0x92ee6ace __semwait_signal + 10
1   libSystem.B.dylib             	0x92f10ced pthread_cond_wait$UNIX2003 + 73
2   com.apple.QuartzCore          	0x91ebd161 fe_fragment_thread + 54
3   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
4   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 7:
0   libSystem.B.dylib             	0x92edf8e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x92ee70dc mach_msg + 72
2   com.apple.CoreFoundation      	0x963860fe CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x96386d94 CFRunLoopRun + 84
4   com.apple.DesktopServices     	0x921acb0f TSystemNotificationTask::SystemNotificationTaskProc(void*) + 123
5   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
6   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
7   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 8:
0   libSystem.B.dylib             	0x92edf8e6 mach_msg_trap + 10
1   libSystem.B.dylib             	0x92ee70dc mach_msg + 72
2   com.apple.CoreFoundation      	0x963860fe CFRunLoopRunSpecific + 1806
3   com.apple.CoreFoundation      	0x96386d94 CFRunLoopRun + 84
4   com.apple.DesktopServices     	0x921acc88 TFSEventsNotificationTask::FSEventsNotificationTaskProc(void*) + 216
5   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
6   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
7   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 9:
0   libSystem.B.dylib             	0x92ee6ace __semwait_signal + 10
1   libSystem.B.dylib             	0x92f10ced pthread_cond_wait$UNIX2003 + 73
2   ...ple.CoreServices.CarbonCore	0x93d752a7 TSWaitOnCondition + 126
3   ...ple.CoreServices.CarbonCore	0x93d54226 TSWaitOnConditionTimedRelative + 202
4   ...ple.CoreServices.CarbonCore	0x93d74f24 MPWaitOnQueue + 208
5   com.apple.DesktopServices     	0x921b8db8 TNodeSyncTask::SyncTaskProc(void*) + 72
6   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 10:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   ...ple.CoreServices.CarbonCore	0x93d54252 TSWaitOnConditionTimedRelative + 246
4   ...ple.CoreServices.CarbonCore	0x93d74f24 MPWaitOnQueue + 208
5   com.apple.DesktopServices     	0x921bb224 TFolderSizeTask::FolderSizeTaskProc(void*) + 104
6   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 11:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   ...ple.CoreServices.CarbonCore	0x93d54252 TSWaitOnConditionTimedRelative + 246
4   ...ple.CoreServices.CarbonCore	0x93d74f24 MPWaitOnQueue + 208
5   com.apple.DesktopServices     	0x921c15b3 TPropertyTask::PropertyTaskProc(void*) + 99
6   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 12:
0   libSystem.B.dylib             	0x92f0f8e6 kevent + 10
1   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
2   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 13:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   ...ple.CoreServices.CarbonCore	0x93d54252 TSWaitOnConditionTimedRelative + 246
4   ...ple.CoreServices.CarbonCore	0x93d74f24 MPWaitOnQueue + 208
5   com.apple.DesktopServices     	0x921bb224 TFolderSizeTask::FolderSizeTaskProc(void*) + 104
6   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 14:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   com.apple.Foundation          	0x946f6f9c -[NSCondition waitUntilDate:] + 236
4   com.apple.Foundation          	0x946f6db0 -[NSConditionLock lockWhenCondition:beforeDate:] + 144
5   com.apple.Foundation          	0x946f6d15 -[NSConditionLock lockWhenCondition:] + 69
6   com.apple.AppKit              	0x935d5c19 -[NSUIHeartBeat _heartBeatThread:] + 746
7   com.apple.Foundation          	0x946b104d -[NSThread main] + 45
8   com.apple.Foundation          	0x946b0bf4 __NSThread__main__ + 308
9   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
10  libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 15:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   ...ple.CoreServices.CarbonCore	0x93d54252 TSWaitOnConditionTimedRelative + 246
4   ...ple.CoreServices.CarbonCore	0x93d74f24 MPWaitOnQueue + 208
5   com.apple.DesktopServices     	0x921bb224 TFolderSizeTask::FolderSizeTaskProc(void*) + 104
6   ...ple.CoreServices.CarbonCore	0x93d734bb PrivateMPEntryPoint + 56
7   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
8   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 16:
0   libSystem.B.dylib             	0x92edf946 semaphore_timedwait_signal_trap + 10
1   libSystem.B.dylib             	0x92f111cf _pthread_cond_wait + 1244
2   libSystem.B.dylib             	0x92f12a53 pthread_cond_timedwait_relative_np + 47
3   com.apple.Foundation          	0x946f6f9c -[NSCondition waitUntilDate:] + 236
4   com.apple.Foundation          	0x946f6db0 -[NSConditionLock lockWhenCondition:beforeDate:] + 144
5   com.apple.AppKit              	0x937c9d22 +[NSNavFBENodePreviewHelper _subthreadComputePreviewThumbnailImages] + 278
6   com.apple.Foundation          	0x946b104d -[NSThread main] + 45
7   com.apple.Foundation          	0x946b0bf4 __NSThread__main__ + 308
8   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
9   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 17 Crashed:
0   libSystem.B.dylib             	0xffff0a2f __memcpy + 655
1   org.m0k.handbrake             	0x0003cacc hb_stream_read + 2605 (stream.c:2116)
2   org.m0k.handbrake             	0x0003cceb hb_stream_seek + 376 (stream.c:607)
3   org.m0k.handbrake             	0x00031dcc ScanFunc + 768 (scan.c:316)
4   org.m0k.handbrake             	0x00030b0a hb_thread_func + 80 (ports.c:288)
5   libSystem.B.dylib             	0x92f10075 _pthread_start + 321
6   libSystem.B.dylib             	0x92f0ff32 thread_start + 34

Thread 17 crashed with X86 Thread State (32-bit):
  eax: 0xffff09f5  ebx: 0x0003c0b3  ecx: 0x00000030  edx: 0xffffffc0
  edi: 0x11b2d040  esi: 0xb09f2974  ebp: 0xb09f2858  esp: 0xb09f2850
   ss: 0x0000001f  efl: 0x00010286  eip: 0xffff0a2f   cs: 0x00000017
   ds: 0x0000001f   es: 0x0000001f   fs: 0x0000001f   gs: 0x00000037
  cr2: 0x11b2d000

Binary Images:
    0x1000 -   0x47bff6 +org.m0k.handbrake 0.9.1 (2007100800) <c924b8d7881a769897d2f395a2649ffb> /Users/rouven/OpenSource/HandBrake/corebackup/HandBrake.app/Contents/MacOS/HandBrake
  0x7b3000 -   0x7bfff7 +org.andymatuschak.Sparkle ??? (1.1) /Users/rouven/OpenSource/HandBrake/corebackup/HandBrake.app/Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle
  0x7ca000 -   0x7e0fe7  com.apple.CoreVideo 1.5.0 (1.5.0) <7e010557527a0e6d49147c297d16850a> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
  0xe9f000 -   0xf85ff7  com.apple.RawCamera.bundle 2.0 (2.0) /System/Library/CoreServices/RawCamera.bundle/Contents/MacOS/RawCamera
 0xca1b000 -  0xca20ff3  libCGXCoreImage.A.dylib ??? (???) <978986709159e5fe9e094df5efddac1d> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGXCoreImage.A.dylib
 0xd39c000 -  0xd3a6ffe  com.apple.URLMount 3.1 (3.1) <742db901c626729373961d2b99036aab> /System/Library/PrivateFrameworks/URLMount.framework/URLMount
 0xe74b000 -  0xea5ffe2  com.apple.QuickTime 7.4.0 (92) <0d674546d12c65dc5c33dca4c81c315b> /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime
 0xeb1e000 -  0xebaaffb  com.apple.QTKit 7.4 (92) /System/Library/Frameworks/QTKit.framework/Versions/A/QTKit
 0xec04000 -  0xec2efff  com.apple.CoreMediaPrivate 1.4 (1.4) <59630ee9096ecf2ca1e518da2f46c68d> /System/Library/PrivateFrameworks/CoreMediaPrivate.framework/Versions/A/CoreMediaPrivate
 0xec3f000 -  0xec7cfff  com.apple.CoreMediaIOServicesPrivate 1.4 (1.4) /System/Library/PrivateFrameworks/CoreMediaIOServicesPrivate.framework/Versions/A/CoreMediaIOServicesPrivate
0x8fe00000 - 0x8fe2d883  dyld 95.3 (???) <81592e798780564b5d46b988f7ee1a6a> /usr/lib/dyld
0x9026c000 - 0x90327fe3  com.apple.WebKit 5523.10.6 (5523.10.6) <2741777559b3948d520a4d126330dbce> /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit
0x90328000 - 0x903b2fff  com.apple.framework.IOKit 1.5.1 (???) <5176a7383151a19c962334009fef2c6d> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x903b3000 - 0x903f5fef  com.apple.NavigationServices 3.5.1 (161) <cc6bd78eabf1e2e7166914e9f12f5850> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/NavigationServices.framework/Versions/A/NavigationServices
0x903f6000 - 0x90430ff7  com.apple.coreui 0.1 (60) /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
0x904ca000 - 0x90549ff5  com.apple.SearchKit 1.2.0 (1.2.0) <277b460da86bc222785159fe77e2e2ed> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x9054a000 - 0x905a3fff  libGLU.dylib ??? (???) /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x905a4000 - 0x905aefeb  com.apple.audio.SoundManager 3.9.2 (3.9.2) <0f2ba6e891d3761212cf5a5e6134d683> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/CarbonSound
0x905af000 - 0x905afffb  com.apple.installserver.framework 1.0 (8) /System/Library/PrivateFrameworks/InstallServer.framework/Versions/A/InstallServer
0x905b0000 - 0x905b7ff7  libCGATS.A.dylib ??? (???) <9b29a5500efe01cc3adea67bbc42568e> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGATS.A.dylib
0x905b8000 - 0x905b8ffc  com.apple.audio.units.AudioUnit 1.5 (1.5) /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x90724000 - 0x90732ffd  libz.1.dylib ??? (???) <5ddd8539ae2ebfd8e7cc1c57525385c7> /usr/lib/libz.1.dylib
0x90733000 - 0x90752ffa  libJPEG.dylib ??? (???) <0cfb80109d624beb9ceb3c43b6c5ec10> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x9075b000 - 0x907cffef  libvMisc.dylib ??? (???) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x916e5000 - 0x916e7fff  com.apple.securityhi 3.0 (30817) <2b2854123fed609d1820d2779e2e0963> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x9176d000 - 0x917e4fe3  com.apple.CFNetwork 220 (221) <972a41911805859205b057a6f5b91e8d> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x917e5000 - 0x917e5ff8  com.apple.Cocoa 6.5 (???) <e064f94d969ce25cb7de3cfb980c3249> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x917e6000 - 0x91842ff7  com.apple.htmlrendering 68 (1.1.3) <fe87a9dede38db00e6c8949942c6bd4f> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering
0x91849000 - 0x918d5ff7  com.apple.LaunchServices 286 (286) <72b15e7a01e42d510f0339e90113d5d6> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x918d6000 - 0x9199dff2  com.apple.vImage 3.0 (3.0) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x9199e000 - 0x919a4fff  com.apple.print.framework.Print 218 (220) <c35172175abbe554ddadd9b6401351fa> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x91a6b000 - 0x91a98feb  libvDSP.dylib ??? (???) <a26683d121ee0f96df9a9d0bfca36049> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x91a99000 - 0x91b40fff  com.apple.QD 3.11.50 (???) <e2f71720ae1dad06a8883ac80775b21a> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x91b41000 - 0x91b42ffc  libffi.dylib ??? (???) <a3b573eb950ca583290f7b2b4c486d09> /usr/lib/libffi.dylib
0x91b43000 - 0x91c0efff  com.apple.ColorSync 4.5.0 (4.5.0) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x91db2000 - 0x91db2ffd  com.apple.Accelerate.vecLib 3.4 (vecLib 3.4) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x91db3000 - 0x91dc7ff3  com.apple.ImageCapture 4.0 (5.0.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x91dc8000 - 0x9215eff7  com.apple.QuartzCore 1.5.1 (1.5.1) <deb61cbeb3f734a1b2f4669f6268b9de> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x921ab000 - 0x9225afff  com.apple.DesktopServices 1.4.3 (1.4.3) <66d5ed56111c43d234e235d365d02469> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x9225b000 - 0x92727ffe  libGLProgrammability.dylib ??? (???) <e8bc0af671427cf2b6279a035805a086> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
0x92728000 - 0x92734ff5  libGL.dylib ??? (???) /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x92735000 - 0x92774fef  libTIFF.dylib ??? (???) <6d0f80e9d4d81f3f64c876aca005bd53> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x927a5000 - 0x927eafef  com.apple.Metadata 10.5.0 (398) <4fd74fba0062c2e08ec4b1c10b40ff63> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x927f0000 - 0x92d06fff  com.apple.WebCore 5523.10.6 (5523.10.6) <9e1a5e022ebf8134c175de5f91c63bee> /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore
0x92d07000 - 0x92d81ff8  com.apple.print.framework.PrintCore 5.5 (245) <9441d178f4b430cf92b67bf346646693> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x92d82000 - 0x92e2bfff  com.apple.JavaScriptCore 5523.10.3 (5523.10.3) <9e6719a7a0740f5c224099a7b853e45b> /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/JavaScriptCore
0x92e2c000 - 0x92e89ffb  libstdc++.6.dylib ??? (???) <04b812dcec670daa8b7d2852ab14be60> /usr/lib/libstdc++.6.dylib
0x92e8a000 - 0x92ebbffb  com.apple.quartzfilters 1.5.0 (1.5.0) <22581f8fe9dd2cb261f97a897407ec3e> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuartzFilters.framework/Versions/A/QuartzFilters
0x92ebc000 - 0x92ec5fff  com.apple.speech.recognition.framework 3.7.24 (3.7.24) <d3180f9edbd9a5e6f283d6156aa3c602> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x92ec6000 - 0x92edefff  com.apple.openscripting 1.2.6 (???) <b8e553df643f2aec68fa968b3b459b2b> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x92edf000 - 0x93039fe3  libSystem.B.dylib ??? (???) <8ecc83dc0399be3946f7a46e88cf4bbb> /usr/lib/libSystem.B.dylib
0x9312f000 - 0x93165fff  com.apple.SystemConfiguration 1.9.0 (1.9.0) <7919d9588c3b0d556646e555b7193f1f> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x9318b000 - 0x9318bffe  com.apple.MonitorPanelFramework 1.2.0 (1.2.0) <a2b462be6c51187eddf7d097ef0e0a04> /System/Library/PrivateFrameworks/MonitorPanel.framework/Versions/A/MonitorPanel
0x931bd000 - 0x932a1ffb  com.apple.CoreData 100 (185) <a4e63784275e25e62f57e75e0af0b94d> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x932a2000 - 0x932a7ffb  com.apple.DisplayServicesFW 2.0 (2.0) <8953865f53e940007a4e4ac5390d3c95> /System/Library/PrivateFrameworks/DisplayServices.framework/Versions/A/DisplayServices
0x932ad000 - 0x932b8ff9  com.apple.helpdata 1.0 (14) /System/Library/PrivateFrameworks/HelpData.framework/Versions/A/HelpData
0x932bc000 - 0x93477ff3  com.apple.QuartzComposer 2.0 (106) <e31bf3733d0676dd7993afca6ce48c3e> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuartzComposer.framework/Versions/A/QuartzComposer
0x93478000 - 0x9352efe3  com.apple.CoreServices.OSServices 210.2 (210.2) <4ed69f07fc0f211ab32d1ee96e281fc2> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x9352f000 - 0x93d29fef  com.apple.AppKit 6.5 (949) <f8d0f6d0bb5ac092f48f42ca684bdb54> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x93d2a000 - 0x94003fe7  com.apple.CoreServices.CarbonCore 783 (783) <8370e664eeb25edc98d5c1f5405b06ae> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x94004000 - 0x94006ff5  libRadiance.dylib ??? (???) <20eadb285da83df96c795c2c5fa20590> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
0x9407b000 - 0x9448bfef  libBLAS.dylib ??? (???) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x944dd000 - 0x946a6fef  com.apple.security 5.0.1 (32736) <8c9eda0fcc1d8a571543025ac900715f> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x946a7000 - 0x94920fe7  com.apple.Foundation 6.5.1 (677.1) <85ac18c7cd454378db6122bea0c00965> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x94921000 - 0x94949ff7  com.apple.shortcut 1 (1.0) <057783867138902b52bc0941fedb74d1> /System/Library/PrivateFrameworks/Shortcut.framework/Versions/A/Shortcut
0x9494a000 - 0x94a2bff7  libxml2.2.dylib ??? (???) <450ec38b57fb46013847cce851001a2f> /usr/lib/libxml2.2.dylib
0x94a36000 - 0x94ae6fff  edu.mit.Kerberos 6.0.11 (6.0.11) <33c25789baedcd70a7e24881775dd9ad> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x94ae7000 - 0x94c0bfe3  com.apple.audio.toolbox.AudioToolbox 1.5 (1.5) /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x94c0c000 - 0x94c0cffa  com.apple.CoreServices 32 (32) <2fcc8f3bd5bbfc000b476cad8e6a3dd2> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x94c13000 - 0x94c54fe7  libRIP.A.dylib ??? (???) <bdc6d70bf4ed3dace321b4ff76a353b3> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
0x94c96000 - 0x94cf0ff7  com.apple.CoreText 2.0.0 (???) <7fa39cd5bc847615ec02e7c7a37c0508> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
0x94cf1000 - 0x94d6dfeb  com.apple.audio.CoreAudio 3.1.0 (3.1) <70bb7c657061631491029a61babe0b26> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x94d6e000 - 0x94dbafff  com.apple.QuickLookUIFramework 1.0.1 (168.1) /System/Library/PrivateFrameworks/QuickLookUI.framework/Versions/A/QuickLookUI
0x94dbb000 - 0x94f00ff7  com.apple.ImageIO.framework 2.0.0 (2.0.0) <154d4d8cda2bd99518cbabc9f2d69833> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x94f01000 - 0x94f93ff3  com.apple.ApplicationServices.ATS 3.0 (???) <fb5f572243dbc370a0ea5efc8e81ae11> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x94f94000 - 0x950cafe3  com.apple.imageKit 1.0 (1.0) <2f2656deebcf595b88f010ba08cef0e4> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Versions/A/ImageKit
0x950cb000 - 0x95152ff7  libsqlite3.0.dylib ??? (???) <273efcb717e89c21207c851d7d33fda4> /usr/lib/libsqlite3.0.dylib
0x95153000 - 0x9517dfef  libauto.dylib ??? (???) <d468bc4a8a69343f1748c293db1b57fb> /usr/lib/libauto.dylib
0x9519c000 - 0x9519ffff  com.apple.help 1.1 (36) <b507b08e484cb89033e9cf23062d77de> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x951a0000 - 0x951bbffb  libPng.dylib ??? (???) <b6abcac36ec7654ff3e1cfa786b0117b> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x951bc000 - 0x951c0fff  libGIF.dylib ??? (???) <d4234e6f5e5f530bdafb969157f1f17b> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x951c1000 - 0x95254fff  com.apple.ink.framework 101.3 (86) <bf3fa8927b4b8baae92381a976fd2079> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x95255000 - 0x95273ff3  com.apple.DirectoryService.Framework 3.5 (3.5) <899d8c9ee31b004a6ff73dab88982b1a> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
0x95274000 - 0x95274ffd  com.apple.Accelerate 1.4 (Accelerate 1.4) /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x95355000 - 0x9565bfff  com.apple.HIToolbox 1.5.0 (???) <1b872a7151ee3f80c9c736a3e46d00d9> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x9565c000 - 0x95664fff  com.apple.DiskArbitration 2.2 (2.2) <1551b2af557fdf6f368f93e093933852> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x95665000 - 0x95675ffc  com.apple.LangAnalysis 1.6.4 (1.6.4) <cbeb17ab39f28351fe2ab5b82bf465bc> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x95778000 - 0x9578efff  com.apple.DictionaryServices 1.0.0 (1.0.0) <ad0aa0252e3323d182e17f50defe56fc> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x95aa1000 - 0x95aacfe7  libCSync.A.dylib ??? (???) <df82fc093e498a9eb5490761cb292218> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCSync.A.dylib
0x95b13000 - 0x95b42fe3  com.apple.AE 402 (402) <994ba8e884aefe7bf1fc5987df099e7b> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x95b43000 - 0x95c7bff7  libicucore.A.dylib ??? (???) <afcea652ff2ec36885b2c81c57d06d4c> /usr/lib/libicucore.A.dylib
0x95c7c000 - 0x96313fef  com.apple.CoreGraphics 1.351.0 (???) <7a6f399039eed6dbe845c169f7d21a70> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x96314000 - 0x96446fe7  com.apple.CoreFoundation 6.5 (476) <8bfebc0dbad6fc33bea0fa00a1b9ec37> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x96447000 - 0x96465ff7  com.apple.QuickLookFramework 1.0.1 (168.1) /System/Library/Frameworks/QuickLook.framework/Versions/A/QuickLook
0x96466000 - 0x96466ffd  com.apple.vecLib 3.4 (vecLib 3.4) /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
0x964d4000 - 0x96542fff  com.apple.iLifeMediaBrowser 1.0.3 (194) /System/Library/PrivateFrameworks/iLifeMediaBrowser.framework/Versions/A/iLifeMediaBrowser
0x96543000 - 0x96901fea  libLAPACK.dylib ??? (???) /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x96902000 - 0x96903fef  libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib
0x96904000 - 0x969e3fff  libobjc.A.dylib ??? (???) <5eda47fec2d0e7853b3506aa1fd2dafa> /usr/lib/libobjc.A.dylib
0x969e4000 - 0x969e9fff  com.apple.CommonPanels 1.2.4 (85) <ea0665f57cd267609466ed8b2b20e893> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x96a10000 - 0x96a4dff7  libGLImage.dylib ??? (???) <202d73e6a4688fc06ff11b71910c2ce7> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x96a4e000 - 0x96a5efff  com.apple.speech.synthesis.framework 3.6.59 (3.6.59) <4ffef145fad3d4d787e0c33eab26b336> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x96a5f000 - 0x96acefff  com.apple.PDFKit 2.0 (2.0) /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/PDFKit.framework/Versions/A/PDFKit
0x96acf000 - 0x96aedfff  libresolv.9.dylib ??? (???) <54e6a08c2f108bdf5916fb483d51961b> /usr/lib/libresolv.9.dylib
0x96aee000 - 0x96afbfe7  com.apple.opengl 1.5.5 (1.5.5) <aa08b52d2a84b44dc6ee5d544a53fe8a> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x96afc000 - 0x96afcffe  com.apple.quartzframework 1.5 (1.5) <4b8f505e32e4f2d67967a276401f9aaf> /System/Library/Frameworks/Quartz.framework/Versions/A/Quartz
0x96afd000 - 0x96b0cffe  com.apple.DSObjCWrappers.Framework 1.2 (1.2) <f5b58d1d3a855a63d493ccbec417a1e9> /System/Library/PrivateFrameworks/DSObjCWrappers.framework/Versions/A/DSObjCWrappers
0x96b0d000 - 0x96b0dfff  com.apple.Carbon 136 (136) <98a5e3bc0c4fa44bbb09713bb88707fe> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x96b0e000 - 0x96b5eff7  com.apple.HIServices 1.6.0 (???) <d74aa73e4cfd30a08fb169198a8d2539> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x96b5f000 - 0x96b83fff  libxslt.1.dylib ??? (???) <4933ddc7f6618743197aadc85b33b5ab> /usr/lib/libxslt.1.dylib
0x96b84000 - 0x96b8bffe  libbsm.dylib ??? (???) <d25c63378a5029648ffd4b4669be31bf> /usr/lib/libbsm.dylib
0x96b8c000 - 0x96b93fe9  libgcc_s.1.dylib ??? (???) <f53c808e87d1184c0f9df63aef53ce0b> /usr/lib/libgcc_s.1.dylib
0x96b94000 - 0x96bbbfff  libcups.2.dylib ??? (???) <5521498e8902ddd0b15cfaa7db384e29> /usr/lib/libcups.2.dylib
0x96c1c000 - 0x96cceffb  libcrypto.0.9.7.dylib ??? (???) <330b0e48e67faffc8c22dfc069ca7a47> /usr/lib/libcrypto.0.9.7.dylib
0x96d6e000 - 0x96d6eff8  com.apple.ApplicationServices 34 (34) <8f910fa65f01d401ad8d04cc933cf887> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0xc0000000 - 0xc0008fff +com.growl.growlframework 0.7.6 (0.7.6) /Users/rouven/OpenSource/HandBrake/corebackup/HandBrake.app/Contents/Frameworks/Growl.framework/Versions/A/Growl
0xfffe8000 - 0xfffebfff  libobjc.A.dylib ??? (???) /usr/lib/libobjc.A.dylib
0xffff0000 - 0xffff1780  libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib
Cavalicious
Moderator
Posts: 1804
Joined: Mon Mar 26, 2007 12:07 am

Re: MPEG-2 Transport Stream Support

Post by Cavalicious »

There has been numerous patches pertaining to TS/PS support. I would advise you use the latest svn...even then, I'm not sure if all patches have been committed.
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Ups, forgot to mention. It is the latest svn. (Else wise I couldn't have opened an .eyetv file)
Cavalicious
Moderator
Posts: 1804
Joined: Mon Mar 26, 2007 12:07 am

Re: MPEG-2 Transport Stream Support

Post by Cavalicious »

realityking wrote:Ups, forgot to mention. It is the latest svn. (Else wise I couldn't have opened an .eyetv file)
Not True. .eyetv support was added 56 commits ago.

Anyway, like I said, I'm not sure all patches made it yet. Look for replies to me from van. But , then again, could be something different.

Plus, the Activity Log would be great, if it is something new.
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Cavalicious wrote:
realityking wrote:Ups, forgot to mention. It is the latest svn. (Else wise I couldn't have opened an .eyetv file)
Not True. .eyetv support was added 56 commits ago.

Anyway, like I said, I'm not sure all patches made it yet. Look for replies to me from van. But , then again, could be something different.

Plus, the Activity Log would be great, if it is something new.
Well okay, only thought about svn <-> release.

All look for patches, maybe I find something.

Here's the activity log:

Code: Select all

HandBrake Activity Log for Session (Cleared): 2008-01-18 18:41:24 +0100

[18:41:25] hb_init: checking cpu count
[18:41:25] hb_init: starting libhb thread
[18:41:25] thread b01da000 started ("libhb")
[18:41:37] macgui: trying to open a package at: /Users/rouven/Documents/EyeTV Archive/C.S.I. - Den Tätern auf der Spur - Lebende Legende (Living Legend).eyetv
[18:41:37] macgui: trying to open eyetv package
[18:41:37] macgui: found mpeg in eyetv package
[18:41:37] hb_scan: path=/Users/rouven/Documents/EyeTV Archive/C.S.I. - Den Tätern auf der Spur - Lebende Legende (Living Legend).eyetv/000000000cda6b45.mpg, title_index=0
[18:41:37] thread b067d000 started ("scan")
[18:41:37] scan: trying to open with libdvdread
GUI ERROR dialog: dvd: DVDOpen failed (/Users/rouven/Documents/EyeTV Archive/C.S.I. - Den Tätern auf der Spur - Lebende Legende (Living Legend).eyetv/000000000cda6b45.mpg)
[18:41:37] file is MPEG Transport Stream
[18:41:37] hb_ts_stream_find_pids - found the following PIDS
[18:41:37]     Video PIDS : 
[18:41:37]       0x12c (300)
[18:41:37]     Audio PIDS : 
[18:41:37]       0x12d (301)
[18:41:37] hb_sample_pts: pts 497052037 at 10338120
[18:41:37] hb_sample_pts: pts 647002837 at 30979016
[18:41:37] transport stream pid 0x12d (type 0x3) is MPEG audio id 0xc0
[18:41:37] scan: decoding previews for title 1
[18:41:39] scan: preview 1
[18:41:40] scan: preview 2
[18:41:40] scan: preview 3
[18:41:41] scan: preview 4
Also interesting might be that it is just 69 seconds long.
awk
Enlightened
Posts: 109
Joined: Sat Mar 31, 2007 11:55 pm

Re: MPEG-2 Transport Stream Support

Post by awk »

That log looks a little 'short' - there should be more previews (usually 10).

However you also mention that this is a very short clip - that can sometimes screw up the preview generation if it can't find 10 complete pictures each starting 1/10th of the file (in bytes) apart. For very short files with the MPEG-2 long gop scheme sometimes this can be difficult.

I'd suggest trying a larger file - perhaps a couple of minutes.
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

The thing is that other streams work, I just tried one that is 3:27, that works just fine. However this doesn't help me if I try to encode my 69 second video. The video is not important, just wanted to report this as a bug.
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Re: MPEG-2 Transport Stream Support

Post by van »

This is a part of the code I've avoided looking at. From the crash log it's clearly doing a memcpy with a problem src or destination. Here's a patch that fixes everything I could find with a quick read over the general area (an off-by-one, a couple of flailing buffer indices & a slight excess of trust in the data stream). I also made the code around the memcpy more paranoid so it should at least print an error message rather than aborting. I'd like to see the activity log from this even if it works. If it doesn't work perhaps I can get a copy of the clip so I can run it in the debugger & figure out what's happening. Thanks.

http://pastebin.ca/861095

Code: Select all

Index: libhb/stream.c
===================================================================
--- libhb/stream.c	(revision 1210)
+++ libhb/stream.c	(working copy)
@@ -527,9 +527,14 @@
 	// Transport streams are a little more complex  - we might be able to just
 	// read from the transport stream conversion buffer (if there's enough data)
 	// or we may need to transfer what's left and fill it again.
-	if (src_stream->ps_decode_buffer[read_buffer_index].len - src_stream->ps_decode_buffer[read_buffer_index].read_pos > HB_DVD_READ_BUFFER_SIZE)
+	if (src_stream->ps_decode_buffer[read_buffer_index].len
+          - src_stream->ps_decode_buffer[read_buffer_index].read_pos
+        >= HB_DVD_READ_BUFFER_SIZE)
 	{
-		memcpy(b->data, src_stream->ps_decode_buffer[read_buffer_index].data + src_stream->ps_decode_buffer[read_buffer_index].read_pos,HB_DVD_READ_BUFFER_SIZE);
+		memcpy(b->data,
+               src_stream->ps_decode_buffer[read_buffer_index].data +
+                 src_stream->ps_decode_buffer[read_buffer_index].read_pos,
+               HB_DVD_READ_BUFFER_SIZE);
 		src_stream->ps_decode_buffer[read_buffer_index].read_pos += HB_DVD_READ_BUFFER_SIZE;
 		return 1;
 	}
@@ -541,9 +546,9 @@
 		int amt_avail_to_transfer = src_stream->ps_decode_buffer[read_buffer_index].len - src_stream->ps_decode_buffer[read_buffer_index].read_pos;
 		memcpy(b->data, src_stream->ps_decode_buffer[read_buffer_index].data + src_stream->ps_decode_buffer[read_buffer_index].read_pos, amt_avail_to_transfer);
 		transfer_size -= amt_avail_to_transfer;
-		src_stream->ps_decode_buffer[read_buffer_index].read_pos += amt_avail_to_transfer;
-		
+
 		// Give up this buffer - decoding may well need it, and we're done
+		src_stream->ps_decode_buffer[read_buffer_index].read_pos = 0;
 		src_stream->ps_decode_buffer[read_buffer_index].write_pos = 0;
 		src_stream->ps_decode_buffer[read_buffer_index].len = 0;
 		
@@ -1627,6 +1632,9 @@
 				make_pes_header(stream->ts_packetbuf[curstream] + pos, stream->ts_streamid[curstream], 0, -1, -1);
 			}
 
+			stream->ts_packetpos[curstream] = 0;
+			stream->ts_streamcont[curstream] = -1;
+
 			// Write padding
 			if ((written % HB_DVD_READ_BUFFER_SIZE) != 0)
 			{
@@ -1640,9 +1648,6 @@
 				}
 			}
 
-			stream->ts_packetpos[curstream] = 0;
-			stream->ts_streamcont[curstream] = -1;
-
 	return 0;
 }
 
@@ -1978,7 +1983,7 @@
 			adapt_len = buf[4] + 1;
 			if (adapt_len > 184)
 			{
-				hb_log("hb_ts_stream_decode - Invalid adapt len (was > 183)!");
+				hb_log("hb_ts_stream_decode - Invalid adapt len %d", adapt_len);
 				for (i=0; i < stream->ts_number_video_pids + stream->ts_number_audio_pids; i++)
 				{
 					stream->ts_skipbad[i] = 1;
@@ -2011,7 +2016,7 @@
 //					int pos = ftell(fin);
 //					error("AC3 packet sync not found in start frame");
 //					return 1;
-				adapt_len += 9 + buf[4 + adapt_len + 8];	
+				adapt_len = 184;	
 				start = 0;
 			}
 		}
@@ -2112,6 +2117,15 @@
 		// Add the payload for this packet to the current buffer
 		if (stream->ts_foundfirst[curstream] && (184 - adapt_len) > 0)
 		{
+            // XXX this shouldn't happen but we'll be paranoid
+            if (stream->ts_packetpos[curstream] + 184 - adapt_len > 1024*1024)
+            {
+                hb_log("hb_ts_stream_decode: ts_packetbuf overflow, pos = %d ,"
+                       "len = %d", stream->ts_packetpos[curstream],
+                       184 - adapt_len );
+                return;
+            }
+
 			memcpy(stream->ts_packetbuf[curstream] + stream->ts_packetpos[curstream], buf + 4 + adapt_len, 184 - adapt_len);
 			stream->ts_packetpos[curstream] += 184 - adapt_len;
 		}

realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Your patched fixed the scanning issue, thanks. The length of the video was greatly misreported, Handbrake thinks it is 55 minutes long (I suppose that the fake duration thing I read somewhere). However while the video is fine the resulting file is without audio.
I just remembered that I created this file from an eyetv recording as outlined above, however I didn't just delete something at the start and the end but also in the middle. Anyways here is the activity log:
http://pastebin.com/m59160c3e

(Can't post it here, its too long)
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Re: MPEG-2 Transport Stream Support

Post by van »

Thanks for the report & the log. I didn't fix the underlying problem but the log now has enough info to help track it down.

The lack of audio bothers me. Are you able to convert other EyeTV files with MPEG audio using HB (i.e., transport streams where you see a message like "transport stream pid 0x12d (type 0x3) is MPEG audio id 0xc0" in the activity log)? The reason I ask is because I can't test that here - ATSC, the US Digital TV standard, mandates AC3 so I don't have any transport streams with MPEG audio & just guessed at how to handle it.

I knew a duration issue due to timing discontinuities in the middle of the content would come up as soon as the EyeTV integration started getting more use. I didn't want to put in code to handle this until it actually caused a problem for someone. Looks like I have to fix it now :wink:
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Another one with MPEG-Audio didn't work either. :/ I could have sworn I have encoded EyeTV recordings before mit HandBrake, but maybe that had an AC3 Track.
I'll upload a sample for you sometime this week.
van
Veteran User
Posts: 417
Joined: Wed Aug 29, 2007 6:35 am

Re: MPEG-2 Transport Stream Support

Post by van »

I did a desk check of the the mpeg audio code in libhb/stream.c & found several mistakes I'd made. Attached is an updated patch that may work better on your clip. As before I'm interested in the activity log whether it works on not. Thanks again for testing this.
http://pastebin.ca/861938

Code: Select all

Index: libhb/stream.c
===================================================================
--- libhb/stream.c	(revision 1212)
+++ libhb/stream.c	(working copy)
@@ -527,9 +527,14 @@
 	// Transport streams are a little more complex  - we might be able to just
 	// read from the transport stream conversion buffer (if there's enough data)
 	// or we may need to transfer what's left and fill it again.
-	if (src_stream->ps_decode_buffer[read_buffer_index].len - src_stream->ps_decode_buffer[read_buffer_index].read_pos > HB_DVD_READ_BUFFER_SIZE)
+	if (src_stream->ps_decode_buffer[read_buffer_index].len
+          - src_stream->ps_decode_buffer[read_buffer_index].read_pos
+        >= HB_DVD_READ_BUFFER_SIZE)
 	{
-		memcpy(b->data, src_stream->ps_decode_buffer[read_buffer_index].data + src_stream->ps_decode_buffer[read_buffer_index].read_pos,HB_DVD_READ_BUFFER_SIZE);
+		memcpy(b->data,
+               src_stream->ps_decode_buffer[read_buffer_index].data +
+                 src_stream->ps_decode_buffer[read_buffer_index].read_pos,
+               HB_DVD_READ_BUFFER_SIZE);
 		src_stream->ps_decode_buffer[read_buffer_index].read_pos += HB_DVD_READ_BUFFER_SIZE;
 		return 1;
 	}
@@ -541,9 +546,9 @@
 		int amt_avail_to_transfer = src_stream->ps_decode_buffer[read_buffer_index].len - src_stream->ps_decode_buffer[read_buffer_index].read_pos;
 		memcpy(b->data, src_stream->ps_decode_buffer[read_buffer_index].data + src_stream->ps_decode_buffer[read_buffer_index].read_pos, amt_avail_to_transfer);
 		transfer_size -= amt_avail_to_transfer;
-		src_stream->ps_decode_buffer[read_buffer_index].read_pos += amt_avail_to_transfer;
-		
+
 		// Give up this buffer - decoding may well need it, and we're done
+		src_stream->ps_decode_buffer[read_buffer_index].read_pos = 0;
 		src_stream->ps_decode_buffer[read_buffer_index].write_pos = 0;
 		src_stream->ps_decode_buffer[read_buffer_index].len = 0;
 		
@@ -650,13 +655,15 @@
         }
         else if ((buf[3] & 0xe0) == 0xc0)
         {
-            audio->id = buf[3];
+            audio->id = buf[3] | aud_pid_index;
             audio->codec = HB_ACODEC_MPGA;
             hb_log("transport stream pid 0x%x (type 0x%x) is MPEG audio id 0x%x",
                    stream->ts_audio_pids[aud_pid_index],
                    stream->ts_audio_stream_type[aud_pid_index],
                    audio->id);
             stream->ts_audio_stream_type[aud_pid_index] = 0x03;
+            stream->ts_streamid[stream->ts_number_video_pids + aud_pid_index] =
+                    audio->id;
         }
     }
     fseeko(stream->file_handle, cur_pos, SEEK_SET);
@@ -760,8 +767,10 @@
 	
     if (stream->stream_type == hb_stream_type_transport)
 	{
-		// Find the audio stream info for this PID
-        int i = (audio->id >> 8) & 0xf;
+        // Find the audio stream info for this PID. The stream index is
+        // the subchannel id which is in the bottom four bits for MPEG audio
+        // and the bottom four bits of the upper byte for everything else.
+        int i = ( audio->id > 0xd0 ? audio->id >> 8 : audio->id ) & 0xf;
         if (i >= stream->ts_number_audio_pids)
 		{
             hb_log("hb_stream_update_audio: no PID for audio stream 0x%x",
@@ -1627,6 +1636,9 @@
 				make_pes_header(stream->ts_packetbuf[curstream] + pos, stream->ts_streamid[curstream], 0, -1, -1);
 			}
 
+			stream->ts_packetpos[curstream] = 0;
+			stream->ts_streamcont[curstream] = -1;
+
 			// Write padding
 			if ((written % HB_DVD_READ_BUFFER_SIZE) != 0)
 			{
@@ -1640,9 +1652,6 @@
 				}
 			}
 
-			stream->ts_packetpos[curstream] = 0;
-			stream->ts_streamcont[curstream] = -1;
-
 	return 0;
 }
 
@@ -1978,7 +1987,7 @@
 			adapt_len = buf[4] + 1;
 			if (adapt_len > 184)
 			{
-				hb_log("hb_ts_stream_decode - Invalid adapt len (was > 183)!");
+				hb_log("hb_ts_stream_decode - Invalid adapt len %d", adapt_len);
 				for (i=0; i < stream->ts_number_video_pids + stream->ts_number_audio_pids; i++)
 				{
 					stream->ts_skipbad[i] = 1;
@@ -2011,7 +2020,7 @@
 //					int pos = ftell(fin);
 //					error("AC3 packet sync not found in start frame");
 //					return 1;
-				adapt_len += 9 + buf[4 + adapt_len + 8];	
+				adapt_len = 184;	
 				start = 0;
 			}
 		}
@@ -2110,8 +2119,17 @@
 		}
 
 		// Add the payload for this packet to the current buffer
-		if (stream->ts_foundfirst[curstream] && (184 - adapt_len) > 0)
+		if (!stream->ts_skipbad[curstream] && stream->ts_foundfirst[curstream] &&
+            (184 - adapt_len) > 0)
 		{
+            // XXX this shouldn't happen but we'll be paranoid
+            if (stream->ts_packetpos[curstream] + 184 - adapt_len > 1024*1024)
+            {
+                hb_log("hb_ts_stream_decode: ts_packetbuf overflow, pos = %d ,"
+                       "len = %d", stream->ts_packetpos[curstream],
+                       184 - adapt_len );
+                return;
+            }
 			memcpy(stream->ts_packetbuf[curstream] + stream->ts_packetpos[curstream], buf + 4 + adapt_len, 184 - adapt_len);
 			stream->ts_packetpos[curstream] += 184 - adapt_len;
 		}

realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Should I apply this in addition to the ld patch or instead?
Cavalicious
Moderator
Posts: 1804
Joined: Mon Mar 26, 2007 12:07 am

Re: MPEG-2 Transport Stream Support

Post by Cavalicious »

Instead (since it is updated)
realityking
Veteran User
Posts: 680
Joined: Tue Apr 24, 2007 12:36 pm

Re: MPEG-2 Transport Stream Support

Post by realityking »

Well that's probably what happens if you don really know hat you do, I always get this error:

Code: Select all

File to patch: /Users/rouven/OpenSource/HandBrake/mpeg2/libhb/stream.c 
patching file /Users/rouven/OpenSource/HandBrake/mpeg2/libhb/stream.c
patch: **** malformed patch at line 6:    // Transport streams are a little more complex  - we might be able to just
Maybe because I'm using 1215 instead of 1212? But stream.c hasn't changed since then....
Post Reply