Projects
Multimedia
ffmpeg2theora
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
ffmpeg2theora.spec
Changed
@@ -1,13 +1,13 @@ # norootforbuild -BuildRequires: libffmpeg_oldabi-devel +BuildRequires: libffmpeg-devel BuildRequires: libtheora-devel libmp3lame-devel BuildRequires: libkate-devel scons Name: ffmpeg2theora License: GNU General Public License (GPL) Group: Productivity/Multimedia/Other -Version: 0.27 +Version: 0.28 Release: 1 Summary: A simple converter to create Ogg Theora files URL: http://v2v.cc/~j/ffmpeg2theora/index.html @@ -48,6 +48,8 @@ %doc %{_mandir}/man1/ffmpeg2theora.1* %changelog +* Sun Jul 31 2011 Manfred.Tremmel <Manfred.Tremmel@iiv.de> - 0.28-0.pm.1 +- updated to version 0.28 * Sat Jun 19 2010 Manfred.Tremmel <Manfred.Tremmel@iiv.de> - 0.27-0.pm.1 - updated to version 0.27 * Sat Feb 06 2010 Manfred.Tremmel <Manfred.Tremmel@iiv.de> - 0.26-0.pm.1
View file
ffmpeg2theora-0.27.tar.bz2/get_ffmpeg_svn.sh
Deleted
@@ -1,43 +0,0 @@ -#!/bin/sh - -common="--enable-version3 --enable-gpl --enable-postproc --disable-muxers --disable-encoders --enable-libvorbis" -common="$common --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-doc" - -#optional, if you have those libs installed: -#extra="--enable-libopencore-amrnb --enable-libopencore-amrwb" - -#apt-get install liba52-dev libfaad-dev libgsm1-dev -#extra="$extra--enable-libfaad --enable-libgsm" - -#optional, if you have libvpx installed: -#extra="--enable-libvpx" - -#linux -options="$common --enable-pthreads $extra" - -#mingw32 -uname | grep MINGW && options="$common --enable-memalign-hack --enable-mingw32 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib $extra" - -# load FFMPEG specific properties -. ./ffmpegrev - -#Get ffmpeg from svn -#svn -r $FFMPEG_REVISION co $FFMPEG_SVN $FFMPEG_CO_DIR -#svn update -r $FFMPEG_EXTERNALS_REVISION $FFMPEG_CO_DIR/libswscale - -#Get ffmpeg from svn 0.6 branch -svn co $FFMPEG_SVN $FFMPEG_CO_DIR - -apply_patches() { - cd ffmpeg - for patch in ../patches/*.patch; do - patch -p0 < $patch - done - touch .ffmpeg2theora_patched - cd .. -} - -test -e ffmpeg/.ffmpeg2theora_patched || apply_patches -#configure and build ffmpeg -cd ffmpeg && ./configure $options && make -
View file
ffmpeg2theora-0.27.tar.bz2/patches/6to2channel-resample.patch
Deleted
@@ -1,92 +0,0 @@ -Index: libavcodec/resample.c -=================================================================== ---- libavcodec/resample.c (revision 22168) -+++ libavcodec/resample.c (working copy) -@@ -52,6 +52,17 @@ - unsigned buffer_size2; ///< sizes of allocated buffers - }; - -+/* -+*/ -+static short clip_short(int v) { -+ if (v < -32768) -+ v = -32768; -+ else if (v > 32767) -+ v = 32767; -+ return (short) v; -+} -+ -+ - /* n1: number of samples */ - static void stereo_to_mono(short *output, short *input, int n1) - { -@@ -103,14 +114,43 @@ - } - } - --/* XXX: should use more abstract 'N' channels system */ --static void stereo_split(short *output1, short *output2, short *input, int n) --{ -+/* XXX: make this better. channels will always be >= 2. -+ - Left = front_left + rear_gain * rear_left + center_gain * center -+ - Right = front_right + rear_gain * rear_right + center_gain * center -+ where rear_gain is usually around 0.5-1.0 and center_gain is almost always 0.7 (-3 dB) if I recall correctly. */ -+static void multi_to_stereo_split(short *output1, short *output2, short *input, int n, int channels) { - int i; -+ short l,r; - - for(i=0;i<n;i++) { -- *output1++ = *input++; -- *output2++ = *input++; -+ if (channels == 2) { -+ /* simple stereo to stereo. Input is: l, r */ -+ l = input0; -+ r = input1; -+ } else if (channels == 6) { -+ /* 5.1 to stereo input: fl, fr, c, lfe, rl, rr */ -+ int fl,fr,c,rl,rr,lfe; -+ fl = input0; -+ fr = input1; -+ c = input2; -+ lfe = input3; -+ rl = input4; -+ rr = input5; -+ -+ l = clip_short(fl + (0.5 * rl) + (0.7 * c)); -+ r = clip_short(fr + (0.5 * rr) + (0.7 * c)); -+ } else { -+ /* channels must be 3-5, or >= 7. l, c, r, ? */ -+ l = input0; -+ r = input2; -+ } -+ -+ /* output l & r. */ -+ *output1++ = l; -+ *output2++ = r; -+ -+ /* increment input. */ -+ input += channels; - } - } - -@@ -150,9 +190,9 @@ - { - ReSampleContext *s; - -- if ( input_channels > 2) -+ if ((input_channels > 2) && (input_channels != 6)) - { -- av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n"); -+ av_log(NULL, AV_LOG_ERROR, "Resampling with input channels other than 1,2, or 6 is unsupported.\n"); - return NULL; - } - -@@ -312,7 +352,7 @@ - } else if (s->output_channels >= 2) { - buftmp30 = bufout0; - buftmp31 = bufout1; -- stereo_split(buftmp20, buftmp21, input, nb_samples); -+ multi_to_stereo_split(buftmp20, buftmp21, input, nb_samples, s->input_channels); - } else { - buftmp30 = output; - memcpy(buftmp20, input, nb_samples*sizeof(short));
View file
ffmpeg2theora-0.27.tar.bz2/patches/ogg_duration.patch
Deleted
@@ -1,23 +0,0 @@ -Index: libavformat/oggdec.c -=================================================================== ---- libavformat/oggdec.c (revision 19439) -+++ libavformat/oggdec.c (working copy) -@@ -469,6 +469,18 @@ - ogg->size = size; - ogg_restore (s, 0); - -+ ogg_save (s); -+ url_fseek (s->pb, 0, SEEK_SET); -+ while (!ogg_read_page (s, &i)){ -+ if (ogg->streamsi.granule != -1 && ogg->streamsi.granule != 0 && -+ ogg->streamsi.codec) { -+ s->streamsi->duration -= -+ ogg_gptopts (s, i, ogg->streamsi.granule, NULL); -+ break; -+ } -+ } -+ ogg_restore (s, 0); -+ - return 0; - } -
View file
ffmpeg2theora-0.27.tar.bz2/ChangeLog -> ffmpeg2theora-0.28.tar.bz2/ChangeLog
Changed
@@ -1,3 +1,8 @@ +0.28 2011-07-30 + - select resize method via commandline + - fix 5.1 channel ordering + - update to FFmpeg 0.7 branch + 0.27 2010-06-18 - Use Skeleton 4.0 by default (including index), can be disabled with --skeleton-3 or --no-skeleton
View file
ffmpeg2theora-0.27.tar.bz2/INSTALL -> ffmpeg2theora-0.28.tar.bz2/INSTALL
Changed
@@ -3,7 +3,7 @@ you need - scons (http://www.scons.org/) - the latest version of libtheora <http://downloads.xiph.org/releases/theora/> -- ffmpeg svn <http://ffmpeg.sf.net> by running ./get_ffmpeg_svn.sh +- ffmpeg git <http://ffmpeg.org> by running ./get_ffmpeg.sh (this script downloads ffmpeg and runs configure and compiles ffmpeg) - for subtitles support, libkate <http://code.google.com/p/libkate/>, or by running ./get_libkate.sh (this script downloads libkate, and
View file
ffmpeg2theora-0.27.tar.bz2/SConstruct -> ffmpeg2theora-0.28.tar.bz2/SConstruct
Changed
@@ -5,20 +5,17 @@ import SCons def svnversion(): - f = os.popen("svnversion") + f = os.popen("./version.sh") version = f.read().strip() f.close() return version -pkg_version="0.27" +pkg_version="0.28" #pkg_version +="+svn" + svnversion() pkg_name="ffmpeg2theora" -scons_version=(0,97,0) -#this is needed to make scons -h work, so not checking for it right now -#(i.e. ubuntu hardy only ships with 0.97..) -#scons_version=(0,98,0) +scons_version=(1,2,0) try: EnsureSConsVersion(*scons_version) @@ -26,18 +23,18 @@ print 'SCons %d.%d.%d or greater is required, but you have an older version' % scons_version Exit(2) -opts = Options() -opts.AddOptions( - BoolOption('static', 'Set to 1 for static linking', 0), - BoolOption('debug', 'Set to 1 to enable debugging', 0), +opts = Variables() +opts.AddVariables( + BoolVariable('static', 'Set to 1 for static linking', 0), + BoolVariable('debug', 'Set to 1 to enable debugging', 0), ('prefix', 'install files in', '/usr/local'), ('bindir', 'user executables', 'PREFIX/bin'), ('mandir', 'man documentation', 'PREFIX/man'), ('destdir', 'extra install time prefix', ''), ('APPEND_CCFLAGS', 'Additional C/C++ compiler flags'), ('APPEND_LINKFLAGS', 'Additional linker flags'), - BoolOption('libkate', 'enable libkate support', 1), - BoolOption('crossmingw', 'Set to 1 for crosscompile with mingw', 0) + BoolVariable('libkate', 'enable libkate support', 1), + BoolVariable('crossmingw', 'Set to 1 for crosscompile with mingw', 0) ) env = Environment(options = opts) Help(opts.GenerateHelpText(env)) @@ -139,16 +136,29 @@ Exit(1) ParsePKGConfig(env, XIPH_LIBS) -FFMPEG_LIBS="libavcodec >= 52.30.0", "libavdevice", "libavformat", "libpostproc", "libswscale" +FFMPEG_LIBS= + "libavdevice", + "libavformat", + "libavcodec >= 52.30.0", + "libpostproc", + "libswscale", + "libavutil", + if os.path.exists("./ffmpeg"): - os.environ'PKG_CONFIG_PATH' = "./ffmpeg/libavutil:./ffmpeg/libavformat:./ffmpeg/libavcodec:./ffmpeg/libavdevice:./ffmpeg/libswscale:./ffmpeg/libpostproc:" + os.environ.get('PKG_CONFIG_PATH', '') + pkg_path = list(set(map(os.path.dirname, glob('./ffmpeg/*/*.pc')))) + pkg_path.append(os.environ.get('PKG_CONFIG_PATH', '')) + os.environ'PKG_CONFIG_PATH' = ':'.join(pkg_path) + env.Append(CCFLAGS= + '-Iffmpeg' + ) + if not conf.CheckPKG(' '.join(FFMPEG_LIBS)): print """ Could not find %s. You can install it via sudo apt-get install %s or update PKG_CONFIG_PATH to point to ffmpeg's source folder - or run ./get_ffmpeg_svn.sh (for more information see INSTALL) + or run ./get_ffmpeg.sh (for more information see INSTALL) """ %(" ".join(FFMPEG_LIBS), " ".join("%s-dev"%l.split()0 for l in FFMPEG_LIBS)) Exit(1) @@ -183,7 +193,10 @@ if conf.CheckLib('iconv'): env.Append(LIBS='iconv') -if env'static': +if env'crossmingw': + env.Append(CCFLAGS='-Wl,-subsystem,windows') + env.Append(LIBS='m') +elif env'static': env.Append(LIBS='m', 'dl') env = conf.Finish()
View file
ffmpeg2theora-0.27.tar.bz2/ffmpeg2theora.1 -> ffmpeg2theora-0.28.tar.bz2/ffmpeg2theora.1
Changed
@@ -89,10 +89,10 @@ but it is slower and therefore is disabled by default. .TP .B \-\-speedlevel -encoding is faster with higher values the cost is quality and bandwidth - 0: Slowest (best) - 1: Enable early skip (default) - 2: Disable motion compensation +encoding is faster with higher values +the cost is quality and bandwidth (default 1) +available values depend on the version of libtheora +check ffmpeg2theora --help for supported values. .TP .B \-x, \-\-width Scale to given width (in pixels). @@ -171,6 +171,9 @@ Force deinterlace. Otherwise only material marked as interlaced will be deinterlaced. .TP +.B \-\-no-deinterlace +Force deinterlace off. +.TP .B \-\-vhook you can use ffmpeg's vhook system, example: ffmpeg2theora \-\-vhook '/path/watermark.so \-f wm.gif' input.dv @@ -309,8 +312,10 @@ ffmpeg2theora frame%06d.png -o output.ogv Live streaming from V4L Device: - ffmpeg2theora /dev/video0 \-f video4linux \-\-inputfps 15 \-x 160 \-y 128 \\ - \-o \- | oggfwd icast2server 8000 password /theora.ogv + ffmpeg2theora \-\-no\-skeleton /dev/video0 \-f video4linux \\ + \-\-inputfps 15 \-x 160 \-y 128 \\ + \-o \- | oggfwd icast2server 8000 password /theora.ogv + (you might have to use video4linux2 depending on your hardware) Live encoding from a DV camcorder (needs a fast machine): @@ -318,8 +323,8 @@ Live encoding and streaming to icecast server: dvgrab \-\-format raw \- \\ - | ffmpeg2theora \-f dv \-x 160 \-y 128 \-o /dev/stdout \- \\ - | oggfwd icast2server 8000 password /theora.ogv + | ffmpeg2theora \-\-no\-skeleton \-f dv \-x 160 \-y 128 \-o /dev/stdout \- \\ + | oggfwd icast2server 8000 password /theora.ogv .SH AUTHOR
View file
ffmpeg2theora-0.27.tar.bz2/ffmpegrev -> ffmpeg2theora-0.28.tar.bz2/ffmpegrev
Changed
@@ -1,9 +1,3 @@ FFMPEG_CO_DIR=ffmpeg -FFMPEG_SVN=svn://svn.ffmpeg.org/ffmpeg/branches/0.6 -#not required fro 0.6 branch -# Because ffmpeg checks out libswscale via an svn:externals, checking -# out an old ffmpeg does not check out a corresponding libswscale. -# Keep the swscale checkout manually synchronized, then. Update this -# when you update FFMPEG_REVISION. -#FFMPEG_REVISION=23309 -#FFMPEG_EXTERNALS_REVISION=31211 +FFMPEG_URL=git://git.videolan.org/ffmpeg +#FFMPEG_REVISION=54bc6403620286f595becd01842947395020e2f4
View file
ffmpeg2theora-0.28.tar.bz2/get_ffmpeg.sh
Added
@@ -0,0 +1,43 @@ +#!/bin/sh + +common="--enable-version3 --enable-gpl --enable-postproc --disable-muxers --disable-encoders --enable-libvorbis" +common="$common --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-doc" + +#optional, if you have those libs installed: +#extra="$extra --enable-libopencore-amrnb --enable-libopencore-amrwb" + +#apt-get install liba52-dev libgsm1-dev +#extra="$extra --enable-libgsm" + +#optional, if you have libvpx installed: +#extra="$extra --enable-libvpx" + +#linux +options="$common --enable-pthreads $extra" + +#mingw32 +uname | grep MINGW && options="$common --enable-memalign-hack --enable-mingw32 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib $extra" + +# load FFMPEG specific properties +. ./ffmpegrev + +test -e $FFMPEG_CO_DIR || git clone $FFMPEG_URL $FFMPEG_CO_DIR +cd $FFMPEG_CO_DIR +#git pull -r $FFMPEG_REVISION +git checkout release/0.7 +git pull +cd .. + +apply_patches() { + cd $FFMPEG_CO_DIR + for patch in ../patches/*.patch; do + patch -p0 < $patch + done + touch .ffmpeg2theora_patched + cd .. +} + +#test -e $FFMPEG_CO_DIR/.ffmpeg2theora_patched || apply_patches +#configure and build ffmpeg +cd $FFMPEG_CO_DIR && ./configure $options && make +
View file
ffmpeg2theora-0.27.tar.bz2/get_libkate.sh -> ffmpeg2theora-0.28.tar.bz2/get_libkate.sh
Changed
@@ -1,6 +1,6 @@ #!/bin/bash -version=0.3.7 +version=0.3.8 baseurl="http://libkate.googlecode.com/files/libkate-$version.tar.gz" which wget >& /dev/null
View file
ffmpeg2theora-0.27.tar.bz2/src/avinfo.c -> ffmpeg2theora-0.28.tar.bz2/src/avinfo.c
Changed
@@ -196,7 +196,7 @@ } switch(enc->codec_type) { - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: codec_name = fix_codec_name(codec_name); json_add_key_value(output, "codec", (void *)codec_name, JSON_STRING, 0, indent); if (enc->pix_fmt != PIX_FMT_NONE) { @@ -224,7 +224,7 @@ json_add_key_value(output, "bitrate", &t, JSON_FLOAT, 0, indent); } break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: codec_name = fix_codec_name(codec_name); json_add_key_value(output, "codec", (void *)codec_name, JSON_STRING, 0, indent); if (enc->sample_rate) { @@ -277,15 +277,15 @@ } break; /* - case CODEC_TYPE_DATA: + case AVMEDIA_TYPE_DATA: fprintf(output, "datacodec: %s\n", codec_name); bitrate = enc->bit_rate; break; - case CODEC_TYPE_SUBTITLE: + case AVMEDIA_TYPE_SUBTITLE: fprintf(output, "subtitle: %s\n", codec_name); bitrate = enc->bit_rate; break; - case CODEC_TYPE_ATTACHMENT: + case AVMEDIA_TYPE_ATTACHMENT: fprintf(output, "attachment: : %s\n", codec_name); bitrate = enc->bit_rate; break; @@ -316,21 +316,7 @@ fprintf(output, "{\n"); json_codec_info(output, st->codec, indent + 1); - if (st->sample_aspect_ratio.num && // default - av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { - AVRational display_aspect_ratio; - av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, - st->codec->width*st->sample_aspect_ratio.num, - st->codec->height*st->sample_aspect_ratio.den, - 1024*1024); - snprintf(buf1, sizeof(buf1), "%d:%d", - st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); - json_add_key_value(output, "pixel_aspect_ratio", buf1, JSON_STRING, 0, indent + 1); - snprintf(buf1, sizeof(buf1), "%d:%d", - display_aspect_ratio.num, display_aspect_ratio.den); - json_add_key_value(output, "display_aspect_ratio", buf1, JSON_STRING, 0, indent + 1); - } - if(st->codec->codec_type == CODEC_TYPE_VIDEO){ + if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ if (st->time_base.den && st->time_base.num && av_q2d(st->time_base) > 0.001) { snprintf(buf1, sizeof(buf1), "%d:%d", st->time_base.den, st->time_base.num); @@ -340,6 +326,20 @@ st->r_frame_rate.num, st->r_frame_rate.den); json_add_key_value(output, "framerate", buf1, JSON_STRING, 0, indent + 1); } + if (st->sample_aspect_ratio.num && // default + av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { + AVRational display_aspect_ratio; + av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, + st->codec->width*st->sample_aspect_ratio.num, + st->codec->height*st->sample_aspect_ratio.den, + 1024*1024); + snprintf(buf1, sizeof(buf1), "%d:%d", + st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); + json_add_key_value(output, "pixel_aspect_ratio", buf1, JSON_STRING, 0, indent+1); + snprintf(buf1, sizeof(buf1), "%d:%d", + display_aspect_ratio.num, display_aspect_ratio.den); + json_add_key_value(output, "display_aspect_ratio", buf1, JSON_STRING, 0, indent+1); + } } json_add_key_value(output, "id", &i, JSON_INT, 1, indent + 1); do_indent(output, indent-1); @@ -484,11 +484,11 @@ int j, k; for(j=0; j<ic->nb_programs; j++) { for(k=0; k<ic->programsj->nb_stream_indexes; k++) - json_stream_format(output, ic, ic->programsj->stream_indexk, 2, !k && !j, CODEC_TYPE_VIDEO); + json_stream_format(output, ic, ic->programsj->stream_indexk, 2, !k && !j, AVMEDIA_TYPE_VIDEO); } } else { for(i=0;i<ic->nb_streams;i++) { - json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_VIDEO); + json_stream_format(output, ic, i, 2, !i, AVMEDIA_TYPE_VIDEO); } } fprintf(output, ",\n"); @@ -499,11 +499,11 @@ int j, k; for(j=0; j<ic->nb_programs; j++) { for(k=0; k<ic->programsj->nb_stream_indexes; k++) - json_stream_format(output, ic, ic->programsj->stream_indexk, 2, !k && !j, CODEC_TYPE_AUDIO); + json_stream_format(output, ic, ic->programsj->stream_indexk, 2, !k && !j, AVMEDIA_TYPE_AUDIO); } } else { for(i=0;i<ic->nb_streams;i++) { - json_stream_format(output, ic, i, 2, !i, CODEC_TYPE_AUDIO); + json_stream_format(output, ic, i, 2, !i, AVMEDIA_TYPE_AUDIO); } } fprintf(output, ",\n");
View file
ffmpeg2theora-0.27.tar.bz2/src/ffmpeg2theora.c -> ffmpeg2theora-0.28.tar.bz2/src/ffmpeg2theora.c
Changed
@@ -52,6 +52,7 @@ enum { NULL_FLAG, DEINTERLACE_FLAG, + NODEINTERLACE_FLAG, SOFTTARGET_FLAG, TWOPASS_FLAG, FIRSTPASS_FLAG, @@ -85,6 +86,7 @@ FRONTENDFILE_FLAG, SPEEDLEVEL_FLAG, PP_FLAG, + RESIZE_METHOD_FLAG, NOSKELETON, SKELETON_3, INDEX_INTERVAL, @@ -233,6 +235,8 @@ this->uv_lut_used = 0; this->sws_colorspace_ctx = NULL; this->sws_scale_ctx = NULL; + + this->resize_method = -1; } return this; } @@ -341,7 +345,7 @@ static const char *find_category_for_subtitle_stream (ff2theora this, int idx, int included_subtitles) { AVCodecContext *enc = this->context->streamsidx->codec; - if (enc->codec_type != CODEC_TYPE_SUBTITLE) return 0; + if (enc->codec_type != AVMEDIA_TYPE_SUBTITLE) return 0; switch (enc->codec_id) { case CODEC_ID_TEXT: case CODEC_ID_SSA: @@ -500,9 +504,11 @@ static const char *find_language_for_subtitle_stream(const AVStream *s) { - const char *lang=find_iso639_1(s->language); + AVMetadataTag *language = av_metadata_get(s->metadata, "language", NULL, 0); + const char *lang=find_iso639_1(language->value); if (!lang) { - fprintf(stderr,"WARNING - unrecognized ISO 639-2 language code: %s\n",s->language); + fprintf(stderr, "WARNING - unrecognized ISO 639-2 language code: %s\n", + language->value); } return lang; } @@ -518,11 +524,11 @@ AVCodec *vcodec = NULL; pp_mode_t *ppMode = NULL; pp_context_t *ppContext = NULL; - int sws_flags; + int sws_flags = this->resize_method; float frame_aspect = 0; double fps = 0.0; AVRational vstream_fps; - int display_width, display_height; + int display_width = -1, display_height = -1; char *subtitles_enabled = (char*)alloca(this->context->nb_streams); char *subtitles_opened = (char*)alloca(this->context->nb_streams); int synced = this->start_time == 0.0; @@ -530,7 +536,7 @@ if (this->audiostream >= 0 && this->context->nb_streams > this->audiostream) { AVCodecContext *enc = this->context->streamsthis->audiostream->codec; - if (enc->codec_type == CODEC_TYPE_AUDIO) { + if (enc->codec_type == AVMEDIA_TYPE_AUDIO) { this->audio_index = this->audiostream; fprintf(stderr, " Using stream #0.%d as audio input\n",this->audio_index); } @@ -540,7 +546,7 @@ } if (this->videostream >= 0 && this->context->nb_streams > this->videostream) { AVCodecContext *enc = this->context->streamsthis->videostream->codec; - if (enc->codec_type == CODEC_TYPE_VIDEO) { + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { this->video_index = this->videostream; fprintf(stderr, " Using stream #0.%d as video input\n",this->video_index); } @@ -552,11 +558,11 @@ for (i = 0; i < this->context->nb_streams; i++) { AVCodecContext *enc = this->context->streamsi->codec; switch (enc->codec_type) { - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if (this->video_index < 0 && !this->disable_video) this->video_index = i; break; - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if (this->audio_index < 0 && !this->disable_audio) this->audio_index = i; break; @@ -698,14 +704,10 @@ this->frame_aspect.num = width; this->frame_aspect.den = height; } - if (av_q2d(this->frame_aspect) <= 1.5) { - this->picture_width=128; - this->picture_height=96; - } - else { - this->picture_width=128; - this->picture_height=72; - } + + this->picture_width=128; + this->picture_height=128/av_q2d(this->frame_aspect); + this->frame_aspect.num = this->picture_width; this->frame_aspect.den = this->picture_height; } @@ -851,8 +853,12 @@ fprintf(stderr, " Frame Aspect Ratio: %.2f/1\n", frame_aspect); } - if (!(info.twopass==3 && info.passno==2) && !info.frontend && this->deinterlace==1) + if (!(info.twopass==3 && info.passno==2) && !info.frontend && + this->deinterlace==1) fprintf(stderr, " Deinterlace: on\n"); + if (!(info.twopass==3 && info.passno==2) && !info.frontend && + this->deinterlace==-1) + fprintf(stderr, " Deinterlace: off\n"); if (strcmp(this->pp_mode, "")) { ppContext = pp_get_context(display_width, display_height, PP_FORMAT_420); @@ -882,11 +888,13 @@ this->frame_y_offset = this->frame_height-this->picture_height>>1&~1; //Bicubic (best for upscaling), - if(display_width - (this->frame_leftBand + this->frame_rightBand) < this->picture_width || - display_height - (this->frame_topBand + this->frame_bottomBand) < this->picture_height) { - sws_flags = SWS_BICUBIC; - } else { //Bilinear (best for downscaling), - sws_flags = SWS_BILINEAR; + if (sws_flags < 0) { + if(display_width - (this->frame_leftBand + this->frame_rightBand) < this->picture_width || + display_height - (this->frame_topBand + this->frame_bottomBand) < this->picture_height) { + sws_flags = SWS_BICUBIC; + } else { //Bilinear (best for downscaling), + sws_flags = SWS_BILINEAR; + } } if (this->frame_width > 0 || this->frame_height > 0) { @@ -931,6 +939,7 @@ astream = this->context->streamsthis->audio_index; aenc = this->context->streamsthis->audio_index->codec; acodec = avcodec_find_decoder (aenc->codec_id); + int sample_rate = aenc->sample_rate; if (this->channels < 1) { this->channels = aenc->channels; } @@ -946,19 +955,19 @@ } if (acodec != NULL && avcodec_open (aenc, acodec) >= 0) { - if (this->sample_rate != aenc->sample_rate + if (this->sample_rate != sample_rate || this->channels != aenc->channels || aenc->sample_fmt != SAMPLE_FMT_S16) { // values take from libavcodec/resample.c this->audio_resample_ctx = av_audio_resample_init(this->channels, aenc->channels, - this->sample_rate, aenc->sample_rate, + this->sample_rate, sample_rate, SAMPLE_FMT_S16, aenc->sample_fmt, 16, 10, 0, 0.8); if (!this->audio_resample_ctx) { this->channels = aenc->channels; } - if (!info.frontend && this->sample_rate!=aenc->sample_rate) - fprintf(stderr, " Resample: %dHz => %dHz\n",aenc->sample_rate,this->sample_rate); + if (!info.frontend && this->sample_rate!=sample_rate) + fprintf(stderr, " Resample: %dHz => %dHz\n", sample_rate,this->sample_rate); if (!info.frontend && this->channels!=aenc->channels) fprintf(stderr, " Channels: %d => %d\n",aenc->channels,this->channels); } @@ -980,7 +989,7 @@ AVStream *stream = this->context->streamsi; AVCodecContext *enc = stream->codec; const char *category; - if (enc->codec_type == CODEC_TYPE_SUBTITLE) { + if (enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { AVCodec *codec = avcodec_find_decoder (enc->codec_id); if (codec && avcodec_open (enc, codec) >= 0) { subtitles_openedi = 1; @@ -1283,8 +1292,10 @@ ki->gps_denominator = 1; } ki->granule_shift = 32; - ki->original_canvas_width = display_width; - ki->original_canvas_height = display_height; + if (display_width >= 0) + ki->original_canvas_width = display_width; + if (display_height >= 0) + ki->original_canvas_height = display_height; } } }
View file
ffmpeg2theora-0.27.tar.bz2/src/ffmpeg2theora.h -> ffmpeg2theora-0.28.tar.bz2/src/ffmpeg2theora.h
Changed
@@ -13,6 +13,7 @@ kate_palette kp; kate_bitmap kb; #endif + int x1,x2,y1,y2; } ff2theora_subtitle; typedef struct ff2theora_kate_stream{ @@ -75,6 +76,7 @@ int video_bitrate; ogg_uint32_t keyint; char pp_mode255; + int resize_method; AVRational force_input_fps; int sync;
View file
ffmpeg2theora-0.27.tar.bz2/src/subtitles.c -> ffmpeg2theora-0.28.tar.bz2/src/subtitles.c
Changed
@@ -181,14 +181,17 @@ static char *fgets2(char *s,size_t sz,FILE *f) { - char *ret = fgets(s, sz, f); + char *ret = fgets(s, sz, f); + if (ret) { /* fixup DOS newline character */ char *ptr=strchr(s, '\r'); if (ptr) { *ptr='\n'; *(ptr+1)=0; } - return ret; + } + else *s=0; + return ret; } static double hmsms2s(int h,int m,int s,int ms) @@ -331,6 +334,58 @@ } } +static int store_subtitle(ff2theora_kate_stream *this, + char *text, double t0, double t1, int x1, int x2, int y1, int y2, + int ignore_non_utf8,int *warned, unsigned int line, FILE *frontend) +{ + char *utf8; + size_t len; + int ret; + + remove_last_newline(text); + + /* we want all text to be UTF-8 */ + utf8=convert_subtitle_to_utf8(this->subtitles_encoding,text,ignore_non_utf8, frontend); + if (!utf8) { + warn(frontend, this->filename, line, "Failed to get UTF-8 text"); + return -1; + } + + len = strlen(utf8); + this->subtitles = (ff2theora_subtitle*)realloc(this->subtitles, (this->num_subtitles+1)*sizeof(ff2theora_subtitle)); + if (!this->subtitles) { + free(utf8); + warn(frontend, NULL, 0, "Out of memory"); + return -1; + } + ret=kate_text_validate(kate_utf8,utf8,len+1); + if (ret<0) { + if (!*warned) { + warn(frontend, this->filename, line, "subtitle is not valid UTF-8: %s",utf8); + if (!frontend) + fprintf(stderr," further invalid subtitles will NOT be flagged\n"); + *warned=1; + } + } + else { + /* kill off trailing \n characters */ + while (len>0) { + if (utf8len-1=='\n') utf8--len=0; else break; + } + this->subtitlesthis->num_subtitles.text = utf8; + this->subtitlesthis->num_subtitles.len = len; + this->subtitlesthis->num_subtitles.t0 = t0; + this->subtitlesthis->num_subtitles.t1 = t1; + this->subtitlesthis->num_subtitles.x1 = x1; + this->subtitlesthis->num_subtitles.x2 = x2; + this->subtitlesthis->num_subtitles.y1 = y1; + this->subtitlesthis->num_subtitles.y2 = y2; + this->num_subtitles++; + } + + return 0; +} + #endif int load_subtitles(ff2theora_kate_stream *this, int ignore_non_utf8, FILE *frontend) @@ -343,14 +398,13 @@ int id; static char text4096; int h0,m0,s0,ms0,h1,m1,s1,ms1; + int x1,x2,y1,y2; double t0=0.0; double t1=0.0; static char str4096; int warned=0; FILE *f; - size_t len; unsigned int line=0; - char *utf8; this->subtitles = NULL; @@ -374,7 +428,7 @@ fgets2(str,sizeof(str),f); ++line; - while (!feof(f)) { + while (!feof(f) || *str) { switch (need) { case need_id: if (!strcmp(str,"\n")) { @@ -397,68 +451,41 @@ } 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 || (h0|m0|s0|ms0)<0 || (h1|m1|s1|ms1)<0) { - warn(frontend, this->filename, line, "Syntax error: %s",str); + ret=sscanf(str,"%d:%d:%d%*.,%d --> %d:%d:%d%*.,%d %*xX1: %d %*xX2: %d %*yY1: %d %*yY2: %d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1,&x1,&x2,&y1,&y2); + if (ret!=12) { + x1=y1=x2=y2=-INT_MAX; + ret=sscanf(str,"%d:%d:%d%*.,%d --> %d:%d:%d%*.,%d\n",&h0,&m0,&s0,&ms0,&h1,&m1,&s1,&ms1); + if (ret!=8) { + warn(frontend, this->filename, line, "Syntax error: %s",str); + fclose(f); + free(this->subtitles); + return -1; + } + } + t0=hmsms2s(h0,m0,s0,ms0); + t1=hmsms2s(h1,m1,s1,ms1); + if ((h0|m0|s0|ms0)<0 || (h1|m1|s1|ms1)<0) { + warn(frontend, this->filename, line, "Bad timestamp specification: %s",str); fclose(f); free(this->subtitles); return -1; } - else { - t0=hmsms2s(h0,m0,s0,ms0); - t1=hmsms2s(h1,m1,s1,ms1); - } need=need_text; break; case need_text: if (str0=='\n') { /* we have all the lines for that subtitle, remove the last \n */ - remove_last_newline(text); - - /* we want all text to be UTF-8 */ - utf8=convert_subtitle_to_utf8(this->subtitles_encoding,text,ignore_non_utf8, frontend); - if (!utf8) { - warn(frontend, this->filename, line, "Failed to get UTF-8 text"); - fclose(f); - free(this->subtitles); - return -1; - break; - } - - len = strlen(utf8); - this->subtitles = (ff2theora_subtitle*)realloc(this->subtitles, (this->num_subtitles+1)*sizeof(ff2theora_subtitle)); - if (!this->subtitles) { - free(utf8); - warn(frontend, NULL, 0, "Out of memory"); + int ret = store_subtitle(this, text, t0, t1, x1, x2, y1, y2, ignore_non_utf8, &warned, line, frontend); + if (ret < 0) { fclose(f); free(this->subtitles); - return -1; - } - ret=kate_text_validate(kate_utf8,utf8,len+1); - if (ret<0) { - if (!warned) { - warn(frontend, this->filename, line, "subtitle is not valid UTF-8: %s",utf8); - if (!frontend) - fprintf(stderr," further invalid subtitles will NOT be flagged\n"); - warned=1; - } - } - else { - /* kill off trailing \n characters */ - while (len>0) { - if (utf8len-1=='\n') utf8--len=0; else break; - } - this->subtitlesthis->num_subtitles.text = utf8; - this->subtitlesthis->num_subtitles.len = len; - this->subtitlesthis->num_subtitles.t0 = t0; - this->subtitlesthis->num_subtitles.t1 = t1; - this->num_subtitles++; + return ret; } need=need_id; } else { /* in case of very long subtitles */ - len=strlen(text); + size_t len=strlen(text); if (len+strlen(str) >= sizeof(text)) { warn(frontend, this->filename, line, "Subtitle text is too long - truncated"); } @@ -473,13 +500,20 @@ fclose(f); -#if 0 - // there seems to be quite a lot of files like this, so disable this test. if (need!=need_id) { /* shouldn't be a problem though, but warn */
View file
ffmpeg2theora-0.27.tar.bz2/src/theorautils.c -> ffmpeg2theora-0.28.tar.bz2/src/theorautils.c
Changed
@@ -106,6 +106,8 @@ info->prev_vorbis_window = -1; info->content_offset = 0; + + info->serialno = 0; } void oggmux_setup_kate_streams(oggmux_info *info, int n_kate_streams) @@ -813,7 +815,8 @@ /* yayness. Set up Ogg output stream */ srand (time (NULL)); - ogg_stream_init (&info->vo, rand ()); + info->serialno = rand(); + ogg_stream_init (&info->vo, info->serialno++); if (info->passno!=1) { th_comment_add_tag(&info->tc, "ENCODER", PACKAGE_STRING); @@ -825,7 +828,7 @@ } if (!info->audio_only) { - ogg_stream_init (&info->to, rand ()); /* oops, add one ot the above */ + ogg_stream_init (&info->to, info->serialno++); seek_index_init(&info->theora_index, info->index_interval); } /* init theora done */ @@ -851,6 +854,7 @@ vorbis_block_init (&info->vd, &info->vb); seek_index_init(&info->vorbis_index, info->index_interval); + info->vorbis_granulepos = 0; } /* audio init done */ @@ -860,7 +864,7 @@ int ret, n; for (n=0; n<info->n_kate_streams; ++n) { oggmux_kate_stream *ks=info->kate_streams+n; - ogg_stream_init (&ks->ko, rand ()); /* oops, add one ot the above */ + ogg_stream_init (&ks->ko, info->serialno++); ret = kate_encode_init (&ks->k, &ks->ki); if (ret<0) { fprintf(stderr, "kate_encode_init: %d\n",ret); @@ -879,7 +883,8 @@ } /* kate init done */ - if (!info->skeleton_3 && + if (info->with_skeleton && + !info->skeleton_3 && info->duration == -1) { /* We've not got a duration, we can't index the keyframes. */ @@ -897,7 +902,7 @@ page with a Skeleton4.0 header page. */ int skeleton_3 = info->skeleton_3; info->skeleton_3 = 1; - ogg_stream_init (&info->so, rand()); + ogg_stream_init (&info->so, info->serialno++); add_fishead_packet (info, 3, 0); if (ogg_stream_pageout (&info->so, &og) != 1) { fprintf (stderr, "Internal Ogg library error.\n"); @@ -921,7 +926,7 @@ exit (1); } ogg_stream_clear (&info->so); - ogg_stream_init (&info->so, rand()); + ogg_stream_init (&info->so, info->serialno++); add_fishead_packet (info, 4, 0); if (ogg_stream_pageout (&info->so, &og) != 1) { fprintf (stderr, "Internal Ogg library error.\n"); @@ -1215,7 +1220,7 @@ void oggmux_add_audio (oggmux_info *info, int16_t * buffer, int bytes, int samples, int e_o_s) { ogg_packet op; - int i,j, count = 0; + int i, j, k, count = 0; float **vorbis_buffer; if (bytes <= 0 && samples <= 0) { @@ -1228,7 +1233,20 @@ /* uninterleave samples */ for (i = 0; i < samples; i++) { for (j=0;j<info->channels;j++) { - vorbis_bufferji = buffercount++ / 32768.f; + k = j; + /* 5.1 input: fl, fr, c, lfe, rl, rr */ + if(info->channels == 6) { + switch(j) { + case 0: k = 0; break; + case 1: k = 2; break; + case 2: k = 1; break; + case 3: k = 5; break; + case 4: k = 3; break; + case 5: k = 4; break; + default: k = j; + } + } + vorbis_bufferki = buffercount++ / 32768.f; } } vorbis_analysis_wrote (&info->vd, samples); @@ -1259,6 +1277,31 @@ info->prev_vorbis_window = info->vb.pcmend; ogg_int64_t start_granule = op.granulepos - num_samples; + if (start_granule < 0) { + /* The first vorbis content packet can have more samples than + its granulepos reports. This is allowed by the spec, and + players should discard the leading samples and not play them. + Thus the indexer needs to discard them as well.*/ + if (op.packetno != 4) { + /* We only expect negative start granule in the first content + packet, not any of the others... */ + fprintf(stderr, "WARNING: vorbis packet %lld has calculated start" + " granule of %lld, but it should be non-negative!", + op.packetno, start_granule); + } + start_granule = 0; + } + if (start_granule < info->vorbis_granulepos) { + /* This packet starts before the end of the previous packet. This is + allowed by the specification in the last packet only, and the + trailing samples should be discarded and not played/indexed. */ + if (!op.e_o_s) { + fprintf(stderr, "WARNING: vorbis packet %lld (granulepos %lld) starts before" + " the end of the preceeding packet!", op.packetno, op.granulepos); + } + start_granule = info->vorbis_granulepos; + } + info->vorbis_granulepos = op.granulepos; ogg_int64_t start_time = vorbis_time (&info->vd, start_granule); if (op.granulepos != -1 && @@ -1303,10 +1346,24 @@ * @param text the utf-8 text * @param len the number of bytes in the text */ -void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len) { +void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len, int x1, int x2, int y1, int y2) { ogg_packet op; oggmux_kate_stream *ks=info->kate_streams+idx; int ret; + if (x1!=-INT_MAX && y1!=-INT_MAX && x2!=-INT_MAX && y2!=-INT_MAX) { + kate_region kr; + kate_region_init(&kr); + kr.metric=kate_pixel; + kr.x=x1; + kr.y=y1; + kr.w=x2-x1+1; + kr.h=y2-y1+1; + ret=kate_encode_set_region(&ks->k,&kr); + if (ret<0) { + fprintf(stderr,"Error setting region: %d\n",ret); + return; + } + } ret = kate_ogg_encode_text(&ks->k, t0, t1, text, len, &op); if (ret>=0) { if (!info->skeleton_3 && info->passno != 1) { @@ -1445,12 +1502,21 @@ else if (timebase - last > 0.5 || timebase < last || !remaining) { last = timebase; if (info->frontend) { +#ifdef WIN32 + fprintf(info->frontend, "{\"duration\": %f, \"position\": %.02f, \"audio_kbps\": %d, \"video_kbps\": %d, \"remaining\": %.02f}\n", + info->duration, + timebase, + info->akbps, info->vkbps, + remaining + ); +#else fprintf(info->frontend, "{\"duration\": %lf, \"position\": %.02lf, \"audio_kbps\": %d, \"video_kbps\": %d, \"remaining\": %.02lf}\n", info->duration, timebase, info->akbps, info->vkbps, remaining ); +#endif fflush (info->frontend); } else if (timebase > 0) {
View file
ffmpeg2theora-0.27.tar.bz2/src/theorautils.h -> ffmpeg2theora-0.28.tar.bz2/src/theorautils.h
Changed
@@ -157,6 +157,10 @@ calculate duration of vorbis packets. */ /* The offset of the first non header page in bytes. */ ogg_int64_t content_offset; + /* Granulepos of the last encoded packet. */ + ogg_int64_t vorbis_granulepos; + + ogg_int32_t serialno; } oggmux_info; @@ -166,7 +170,7 @@ extern void oggmux_add_video (oggmux_info *info, th_ycbcr_buffer ycbcr, int e_o_s); extern void oggmux_add_audio (oggmux_info *info, int16_t * readbuffer, int bytesread, int samplesread,int e_o_s); #ifdef HAVE_KATE -extern void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len); +extern void oggmux_add_kate_text (oggmux_info *info, int idx, double t0, double t1, const char *text, size_t len, int x1, int x2, int y1, int y2); extern void oggmux_add_kate_image (oggmux_info *info, int idx, double t0, double t1, const kate_region *kr, const kate_palette *kp, const kate_bitmap *kb); extern void oggmux_add_kate_end_packet (oggmux_info *info, int idx, double t); #endif
View file
ffmpeg2theora-0.28.tar.bz2/version.sh
Added
@@ -0,0 +1,2 @@ +cd `dirname $0` +svnversion
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.