Revision 1f425cb8

View differences:

chunker_metadata.c
44 44
	int isstrategy;
45 45
	char str[1000];
46 46
	char *p;
47
	printf("Calling chunkerInit...\n");
47
	fprintf(stderr,"Calling chunkerInit...\n");
48 48
	FILE *fp = fopen(config,"r");
49 49
	ChunkerMetadata *cmeta = (ChunkerMetadata *)malloc(sizeof(ChunkerMetadata));
50 50
	cmeta->echunk = NULL;
......
71 71
		}
72 72
	}
73 73
	fclose(fp);
74
	printf("done!\n");
74
	fprintf(stderr,"done!\n");
75 75
	return cmeta;
76 76
}
77 77

  
chunker_streamer.c
177 177
	
178 178
	outbuf_audio_size = 10000;
179 179
	outbuf_audio = malloc(outbuf_audio_size);
180
	printf("Chunkbuffer Strategy:%d Value Strategy:%d\n", cmeta->strategy, cmeta->val_strategy);
180
	fprintf(stderr,"Chunkbuffer Strategy:%d Value Strategy:%d\n", cmeta->strategy, cmeta->val_strategy);
181 181
	f1 = fopen("original.mpg","wb");
182 182

  
183 183
	// Register all formats and codecs
......
197 197
	// Find the first video stream
198 198
	videoStream=-1;
199 199
	audioStream=-1;
200
	printf("Num streams : %d\n",pFormatCtx->nb_streams);
200
	fprintf(stderr,"Num streams : %d\n",pFormatCtx->nb_streams);
201 201
	for(i=0; i<pFormatCtx->nb_streams; i++) {
202 202
		if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO && videoStream<0) {
203 203
			videoStream=i;
......
206 206
			audioStream=i;
207 207
		}
208 208
	}
209
	printf("Video stream has id : %d\n",videoStream);
210
	printf("Audio stream has id : %d\n",audioStream);
209
	fprintf(stderr,"Video stream has id : %d\n",videoStream);
210
	fprintf(stderr,"Audio stream has id : %d\n",audioStream);
211 211

  
212 212
	if(videoStream==-1 && audioStream==-1)
213 213
		return -1; // Didn't find a video stream
......
216 216
	pCodecCtx=pFormatCtx->streams[videoStream]->codec;
217 217
	pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
218 218

  
219
	printf("Width:%d Height:%d\n",pCodecCtx->width,pCodecCtx->height);
219
	fprintf(stderr,"Width:%d Height:%d\n",pCodecCtx->width,pCodecCtx->height);
220 220

  
221 221
	if(audioStream!=-1) {
222 222
		aCodecCtx=pFormatCtx->streams[audioStream]->codec;
223
		printf("AUDIO Codecid: %d %d\n",aCodecCtx->codec_id,aCodecCtx->sample_rate);
224
		printf("AUDIO channels %d samplerate %d\n",aCodecCtx->channels,aCodecCtx->sample_rate);
223
		fprintf(stderr,"AUDIO Codecid: %d %d\n",aCodecCtx->codec_id,aCodecCtx->sample_rate);
224
		fprintf(stderr,"AUDIO channels %d samplerate %d\n",aCodecCtx->channels,aCodecCtx->sample_rate);
225 225
	}
226 226

  
227 227

  
......
249 249
	aCodecCtxEnc->sample_fmt = SAMPLE_FMT_S16;
250 250
	aCodecCtxEnc->sample_rate = 44100;//aCodecCtx->sample_rate;
251 251
	aCodecCtxEnc->channels = 2; //aCodecCtx->channels;
252
        printf("InitAUDIOFRAMESIZE:%d %d\n",aCodecCtxEnc->frame_size,av_rescale(44100,1,25));
252
        fprintf(stderr,"InitAUDIOFRAMESIZE:%d %d\n",aCodecCtxEnc->frame_size,av_rescale(44100,1,25));
253 253

  
254 254
	// Find the decoder for the video stream
255 255
	
......
299 299
	// Allocate video frame
300 300
	pFrame=avcodec_alloc_frame();
301 301
	if(pFrame==NULL) {
302
		printf("Memory error!!!\n");
302
		fprintf(stderr,"Memory error!!!\n");
303 303
		return -1;
304 304
	}
305 305
  
......
307 307
	outbuf_size = 100000;
308 308
	outbuf = malloc(outbuf_size);
309 309
	if(!outbuf) {
310
		printf("Memory error!!!\n");
310
		fprintf(stderr,"Memory error!!!\n");
311 311
		return -1;
312 312
	}
