[xiph-commits] r15235 - in trunk/ffmpeg2theora: . src
j at svn.xiph.org
j at svn.xiph.org
Mon Sep 1 04:26:15 PDT 2008
Author: j
Date: 2008-09-01 04:26:15 -0700 (Mon, 01 Sep 2008)
New Revision: 15235
Modified:
trunk/ffmpeg2theora/
trunk/ffmpeg2theora/ChangeLog
trunk/ffmpeg2theora/ffmpeg2theora.1
trunk/ffmpeg2theora/src/ffmpeg2theora.c
trunk/ffmpeg2theora/src/subtitles.c
trunk/ffmpeg2theora/src/theorautils.c
trunk/ffmpeg2theora/subtitles.txt
Log:
various other cleanup/improvements. by ogg.k.ogg.k to subtitle part, update changelog
Property changes on: trunk/ffmpeg2theora
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2008-08-03 00:13:40.305000067 +0200
committer: j
properties:
branch-nick: ffmpeg2theora
+ timestamp: 2008-09-01 20:21:27.381999969 +0900
committer: j
properties:
branch-nick: ffmpeg2theora
Name: bzr:file-ids
-
+ ChangeLog 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ChangeLog
ffmpeg2theora.1 9490 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.1
src/ffmpeg2theora.c 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c
src/subtitles.c subtitles.c-20080523092315-berdpbqhudpfrkh7-1
src/theorautils.c 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:theorautils.c
subtitles.txt 14612 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:subtitles.txt
Name: bzr:revision-id:v3-single1-dHJ1bmsvZmZtcGVnMnRoZW9yYQ..
- 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
+ 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
225 j-20080901112127-tyeax385hwukjt13
Name: bzr:text-parents
+
Modified: trunk/ffmpeg2theora/ChangeLog
===================================================================
--- trunk/ffmpeg2theora/ChangeLog 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/ChangeLog 2008-09-01 11:26:15 UTC (rev 15235)
@@ -1,7 +1,8 @@
0.22 ???
- enable v4l input again (-f video4linux or -f video4linux2)
- ability to set framerate for image sequences (--inputfps)
- - fix several memory leaks
+ - fix several memory leaks
+ - if only width or height are given, the other is set to preserve aspect ratio
0.21 2008-05-19
- switch default extension to .ogv
Modified: trunk/ffmpeg2theora/ffmpeg2theora.1
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.1 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/ffmpeg2theora.1 2008-09-01 11:26:15 UTC (rev 15235)
@@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
-.TH FFMPEG2THEORA 1 "December 30, 2005"
+.TH FFMPEG2THEORA 1 "August 31, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -148,29 +148,34 @@
.TP
.B \-\-subtitles
Encode subtitles from the given file to a multiplexed Kate stream.
-The input file should be in SubRip (.srt) format, encoded in utf-8,
+The input file should be in SubRip (.srt) format, encoded in UTF-8,
unless the --subtitles-encoding option is also given.
.TP
.B \-\-subtitles-encoding encoding
Assumes the corresponding subtitles file is encoded in the given
-encoding (utf-8 and iso-8859-1 (aka latin1) are supported).
+encoding (UTF-8 and iso-8859-1 (aka latin1) are supported). The
+default is UTF-8.
.TP
.B \-\-subtitles-language language
Sets the language of the corresponding subtitles stream. This will
be set in the corresponding Kate stream so a video player may make
-this available to the user for language selection.
+this available to the user for language selection. Language is an
+ISO 639-1 or RFC 3066 ASCII string and is limited to 15 characters.
.TP
.B \-\-subtitles-category category
Sets the category of the corresponding subtitles stream. This will
be set in the corresponding Kate stream so a video player may make
this available to the user for selection. The default category is
"subtitles". Suggested other categories may include "transcript",
-"commentary", "lyrics", etc.
+"commentary", "lyrics", etc. Category is an ASCII string and is
+limited to 15 characters
.TP
.B \-\-subtitles-ignore-non-utf8
-When reading an utf-8 subtitles text file, any invalid utf-8 sequence
+When reading an UTF-8 subtitles text file, any invalid UTF-8 sequence
will be ignored. This may be useful if there are stray sequences in
-an otherwise utf-8 file.
+an otherwise UTF-8 file. Note that, since those invalid sequences
+will be removed from the output, this option is not a substitute to
+converting a non UTF-8 file to UTF-8.
.SS Metadata options:
.TP
.B \-\-artist
Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c 2008-09-01 11:26:15 UTC (rev 15235)
@@ -289,7 +289,7 @@
}
void ff2theora_output(ff2theora this) {
- int i;
+ unsigned int i;
AVCodecContext *aenc = NULL;
AVCodecContext *venc = NULL;
AVStream *astream = NULL;
@@ -1339,7 +1339,7 @@
break;
case PP_FLAG:
if(!strcmp(optarg, "help")) {
- fprintf(stdout, pp_help);
+ fprintf(stdout, "%s", pp_help);
exit(1);
}
snprintf(convert->pp_mode,sizeof(convert->pp_mode),"%s",optarg);
@@ -1496,7 +1496,8 @@
info.with_skeleton=1;
break;
case 'P':
- sprintf(pidfile_name,optarg);
+ snprintf(pidfile_name, sizeof(pidfile_name), "%s", optarg);
+ pidfile_name[sizeof(pidfile_name)-1] = '\0';
break;
case 'f':
input_fmt=av_find_input_format(optarg);
Modified: trunk/ffmpeg2theora/src/subtitles.c
===================================================================
--- trunk/ffmpeg2theora/src/subtitles.c 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/src/subtitles.c 2008-09-01 11:26:15 UTC (rev 15235)
@@ -131,7 +131,7 @@
}
/* very simple implementation when no iconv */
-static void convert_subtitle_to_utf8(F2T_ENCODING encoding,unsigned char *text,int ignore_non_utf8)
+static void convert_subtitle_to_utf8(F2T_ENCODING encoding,char *text,int ignore_non_utf8)
{
size_t nbytes;
char *ptr,*newtext;
@@ -151,7 +151,7 @@
size_t wlen0;
nbytes = strlen(text)+1;
- newtext=(unsigned char*)malloc(nbytes);
+ newtext=(char*)malloc(nbytes);
if (!newtext) {
fprintf(stderr, "WARNING - Memory allocation failed - cannot convert text\n");
return;
@@ -193,18 +193,18 @@
nbytes=0;
for (ptr=text;*ptr;++ptr) {
nbytes++;
- if (0x80&*ptr) nbytes++;
+ if (0x80&*(unsigned char*)ptr) nbytes++;
}
- newtext=(unsigned char*)malloc(1+nbytes);
+ newtext=(char*)malloc(1+nbytes);
if (!newtext) {
fprintf(stderr, "WARNING - Memory allocation failed - cannot convert text\n");
return;
}
nbytes=0;
for (ptr=text;*ptr;++ptr) {
- if (0x80&*ptr) {
- newtext[nbytes++]=0xc0|((*ptr)>>6);
- newtext[nbytes++]=0x80|((*ptr)&0x3f);
+ if (0x80&*(unsigned char*)ptr) {
+ newtext[nbytes++]=0xc0|((*(unsigned char*)ptr)>>6);
+ newtext[nbytes++]=0x80|((*(unsigned char*)ptr)&0x3f);
}
else {
newtext[nbytes++]=*ptr;
@@ -222,8 +222,10 @@
static void remove_last_newline(char *text)
{
- char *ptr = text+strlen(text)-1;
- if (*ptr=='\n') *ptr=0;
+ if (*text) {
+ char *ptr = text+strlen(text)-1;
+ if (*ptr=='\n') *ptr=0;
+ }
}
#endif
@@ -242,9 +244,12 @@
double t1=0.0;
static char str[4096];
int warned=0;
+ FILE *f;
+ size_t len;
+ unsigned int line=0;
this->subtitles = NULL;
- FILE *f = fopen(this->filename, "r");
+ f = fopen(this->filename, "r");
if (!f) {
fprintf(stderr,"WARNING - Failed to open subtitles file %s (%s)\n", this->filename, strerror(errno));
return -1;
@@ -258,27 +263,33 @@
}
fgets2(str,sizeof(str),f);
+ ++line;
while (!feof(f)) {
switch (need) {
case need_id:
- ret=sscanf(str,"%d\n",&id);
- if (ret!=1) {
- fprintf(stderr,"WARNING - Syntax error: %s\n",str);
- fclose(f);
- free(this->subtitles);
- return -1;
+ if (!strcmp(str,"\n")) {
+ /* be nice and ignore extra empty lines between records */
}
- if (id!=last_seen_id+1) {
- fprintf(stderr,"WARNING - non consecutive ids: %s - pretending not to have noticed\n",str);
+ else {
+ ret=sscanf(str,"%d\n",&id);
+ if (ret!=1) {
+ fprintf(stderr,"WARNING - %s:%u: Syntax error: %s\n",this->filename,line,str);
+ fclose(f);
+ free(this->subtitles);
+ return -1;
+ }
+ if (id!=last_seen_id+1) {
+ fprintf(stderr,"WARNING - %s:%u: non consecutive ids: %s - pretending not to have noticed\n",this->filename,line,str);
+ }
+ last_seen_id=id;
+ need=need_timing;
+ strcpy(text,"");
}
- last_seen_id=id;
- need=need_timing;
- strcpy(text,"");
break;
case need_timing:
ret=sscanf(str,"%d:%d:%d%*[.,]%d --> %d:%d:%d%*[.,]%d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1);
if (ret!=8) {
- fprintf(stderr,"WARNING - Syntax error: %s\n",str);
+ fprintf(stderr,"WARNING - %s:%u: Syntax error: %s\n",this->filename,line,str);
fclose(f);
free(this->subtitles);
return -1;
@@ -295,8 +306,8 @@
remove_last_newline(text);
/* we want all text to be UTF8 */
- convert_subtitle_to_utf8(this->subtitles_encoding,(unsigned char*)text,ignore_non_utf8);
- size_t len = strlen(text);
+ convert_subtitle_to_utf8(this->subtitles_encoding,text,ignore_non_utf8);
+ len = strlen(text);
this->subtitles = (ff2theora_subtitle*)realloc(this->subtitles, (this->num_subtitles+1)*sizeof(ff2theora_subtitle));
if (!this->subtitles) {
fprintf(stderr, "Out of memory\n");
@@ -307,7 +318,7 @@
ret=kate_text_validate(kate_utf8,text,len+1);
if (ret<0) {
if (!warned) {
- fprintf(stderr,"WARNING: subtitle %s is not valid utf-8\n",text);
+ fprintf(stderr,"WARNING - %s:%u: subtitle %s is not valid utf-8\n",this->filename,line,text);
fprintf(stderr," further invalid subtitles will NOT be flagged\n");
warned=1;
}
@@ -327,15 +338,27 @@
need=need_id;
}
else {
- strcat(text,str);
+ /* in case of very long subtitles */
+ len=strlen(text);
+ if (len+strlen(str) >= sizeof(text)) {
+ fprintf(stderr,"WARNING - %s:%u: subtitle text is too long - truncated\n",this->filename,line);
+ }
+ strncpy(text+len,str,sizeof(text)-len);
+ text[sizeof(text)-1]=0;
}
break;
}
fgets2(str,sizeof(str),f);
+ ++line;
}
fclose(f);
+ if (need!=need_id) {
+ /* shouldn't be a problem though, but warn */
+ fprintf(stderr,"WARNING - %s:%u: missing data in %s - truncated file ?\n",this->filename,line,this->filename);
+ }
+
/* fprintf(stderr," %u subtitles loaded.\n", this->num_subtitles); */
return this->num_subtitles;
Modified: trunk/ffmpeg2theora/src/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.c 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/src/theorautils.c 2008-09-01 11:26:15 UTC (rev 15235)
@@ -73,6 +73,7 @@
info->with_kate = 0;
info->n_kate_streams = 0;
+ info->kate_streams = NULL;
}
void oggmux_setup_kate_streams(oggmux_info *info, int n_kate_streams)
@@ -80,6 +81,7 @@
int n;
info->n_kate_streams = n_kate_streams;
+ info->kate_streams = NULL;
if (n_kate_streams == 0) return;
info->kate_streams = (oggmux_kate_stream*)malloc(n_kate_streams*sizeof(oggmux_kate_stream));
for (n=0; n<n_kate_streams; ++n) {
@@ -295,9 +297,15 @@
oggmux_kate_stream *ks=info->kate_streams+n;
ogg_stream_init (&ks->ko, rand ()); /* oops, add one ot the above */
ret = kate_encode_init (&ks->k, &ks->ki);
- if (ret<0) fprintf(stderr, "kate_encode_init: %d\n",ret);
+ if (ret<0) {
+ fprintf(stderr, "kate_encode_init: %d\n",ret);
+ exit(1);
+ }
ret = kate_comment_init(&ks->kc);
- if (ret<0) fprintf(stderr, "kate_comment_init: %d\n",ret);
+ if (ret<0) {
+ fprintf(stderr, "kate_comment_init: %d\n",ret);
+ exit(1);
+ }
kate_comment_add_tag (&ks->kc, "ENCODER",PACKAGE_STRING);
}
#endif
Modified: trunk/ffmpeg2theora/subtitles.txt
===================================================================
--- trunk/ffmpeg2theora/subtitles.txt 2008-09-01 01:22:01 UTC (rev 15234)
+++ trunk/ffmpeg2theora/subtitles.txt 2008-09-01 11:26:15 UTC (rev 15235)
@@ -12,7 +12,7 @@
Subtitles are read from SubRip (.srt) format files and converted to
Kate streams. Those SubRip files must be encoded in utf-8 (7 bit ASCII
-is a subset of utf-8 so are valid input as well). See below for more
+is a subset of utf-8 so is valid input as well). See below for more
information on converting SubRip files with other encodings to utf-8.
Subtitles support requires libkate, available from:
@@ -41,7 +41,8 @@
a language tag according to RFC 3066 (usually a two letter language
code, optionally followed by a dash (or underscore) and a region code.
Examples include en, it, ja, en_GB, de_DE, etc.
- If unspecified, the default is to not set a language.
+ If unspecified, the default is to not set a language. It is however
+ strongly encouraged to set the language.
--subtitles-category <category>
Sets the category of the relevant subtitles stream. Category must be
More information about the commits
mailing list