[xiph-commits] r8238 - in trunk/ffmpeg2theora: . kino_export

j at motherfish-iii.xiph.org j at motherfish-iii.xiph.org
Sat Nov 20 15:40:37 PST 2004


Author: j
Date: 2004-11-20 15:40:36 -0800 (Sat, 20 Nov 2004)
New Revision: 8238

Modified:
   trunk/ffmpeg2theora/ChangeLog
   trunk/ffmpeg2theora/INSTALL
   trunk/ffmpeg2theora/configure.ac
   trunk/ffmpeg2theora/ffmpeg2theora.c
   trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh
Log:
- add new command line options, starttime, endtime
	(thanks to Nilesh Bansal)
- fix compile issues with new version of faad



Modified: trunk/ffmpeg2theora/ChangeLog
===================================================================
--- trunk/ffmpeg2theora/ChangeLog	2004-11-20 19:52:50 UTC (rev 8237)
+++ trunk/ffmpeg2theora/ChangeLog	2004-11-20 23:40:36 UTC (rev 8238)
@@ -1,3 +1,8 @@
+svn 	2004-??-??
+	- add new command line options, starttime, endtime
+	- fix compile issues with new version of faad
+
+
 0.12 	2004-11-18
 	- add more command line options, for bitrate modes, metadata
 	- update kino plugin

Modified: trunk/ffmpeg2theora/INSTALL
===================================================================
--- trunk/ffmpeg2theora/INSTALL	2004-11-20 19:52:50 UTC (rev 8237)
+++ trunk/ffmpeg2theora/INSTALL	2004-11-20 23:40:36 UTC (rev 8238)
@@ -1,7 +1,7 @@
 compiling with configure/make
 ---------------------------------
 you need
--the latest version of libtheora ( http://www.theora.org/files )
+- the latest version of libtheora ( http://www.theora.org/files )
 - ffmpeg 0.4.9-pre1 or cvs ( http://ffmpeg.sf.net ) / by running ./get_ffmpeg_cvs.sh
   configure it with i.e.
   ./configure --enable-faad --enable-vorbis --disable-mp3lame --enable-pp --enable-a52  --enable-pthreads --disable-vhook --disable-v4l --disable-audio-oss --disable-dv1394  --disable-ffmpeg --disable-ffserver --disable-network --enable-gpl

Modified: trunk/ffmpeg2theora/configure.ac
===================================================================
--- trunk/ffmpeg2theora/configure.ac	2004-11-20 19:52:50 UTC (rev 8237)
+++ trunk/ffmpeg2theora/configure.ac	2004-11-20 23:40:36 UTC (rev 8238)
@@ -71,6 +71,9 @@
 AC_CHECK_LIB(faad,faacDecClose, [
   AC_CHECK_HEADER(faad.h, [HAVE_FAAD=yes])
     ],,[-lm -lz])
+AC_CHECK_LIB(faad,NeAACDecInit, [
+  AC_CHECK_HEADER(faad.h, [HAVE_FAAD=yes])
+    ],,[-lm -lz])
 if test "x$HAVE_FAAD" = xyes; then
 	FFMPEG_EXTLIBS="-lfaad"
 	FFMPEG_LIBS="$FFMPEG_LIBS $FFMPEG_EXTLIBS"

Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c	2004-11-20 19:52:50 UTC (rev 8237)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c	2004-11-20 23:40:36 UTC (rev 8238)
@@ -76,6 +76,10 @@
 	int video_y;
 	int frame_x_offset;
 	int frame_y_offset;
+
+	/* In seconds */
+	int start_time;
+	int end_time; 
 }
 *ff2theora;
 
@@ -128,7 +132,8 @@
 		this->frame_bottomBand=0;
 		this->frame_leftBand=0;
 		this->frame_rightBand=0;
-
+		this->start_time=0;
+		this->end_time=0; /* ZERO denotes no end time set */
 	}
 	return this;
 }
@@ -142,7 +147,7 @@
 	AVCodec *acodec = NULL;
 	AVCodec *vcodec = NULL;
 	float frame_aspect;
