Revision 2f5ae7bb chunker_player/player_core.c

View differences:

chunker_player/player_core.c
13 13
#include <assert.h>
14 14
#include <time.h>
15 15

  
16
static char *video_codec;
17

  
16 18
void SaveFrame(AVFrame *pFrame, int width, int height);
17 19
int VideoCallback(void *valthread);
18 20
int CollectStatisticsThread(void *params);
......
250 252
	return res;
251 253
}
252 254

  
253
int ChunkerPlayerCore_InitCodecs(int width, int height, int sample_rate, short int audio_channels)
255
int ChunkerPlayerCore_InitCodecs(char *v_codec, int width, int height, char *audio_codec, int sample_rate, short int audio_channels)
254 256
{
257
	video_codec = v_codec;
258

  
255 259
	// some initializations
256 260
	QueueStopped = 0;
257 261
	AudioQueueOffset=0;
......
279 283
	//aCodecCtx->bit_rate = 64000;
280 284
	aCodecCtx->sample_rate = sample_rate;
281 285
	aCodecCtx->channels = audio_channels;
282
#ifdef MP3_AUDIO_ENCODER
283
	aCodec = avcodec_find_decoder(CODEC_ID_MP3); // codec audio
284
#else
285
	aCodec = avcodec_find_decoder(CODEC_ID_MP2);
286
#endif
287
	printf("MP2 codec id %d MP3 codec id %d\n",CODEC_ID_MP2,CODEC_ID_MP3);
286
	aCodec = avcodec_find_decoder_by_name(audio_codec);
288 287
	if(!aCodec) {
289 288
		printf("Codec not found!\n");
290 289
		return -1;
......
758 757

  
759 758
	//frecon = fopen("recondechunk.mpg","wb");
760 759

  
760
	//setup video decoder
761
	pCodec = avcodec_find_decoder_by_name(video_codec);
762
	if (pCodec) {
763
		fprintf(stderr, "INIT: Setting VIDEO codecID to: %d\n",pCodec->id);
764
	} else {
765
		fprintf(stderr, "INIT: Unknown VIDEO codec: %s!\n", video_codec);
766
		return -1; // Codec not found
767
	}
768

  
761 769
	pCodecCtx=avcodec_alloc_context();
762 770
	pCodecCtx->codec_type = CODEC_TYPE_VIDEO;
763 771
	//pCodecCtx->debug = FF_DEBUG_DCT_COEFF;
764
#ifdef H264_VIDEO_ENCODER
765
	pCodecCtx->codec_id  = CODEC_ID_H264;
766
	pCodecCtx->me_range = 16;
767
	pCodecCtx->max_qdiff = 4;
768
	pCodecCtx->qmin = 1;
769
	pCodecCtx->qmax = 30;
770
	pCodecCtx->qcompress = 0.6;
771
#else
772
	pCodecCtx->codec_id  = CODEC_ID_MPEG4;
773
#endif
772
	pCodecCtx->codec_id = pCodec->id;
773

  
774 774
	//pCodecCtx->bit_rate = 400000;
775 775
	// resolution must be a multiple of two
776 776
	pCodecCtx->width = tval->width;//176;//352;

Also available in: Unified diff