main.c

来自「这是将avs视频的ES流转换成avi文件格式的源代码」· C语言 代码 · 共 116 行

C
116
字号
#include "avilib.h"
#include "string.h"

#include "mp4.h"

int main()
{

   	static char buf[720*576*3];
	long len = 0;
	int n = 0;
	int m=0;
	int n_old;
	int m_old;
	int i ;
	int k=0;
long round=0;

	FILE * fwav;
	FILE * fmp3;
	FILE * fmp4;
	avi_t* aviFile;





	aviFile=AVI_open_output_file("D:/Avi/Stream/Test_AVS.avi");


/*
	fwav = fopen("D:/Avi/Stream/xwyl_11.mpa", "rb");               //fopen  1
	AVI_set_audio(aviFile, 1, 48000, 128000, 0, 0x55 );

*/



	fmp4=fopen("D:/Avi/Stream/xwyl_1.m2v","rb");  //fopen  3
	AVI_set_video(aviFile, 320, 240, 25, "avsf");
    printf(" Read avs beginning............\n");

//		AVI_set_video(aviFile, 720, 576, 25, "XVID");

/*************************/

	//AVI_set_audio(aviFile, 2, 48000, 128000, 0, 0x55 );//WAVE_FORMAT_MPEGLAYER3



	while(1)
	{ 


	//	n_old=n;
		if (ReadDataMp4(fmp4, buf, 720*576*3, 0, 0, &len) ==0 )
			break;
	    	n++;
        AVI_write_frame(aviFile, buf, len);


	/*	   if(AVI_write_frame(aviFile, buf, len)==-1)
		   {
		    	printf("avi write vidos worry. \n");
            	return 0;
		   }
	*/



/*
		//m_old=m;
        if(ReadDataWav(fwav, buf, &len)==0)
		  break;
	    //	m++;

	     	if(AVI_write_audio(aviFile, buf, len)==-1)///写音频原始PCM数据
			{
	    		printf("avi write audio worry. \n");
            	return 0;
			}	

*/



//	if((n==n_old)&&(m==m_old))
//		break;


	}//while(1)
	


    printf("\n");
	printf(" read mp4 end  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
	printf("mp4:n=%d   ===================\n",n);
//	printf("mp3:m=%d   ===================\n",m);
    printf("the test.avi is writed and file will close !\n");




 //  	fclose(fwav);




	AVI_close(aviFile);


	printf("the avi file has been closed too !\n");
	printf("all end !!!\n");

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?