Revision 80515685

View differences:

chunker_streamer/chunker_streamer.c
49 49
int max_b_frames = 1;
50 50
bool vcopy = false;
51 51

  
52
long delay_audio = 0; //delay audio by x millisec
53

  
52 54
// Constant number of frames per chunk
53 55
int chunkFilledFramesStrategy(ExternalChunk *echunk, int chunkType)
54 56
{
......
212 214
	/* `getopt_long' stores the option index here. */
213 215
	int option_index = 0, c;
214 216
	int mandatories = 0;
215
	while ((c = getopt_long (argc, argv, "i:a:v:A:V:s:lop:q:tF:g:b:", long_options, &option_index)) != -1)
217
	while ((c = getopt_long (argc, argv, "i:a:v:A:V:s:lop:q:tF:g:b:d:", long_options, &option_index)) != -1)
216 218
	{
217 219
		switch (c) {
218 220
			case 0: //for long options
......
262 264
			case 'b':
263 265
				sscanf(optarg, "%d", &max_b_frames);
264 266
				break;
267
			case 'd':
268
				sscanf(optarg, "%d", &delay_audio);
269
				break;
265 270
			default:
266 271
				print_usage(argc, argv);
267 272
				return -1;
......
1031 1036
					continue; //SKIP THIS FRAME, bad timestamp
1032 1037
				}
1033 1038

  
1034
				frame->timestamp.tv_sec = (unsigned int)newTime/1000;
1035
				frame->timestamp.tv_usec = newTime%1000;
1039
				frame->timestamp.tv_sec = (unsigned int)(newTime + delay_audio)/1000;
1040
				frame->timestamp.tv_usec = (newTime + delay_audio)%1000;
1036 1041
				frame->size = audio_frame_size;
1037 1042
				frame->type = 5; // 5 is audio type
1038 1043
#ifdef DEBUG_AUDIO_FRAMES
1039
				fprintf(stderr, "AUDIO: pts %d duration %d timebase %d %d dts %d\n", (int)packet.pts, (int)packet.duration, pFormatCtx->streams[audioStream]->time_base.num, pFormatCtx->streams[audioStream]->time_base.den, (int)packet.dts);
1044
				fprintf(stderr, "AUDIO: pts %lld duration %d timebase %d %lld dts %d\n", packet.pts, (int)packet.duration, pFormatCtx->streams[audioStream]->time_base.num, pFormatCtx->streams[audioStream]->time_base.den, packet.dts);
1040 1045
				fprintf(stderr, "AUDIO: timestamp sec:%d usec:%d\n", frame->timestamp.tv_sec, frame->timestamp.tv_usec);
1041 1046
				fprintf(stderr, "AUDIO: deltaaudio %lld\n", delta_audio);	
1042 1047
#endif

Also available in: Unified diff