Revision 2f5ae7bb

View differences:

chunker_player/chunker_player.c
30 30
#include <windows.h>
31 31
#endif
32 32

  
33
static char *audio_codec = "mp2";
34
static char *video_codec = "mpeg4";
35

  
33 36
int ReadALine(FILE* fp, char* Output, int MaxOutputSize)
34 37
{
35 38
    int i=0;
......
96 99
    "\t[-c ChannelName]: channel name (from channels.conf)\n"
97 100
    "\t[-p port]: player http port\n\n"
98 101
    "Other options:\n"
102
    "\t[-A audiocodec]\n"
103
    "\t[-V videocodec]\n"
99 104
    "\t[-t]: log traces (WARNING: old traces will be deleted).\n"
100 105
    "\t[-s mode]: silent mode (no GUI) (mode=1 audio ON, mode=2 audio OFF, mode=3 audio OFF; P2P OFF).\n\n"
101 106
    "=======================================================\n", argv[0]
......
149 154
	int mandatories = 0;
150 155
	
151 156
	char c;
152
	while ((c = getopt (argc, argv, "q:c:p:s:t")) != -1)
157
	while ((c = getopt (argc, argv, "q:c:p:A:V:s:t")) != -1)
153 158
	{
154 159
		switch (c) {
155 160
			case 0: //for long options
......
171 176
#endif
172 177
				mandatories++;
173 178
				break;
179
			case 'A':
180
				audio_codec = strdup(optarg);
181
				break;
182
			case 'V':
183
				video_codec = strdup(optarg);
184
				break;
174 185
			case 's':
175 186
				sscanf(optarg, "%d", &SilentMode);
176 187
				break;
......
583 594
	ChunkerPlayerCore_SetupOverlay(w, h);
584 595
	//ChunkerPlayerGUI_SetupOverlayRect(channel);
585 596
	
586
	if(ChunkerPlayerCore_InitCodecs(channel->Width, channel->Height, channel->SampleRate, channel->AudioChannels) < 0)
597
	if(ChunkerPlayerCore_InitCodecs(video_codec, channel->Width, channel->Height, audio_codec, channel->SampleRate, channel->AudioChannels) < 0)
587 598
	{
588 599
		printf("ERROR, COULD NOT INITIALIZE CODECS\n");
589 600
		exit(2);
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;
chunker_player/player_core.h
118 118
long int LastSavedVFrame;
119 119
unsigned char LastSourceIFrameDistance;
120 120

  
121
int ChunkerPlayerCore_InitCodecs(int width, int height, int sample_rate, short audio_channels);
121
int ChunkerPlayerCore_InitCodecs(char *v_codec, int width, int height, char *audio_codec, int sample_rate, short int audio_channels);
122 122
int ChunkerPlayerCore_AudioEnded();
123 123
void ChunkerPlayerCore_Stop();
124 124
void ChunkerPlayerCore_Play();

Also available in: Unified diff