How to programmatically find out the width and height of a video in the mpeg-2 transport stream file ?
Edit: I am using C ++, but I am happy with the examples in any language. Edit: The fixed question is probably the program threads I was asking about
Check the source code for libmpeg2 , the MPEG2 F / OSS decoder. It appears that the width and height are given in function mpeg2_header_sequence()c header.c. However, I am not sure that control is moving to this particular function. I would suggest opening the MPEG2 file in something using libmpeg2 (like MPlayer ) and attaching a debugger to see more precisely what it does.
mpeg2_header_sequence()
header.c
If you use DirectX, there is a method in the VMRWindowlessControl interface:
piwc->GetNativeVideoSize(&w, &h, NULL, NULL);
Or the IBasicVideo interface:
pivb->GetVideoSize(&w, &h);
MPEG2 Video ( ). 0x000001B3. . / , .
#define VIDEO_SEQUENCE_HDR 0xB3 #define HOR_SIZE_MASK 0xFFF00000 #define HOR_SIZE_SHIFT 20 #define VER_SIZE_MASK 0x000FFF00 #define VER_SIZE_SHIFT 8 unsigned char *pTmp = tsPacket; int len = 188; int horizontal, vertical; while(len>0 && !horizontal && !vertical) { if(*pTmp == 0 && *(pTmp+1) == 0 && *(pTmp+2)== 0x01 && *(pTmp+3) == 0xB3 && (len-1) >0) { unsigned int *pHdr = (unsigned int *)pTmp; pHdr++ ; unsigned int secondByte = ntohl(*pHdr); horizontal = (secondByte & HOR_SIZE_MASK) >> HOR_SIZE_SHIFT; vertical = (secondByte & VER_SIZE_MASK) >> VER_SIZE_SHIFT; break; } pTmp++; len--; }
, , , .
. MPEG-2, - RFC MPEG RTP.
http://www.fh-friedberg.de/fachbereiche/e2/telekom-labor/zinke/mk/mpeg2beg/beginnzi.htm
http://www.ietf.org/rfc/rfc2250.txt
hamishmcn said Adam Rosenfield's answer was what he needed. This makes me wonder about the accuracy of the question. MPEG transport stream does not havevideo title This header is in the MPEG program stream.
I have no answer. I just hoped that someone would answer correctly, because I need it.
Source: https://habr.com/ru/post/1699512/More articles:How do you use F1 help in Delphi 2007? - delphiFreezing related objects - ruby | fooobar.comOpen file with MIDlet.platformRequest () - blackberryHow to fill in the SYSTEMTIME value? - windows-mobilehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1699511/how-to-monitor-log-files-access-to-remote-folders-under-windows&usg=ALkJrhjQh-lH2ppLAq-SP9kqvTaN3cGI3ACancel request validation using HttpHandler in IIS 7 - c #QuickStart basic layout / template for web development? - templatesContains () and how to implement it - c #Add my linq query result set to the dataset, C # asp.net 3.5 - c #Is it possible to develop plugins for Microsoft Office Communicator? - ms-officeAll Articles