313 313
	frame = (Frame *)malloc(sizeof(Frame));
314 314
	if(!frame) {
315
		printf("Memory error!!!\n");
315
		fprintf(stderr,"Memory error!!!\n");
316 316
		return -1;
317 317
	}
318 318
	sizeFrame = 3*sizeof(int)+sizeof(struct timeval);
319 319
	chunk = (ExternalChunk *)malloc(sizeof(ExternalChunk));
320 320
	if(!chunk) {
321
		printf("Memory error!!!\n");
321
		fprintf(stderr,"Memory error!!!\n");
322 322
		return -1;
323 323
	}
324 324
	sizeChunk = 6*sizeof(int)+2*sizeof(struct timeval)+sizeof(double);
325 325
	initChunk(chunk,&seq_current_chunk);
326 326
	chunkaudio = (ExternalChunk *)malloc(sizeof(ExternalChunk));
327 327
	if(!chunkaudio) {
328
		printf("Memory error!!!\n");
328
		fprintf(stderr,"Memory error!!!\n");
329 329
		return -1;
330 330
	}
331 331
	initChunk(chunkaudio,&seq_current_chunk);
......
361 361
				frame->number = pCodecCtx->frame_number;
362 362
				
363 363
				Now=(long long)SDL_GetTicks();
364
				printf("dts:%d %d %d\n",(int)packet.dts,(int)packet.duration,pCodecCtxEnc->time_base.den);
364
				fprintf(stderr,"dts:%d %d %d\n",(int)packet.dts,(int)packet.duration,pCodecCtxEnc->time_base.den);
365 365
				if(packet.duration>0)
366 366
					newtimestamp = (((int)(packet.dts))/((double)(packet.duration*pCodecCtxEnc->time_base.den)));
367 367
				else
368 368
					newtimestamp =(long double)(((double)(packet.dts))/1000);
369 369
				//frame->timestamp.tv_sec = (long)packet.dts*1.e-5;
370 370
				//frame->timestamp.tv_usec = ((long)packet.dts%100000/100);
371
				printf("ts:%llf\n",newtimestamp);
371
				fprintf(stderr,"ts:%llf\n",newtimestamp);
372 372
				if(FirstTimeVideo) {
373 373
					//printf("%lld\n",Now);
374 374
					DeltaTimeVideo=Now-((unsigned int)newtimestamp*(unsigned long long)1000+(newtimestamp-(unsigned int)newtimestamp)*1000);
......
378 378

  
379 379
				newTime = DeltaTimeVideo+((unsigned int)newtimestamp*(unsigned long long)1000+(newtimestamp-(unsigned int)newtimestamp)*1000);
380 380

  
381
				printf("newTime : %d\n",newTime);
381
				fprintf(stderr,"newTime : %d\n",newTime);
382 382

  
383 383
				frame->timestamp.tv_sec = (unsigned int)newTime/1000;
384 384
				frame->timestamp.tv_usec = newTime%1000;
......
388 388
				//printf("video newt:%lf dts:%ld dur:%d sec:%d usec%d pts:%d\n",newtimestamp,(long)packet.dts,packet.duration,frame->timestamp.tv_sec,frame->timestamp.tv_usec,packet.pts);
389 389
				//printf("num:%d size:%d type:%d\n",frame->number,frame->size,frame->type);
390 390

  
391
				printf("VIDEO: tvsec:%d tvusec:%d\n",frame->timestamp.tv_sec,frame->timestamp.tv_usec);
391
				fprintf(stderr,"VIDEO: tvsec:%d tvusec:%d\n",frame->timestamp.tv_sec,frame->timestamp.tv_usec);
392 392
				// Save the frame to disk
393 393
				++i;
394 394
				//SaveFrame(pFrame, pCodecCtx->width, pCodecCtx->height, i);
......
398 398
				chunk->frames_num++; // number of frames in the current chunk
399 399
				chunk->data = (uint8_t *)realloc(chunk->data,sizeof(uint8_t)*(chunk->payload_len+out_size+sizeFrame));
400 400
				if(!chunk->data)  {
401
					printf("Memory error!!!\n");
401
					fprintf(stderr,"Memory error!!!\n");
402 402
					return -1;
403 403
				}
404 404
        //printf("rialloco data di dim:%d con nuova dim:%d\n",chunk->payload_len,out_size);
......
453 453
				//fwrite(audio_buf, 1, data_size, outfileaudio);
454 454
			}
