mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 05:15:12 +00:00
file writer implemented
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1873 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
fff46da0c3
commit
07e4b2db17
@ -9,6 +9,8 @@
|
||||
|
||||
LIBVO_EXTERN (mpegpes)
|
||||
|
||||
int vo_mpegpes_fd=-1;
|
||||
|
||||
static vo_info_t vo_info =
|
||||
{
|
||||
"Mpeg-PES file",
|
||||
@ -20,7 +22,11 @@ static vo_info_t vo_info =
|
||||
static uint32_t
|
||||
init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
|
||||
{
|
||||
|
||||
vo_mpegpes_fd=open("grab.mpg","ab");
|
||||
if(vo_mpegpes_fd<0){
|
||||
perror("vo_mpegpes");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -43,10 +49,41 @@ static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,in
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void my_write(unsigned char* data,int len){
|
||||
while(len>0){
|
||||
int ret=write(vo_mpegpes_fd,data,len);
|
||||
if(ret<=0) break; // error
|
||||
len-=ret; data+=ret;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t draw_frame(uint8_t * src[])
|
||||
{
|
||||
vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
|
||||
int payload_size=p->size+5;
|
||||
int x;
|
||||
unsigned char pes_header[4+2+5];
|
||||
|
||||
// construct PES header:
|
||||
// startcode:
|
||||
pes_header[0]=pes_header[1]=0;
|
||||
pes_header[2]=p->id>>8; pes_header[3]=p->id&255;
|
||||
// packetsize:
|
||||
pes_header[4]=payload_size>>8;
|
||||
pes_header[5]=payload_size&255;
|
||||
// stuffing:
|
||||
// presentation time stamp:
|
||||
x=(0x02 << 4) | (((p->timestamp >> 30) & 0x07) << 1) | 1;
|
||||
pes_header[6]=x;
|
||||
x=((((p->timestamp >> 15) & 0x7fff) << 1) | 1);
|
||||
pes_header[7]=x>>8; pes_header[8]=x&255;
|
||||
x=((((p->timestamp) & 0x7fff) << 1) | 1);
|
||||
pes_header[9]=x>>8; pes_header[10]=x&255;
|
||||
my_write(pes_header,4+2+5);
|
||||
// data:
|
||||
my_write(p->data,p->size);
|
||||
|
||||
// printf("PES: draw frame! pts=%d size=%d \n",p->timestamp,p->size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -61,6 +98,8 @@ query_format(uint32_t format)
|
||||
static void
|
||||
uninit(void)
|
||||
{
|
||||
close(vo_mpegpes_fd);
|
||||
vo_mpegpes_fd=-1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user