-	
+	int64_t frame_number=0;
 	double fps = 0.0;
 
 	for (i = 0; i < this->context->nb_streams; i++){
@@ -426,9 +431,31 @@
 		info.vorbis_quality = this->audio_quality;
 		info.vorbis_bitrate = this->audio_bitrate;
 		theoraframes_init (&info);
-	
+		/*seek to start time*/	
+#if LIBAVFORMAT_BUILD <= 4616
+		av_seek_frame( this->context, this->video_index, (int64_t)AV_TIME_BASE*this->start_time);
+#else
+		av_seek_frame( this->context, this->video_index, (int64_t)AV_TIME_BASE*this->start_time, 1);
+#endif
+		/*check for end time and caclulate number of frames to encode*/
+		int no_frames = fps*(this->end_time - this->start_time);
+		if(this->end_time > 0 && no_frames <= 0){
+			fprintf(stderr,"end time has to be bigger than start time\n");
+			exit(1);
+		}
+		if(info.audio_only && (this->end_time>0 || this->start_time>0)){
+			fprintf(stderr,"sorry, right now start/end time does not work for audio only files\n");
+			exit(1);
+		}
 		/* main decoding loop */
-		do{
+		do{	
+			if(no_frames > 0){
+				if(frame_number > no_frames){
+					if(info.debug)
+						fprintf(stderr,"\nreached end specified with --endtime\n");
+					break;
+				}
+			}
 			ret = av_read_frame(this->context,&pkt);
 			if(ret<0){
 				e_o_s=1;
@@ -449,6 +476,9 @@
 						//FIXME: move image resize/deinterlace/colorformat transformation
 						//			into seperate function
 						if(got_picture){
+							//For audio only files command line option"-e" will not work
+							//as we donot increment frame_number in audio section.
+							frame_number++;
 							//FIXME: better colorformat transformation to YUV420P
 							/* might have to cast other progressive formats here */
 							//if(venc->pix_fmt != PIX_FMT_YUV420P){
@@ -644,6 +674,8 @@
 		"\t --audiobitrate,-A\t[45 to 2000] encoding bitrate for audio\n"
 		"\t --samplerate,-H\tset output samplerate in Hz\n"
 		"\t --nosound\t\tdisable the sound from input\n"
+		"\t --endtime,-e\t\tend encoding at this time (in sec)\n"
+		"\t --starttime,-s\t\tstart encoding at this time (in sec)\n"
 		"\t --v2v-preset,-p\tencode file with v2v preset, \n"
 		"\t\t\t\t right now there is preview and pro,\n"
 		"\t\t\t\t '"PACKAGE" -p info' for more informations\n"
@@ -704,7 +736,7 @@
 	av_register_all ();
 	
 	int c,long_option_index;
-	const char *optstring = "o:f:x:y:v:V:a:A:d:H:c:p:N:D:h::";
+	const char *optstring = "o:f:x:y:v:V:a:s:e:A:d:H:c:p:N:D:h::";
 	struct option options [] = {
 	  {"output",required_argument,NULL,'o'},
 	  {"format",required_argument,NULL,'f'},
@@ -726,6 +758,8 @@
 	  {"cropright",required_argument,&cropright_flag,1},
 	  {"cropleft",required_argument,&cropleft_flag,1},
 	  {"inputfps",required_argument,&inputfps_flag,1},
+	  {"starttime",required_argument,NULL,'s'},
+	  {"endtime",required_argument,NULL,'e'},
 
 	  {"artist",required_argument,&metadata_flag,10},
 	  {"title",required_argument,&metadata_flag,11},
@@ -807,6 +841,12 @@
 					metadata_flag=0;
 				}
 				break;
+			case 'e':
+				convert->end_time = atoi(optarg);
+				break;
+			case 's':
+				convert->start_time = atoi(optarg);
+				break;
 			case 'o':
 				sprintf(outputfile_name,optarg);
 				outputfile_set=1;
@@ -955,6 +995,10 @@
 		fprintf(stderr,"output width and hight size must be a multiple of 2.\n");
 		exit(1);
 	}
+	if(convert->end_time <= convert->start_time){
+		fprintf(stderr,"end time has to be bigger than start time\n");
+		exit(1);
+	}
 
 	if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, NULL) >= 0){
 			if (av_find_stream_info (convert->context) >= 0){

Modified: trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh
===================================================================
--- trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh	2004-11-20 19:52:50 UTC (rev 8237)
+++ trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh	2004-11-20 23:40:36 UTC (rev 8238)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# place this script in/usr/share/kino/scripts/exports
+# place this script in /usr/share/kino/scripts/exports
 # and make sure ffmpeg2theora is in $PATH
 #
 #



More information about the commits mailing list