455 455
			else
456
				printf("Error data_size!!\n");
456
				fprintf(stderr,"Error data_size!!\n");
457 457
			audio_size = avcodec_encode_audio(aCodecCtxEnc,outbuf_audio,data_size,(short *)audio_buf);
458 458
			//printf("audio frame size nuovo pippo : %d %d datasize:%d %d %d\n",aCodecCtxEnc->frame_size,aCodecCtxEnc->time_base.den,data_size,packet.size, len1);
459 459
			//printf("oldaudiosize:%d Audio size : %d\n",len1,audio_size);
......
478 478
                        frame->timestamp.tv_sec = (unsigned int)newTime/1000;
479 479
                        frame->timestamp.tv_usec = newTime%1000;
480 480

  
481
			printf("AUDIO: tvsec:%d tvusec:%d\n",frame->timestamp.tv_sec,frame->timestamp.tv_usec);
481
			fprintf(stderr,"AUDIO: tvsec:%d tvusec:%d\n",frame->timestamp.tv_sec,frame->timestamp.tv_usec);
482 482

  
483 483
			//frame->timestamp.tv_sec = (unsigned int)newtimestamp;
484 484
			//frame->timestamp.tv_usec = (newtimestamp-frame->timestamp.tv_sec)*1000;
......
493 493
			
494 494
			chunkaudio->data = (uint8_t *)realloc(chunkaudio->data,sizeof(uint8_t)*(chunkaudio->payload_len+audio_size+sizeFrame));
495 495
			if(!chunkaudio->data) {
496
				printf("Memory error!!!\n");
496
				fprintf(stderr,"Memory error!!!\n");
497 497
				return -1;
498 498
			}
499 499
			tempdata = chunkaudio->data+chunkaudio->payload_len;
......
564 564
	fclose(f1);
565 565

  
566 566
	// Writing chunk files
567
	printf("cmetasize:%d\n",cmeta->size);
567
	fprintf(stderr,"cmetasize:%d\n",cmeta->size);
568 568
	for(i=0;i<cmeta->size;i++) {
569
		printf("seq:%d pay_len:%d frames_num:%d priority:%f ssec:%d susec:%d esec:%d eusec:%d\n",cmeta->echunk[i].seq,cmeta->echunk[i].payload_len,cmeta->echunk[i].frames_num,cmeta->echunk[i].priority,(int)cmeta->echunk[i].start_time.tv_sec,(int)cmeta->echunk[i].start_time.tv_usec,(int)cmeta->echunk[i].end_time.tv_sec,(int)cmeta->echunk[i].end_time.tv_usec);
569
		fprintf(stderr,"seq:%d pay_len:%d frames_num:%d priority:%f ssec:%d susec:%d esec:%d eusec:%d\n",cmeta->echunk[i].seq,cmeta->echunk[i].payload_len,cmeta->echunk[i].frames_num,cmeta->echunk[i].priority,(int)cmeta->echunk[i].start_time.tv_sec,(int)cmeta->echunk[i].start_time.tv_usec,(int)cmeta->echunk[i].end_time.tv_sec,(int)cmeta->echunk[i].end_time.tv_usec);
570 570
	}
571 571

  
572 572
	// Free the YUV frame
external_chunk_transcoding.c
24 24

  
25 25
void print_block(const uint8_t *b, int size) {
26 26
int i=0;
27
printf("BEGIN OF %d BYTES---\n", size);
27
fprintf(stderr,"BEGIN OF %d BYTES---\n", size);
28 28
for(i=0; i<size; i++) {
29
printf("%d ", *(b+i));
29
fprintf(stderr,"%d ", *(b+i));
30 30
}
31
printf("END OF %d BYTES---\n", size);
31
fprintf(stderr,"END OF %d BYTES---\n", size);
32 32
}
33 33

  
34 34
void chunker_logger(const char *s) {
35
	printf("%s\n", s);
35
	fprintf(stderr,"%s\n", s);
36 36
}
37 37

  
38 38

  
......
83 83
	uint64_t tmp_prio;
84 84
	ExternalChunk *echunk = (ExternalChunk *)malloc(sizeof(ExternalChunk));
85 85
	if(!echunk) {
86
		printf("Memory error in chunkToExternalchunk!\n");
86
		fprintf(stderr,"Memory error in chunkToExternalchunk!\n");
87 87
		return NULL;
88 88
	}
89 89
	/* pull out info from the attributes block from the grapes chunk */

Also available in: Unified diff