Hi:
I want to use some picture to create a video,the picture : size is 1000x720,raw data from camera,monochrome(gray),one byte a pixel.
for test ,i use this tool to create some picture in directory ./pic (you should mkdir ./pic first):
#include <stdlib.h>
#include <stdio.h>
#define WIDTH 1000 //pic size,width
#define HEIGHT 720 //pic size,height
#define MAX 180 //number of file****
#define START 350
#define STOP 370
char ucSpaceLine[WIDTH]={0};
char ucBoxLine[STOP-START][WIDTH]={0};
int space=0,row=0;
void boxGrow(int k,int space,int row) //let box grow from left to right
{
int i=0,j=0,iRight=0,iLeft=0;
iRight= k<(WIDTH-1)? k:(WIDTH-1);
iLeft= (k-space)>0 ? (k-space):0;
for(i=0;i<row;i++)
{
for(j=iLeft;j<iRight;j++)
{
ucBoxLine[i][j]=0xFF;
}
}
}
int createBigFile(int space,int row)
{
int i=0,j=0,k=0;
FILE *file=fopen("./bigFile","wb");
if( !file )
{
printf("\nFailed to create bigFile!");
return -1;
}
k=0;
for(i=0;i<MAX;i++)
{
boxGrow(k,space,row);
k+=WIDTH/MAX;
for(j=0;j<START;j++)
{
fwrite(ucSpaceLine,WIDTH,1,file);
}
fwrite(&(ucBoxLine[0][0]),WIDTH*(STOP-START),1,file);
for(j=STOP;j<HEIGHT;j++)
{
fwrite(ucSpaceLine,WIDTH,1,file);
}
}
fclose(file);
return 0;
}
int createSomeFile(int space,int row)
{
char szFileName[20]={'\0'};
int i=0,j=0,k=0,x=0;
FILE *file=NULL;
k=0;
for(i=0;i<MAX;i++)
{
boxGrow(k,space,row);
k+=WIDTH/MAX;
for(x=0;x<20;x++)
{
szFileName[x]=0;
}
sprintf(szFileName,"./pic/file%05d.tiff",i);
file=fopen(szFileName,"wb");
for(j=0;j<START;j++)
{
fwrite(ucSpaceLine,WIDTH,1,file);
}
fwrite(&(ucBoxLine[0][0]),WIDTH*(STOP-START),1,file);
for(j=STOP;j<HEIGHT;j++)
{
fwrite(ucSpaceLine,WIDTH,1,file);
}
fclose(file);
}
return 0;
}
int main()
{
char choose=0;
space=WIDTH/MAX;
row=STOP-START;
printf("\nInput your choose: 0.create a big file 1.create some file in ./pic directory\n");
printf("choose:");
choose=getchar();
switch(choose)
{
case '0':
createBigFile(space,row);
break;
case '1':
createSomeFile(space,row);
break;
default:
printf("\nIlleage input!\n");
break;
}
}
compile command is: gcc create.c
after run ./a.out,and choose “1”,you get 180 pictures in ./pic.
now,i run this command,use software colorspace transform,it can get the video,though has the wrong framerate.
gst-launch-1.0 multifilesrc location=./pic/file%05d.tiff index=0 start-index=0 stop-index=179 \
blocksize=720000 num-buffers=180 do-timestamp=true typefind=true ! \
'video/x-raw,format=(string)GRAY8,width=(int)1000,height=(int)720,framerate=(fraction)30/1' ! \
videoconvert ! \
'video/x-raw,format=(string)I420,framerate=(fraction)30/1' ! \
omxh264enc ! \
'video/x-h264,stream-format=(string)byte-stream,framerate=(fraction)30/1' ! \
h264parse ! \
qtmux !\
filesink sync=true location=test.mp4 -e \
and ,if i use the hardware colorspace transform,like this,the video has the more wrong framerate:
gst-launch-1.0 multifilesrc location=./pic/file%05d.tiff index=0 start-index=0 stop-index=179 \
blocksize=720000 num-buffers=180 do-timestamp=true typefind=true ! \
'video/x-raw,format=(string)GRAY8,width=(int)1000,height=(int)720,framerate=(fraction)30/1' ! \
nvvidconv ! \
'video/x-raw(memory:NVMM),format=(string)I420,framerate=(fraction)30/1' ! \
omxh264enc ! \
'video/x-h264,stream-format=(string)byte-stream,framerate=(fraction)30/1' ! \
h264parse ! \
qtmux !\
filesink sync=true location=test.mp4 -e \
my question is :
1.May be I missed some configuration on nvviconv ? use software transform ,the video seeams normal,but hardware transform,it looks too quick.
2.Do any one know how to set the framerate? I has tried some method,including change the gstbuffer’s clock,all no use.
by the way,if i use filesrc instead of multifilesrc,the gst-lanch-1.0 can get the video(though also has the wrong framerate).but filesrc can't be used in my c code,i used fakesrc in c code,but can't get the video,and found multifilesrc may be the best choose.
I can use this command in imx6q(freescale,nxp's ic,the gstream's version is 0.1):
gst-launch -v filesrc location=/BigFile blocksize=720000 num-buffers=180 ! \
'video/x-raw-gray,width=1000,height=720,bpp=8,depth=8,framerate=25/1' ! \
ffmpegcolorspace ! \
mfw_ipucsc ! \
'video/x-raw-yuv,format=(fourcc)I420,width=1000,height=720,framerate=25/1' ! \
mfw_deinterlacer ! \
vpuenc framerate-nu=25000 seqheader-method=3 framerate-de=1000 codec=avc ! \
'video/x-h264,width=1000,height=720' ! \
matroskamux ! \
filesink location=/examplebottle.mp4