[xiph-commits] r6863 - in trunk: . ffmpeg2theora
j at dactyl.lonelymoon.com
j
Fri Jun 25 13:58:00 PDT 2004
ffmpeg2theora/kino_export
Message-ID: <20040625205800.20BBA9AAAB at dactyl.lonelymoon.com>
Author: j
Date: Fri Jun 25 13:58:00 2004
New Revision: 6863
Added:
trunk/ffmpeg2theora/
trunk/ffmpeg2theora/AUTHORS
trunk/ffmpeg2theora/COPYING
trunk/ffmpeg2theora/ChangeLog
trunk/ffmpeg2theora/INSTALL
trunk/ffmpeg2theora/Makefile.am
trunk/ffmpeg2theora/Makefile.mingw32
trunk/ffmpeg2theora/NEWS
trunk/ffmpeg2theora/README
trunk/ffmpeg2theora/TODO
trunk/ffmpeg2theora/autogen.sh
trunk/ffmpeg2theora/configure.ac
trunk/ffmpeg2theora/ffmpeg2theora.c
trunk/ffmpeg2theora/get_ffmpeg_cvs.sh
trunk/ffmpeg2theora/kino_export/
trunk/ffmpeg2theora/kino_export/README
trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh
trunk/ffmpeg2theora/theorautils.c
trunk/ffmpeg2theora/theorautils.h
Log:
initial import of ffmpeg2theora into svn.xiph.org
Added: trunk/ffmpeg2theora/AUTHORS
===================================================================
--- trunk/ffmpeg2theora/AUTHORS 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/AUTHORS 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1 @@
+jan gerber <j at v2v.cc>
Added: trunk/ffmpeg2theora/COPYING
===================================================================
--- trunk/ffmpeg2theora/COPYING 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/COPYING 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Added: trunk/ffmpeg2theora/ChangeLog
===================================================================
--- trunk/ffmpeg2theora/ChangeLog 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/ChangeLog 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,42 @@
+0.8 2004-06-19 18:47:14
+ - use ffmpeg aspect ration if possible
+ - normalize quality options to 0-10
+ - fix skipping issues with a/v sync
+
+0.7.1 2004-05-31 01:55:40
+ - added --enable-ffmpegcvs to link against ffmpeg from cvs
+ - try to find and link to shared avcodec/avformat
+ if source not found
+
+0.7 2004-05-30 18:40:40
+ - add comandline options for audio/video quality
+ - fix bug causing crashes with DV files, without resizing
+ - use autotools
+
+0.6 2004-05-06 13:47:30
+ - added resize option
+
+0.5.1 2004-03-27 21:59:40
+ - fix kino export
+ - add -f fmt do define input format.
+
+0.5 2004-03-27 19:59:40
+ - link against shared library on linux
+ - kino export module and support to read from stdin
+ [works only to some extend for now]
+
+0.4
+ - fix wrong deinterlaceing
+ - change memory allocation to work with mingw32
+
+0.3
+ - make encoding of audio only files possible.
+ can be used to transcode audio files[mp4,wav,ac3...] to ogg vorbis now
+ time to call if ffmpeg2ogg?
+ - some code cleanup
+
+0.2
+ - added deinterlace support
+
+0.1
+ - initial version
Added: trunk/ffmpeg2theora/INSTALL
===================================================================
--- trunk/ffmpeg2theora/INSTALL 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/INSTALL 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,27 @@
+compiling with configure/make
+---------------------------------
+you need
+-the latest version of libtheora ( http://www.theora.org/files )
+- ffmpeg 0.4.8 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 --disable-vhook --disable-v4l --disable-audio-oss --disable-dv1394 --disable-ffmpeg --disable-ffserver --disable-network --enable-gpl
+ [note: if you use ffmpeg from cvs you have to run configure with
+ --enable-ffmpegcvs ]
+
+now run:
+./configure [--with-ffmpegprefix=/path/to/ffmpeg_src]
+make
+
+
+cross compiling with mingw32
+----------------------------------------------
+
+ you need to crosscompiled libvorbis,libogg,libtheora
+
+ you need ffmpeg, to build it and install it to /usr/local/win32:
+./configure --prefix=/usr/local/win32/build --enable-vorbis --enable-shared --enable-shared-pp --enable-mingw32 --cc=i586-mingw32msvc-gcc
+ make
+ make install
+
+ to build ffmpeg2theora
+ make -f Makefile.mingw32
Added: trunk/ffmpeg2theora/Makefile.am
===================================================================
--- trunk/ffmpeg2theora/Makefile.am 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/Makefile.am 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,9 @@
+AUTOMAKE_OPTIONS = 1.6 dist-zip
+
+EXTRA="-D_FILE_OFFSET_BITS=64"
+
+bin_PROGRAMS = ffmpeg2theora
+
+ffmpeg2theora_SOURCES = ffmpeg2theora.c theorautils.c
+ffmpeg2theora_LDFLAGS = -static @FFMPEG_LIBS@ @XIPH_LIBS@
+ffmpeg2theora_CFLAGS = $(EXTRA) @XIPH_CFLAGS@ @FFMPEG_CFLAGS@
Added: trunk/ffmpeg2theora/Makefile.mingw32
===================================================================
--- trunk/ffmpeg2theora/Makefile.mingw32 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/Makefile.mingw32 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,34 @@
+#Makefile for ffmpeg2theora/mingw32
+#
+#
+
+CC=i586-mingw32msvc-gcc
+CFLAGS=-O3 -s -D_FILE_OFFSET_BITS=64
+
+MINGW32LIBS=/usr/local/win32/build/lib
+FFMPEG=/usr/local/win32/src/ffmpeg
+MINGW32INCLUDE=-I/usr/local/win32/build/include
+#LINKFLAGS= -static -ltheora -lvorbis -lvorbisenc -lz -lm $(MINGW32LIBS)/avformat.dll $(MINGW32LIBS)/avcodec.dll -static
+LINKFLAGS= -static $(MINGW32LIBS)/libtheora.a $(FFMPEG)/libavformat/avformat.dll $(FFMPEG)/libavcodec/libavcodec.a $(MINGW32LIBS)/libvorbis.a $(MINGW32LIBS)/libvorbisenc.a $(MINGW32LIBS)/libogg.a -lz -lm
+
+BIN=ffmpeg2theora.exe
+
+
+all: $(BIN)
+
+theorautils.o:
+ $(CC) $(CFLAGS) $(INCLUDE) $(MINGW32INCLUDE) $(MINGW32INCLUDE)/ffmpeg \
+ -c -o theorautils.o theorautils.c
+
+ffmpeg2theora.o:
+ $(CC) $(CFLAGS) $(INCLUDE) $(MINGW32INCLUDE) $(MINGW32INCLUDE)/ffmpeg \
+ -c -o ffmpeg2theora.o ffmpeg2theora.c
+
+$(BIN): ffmpeg2theora.o theorautils.o
+ $(CC) $(CFLAGS) -o $(BIN) ffmpeg2theora.o theorautils.o \
+ $(LINKFLAGS) -L$(MINGW32LIBS)
+ upx $(BIN)
+
+clean:
+ rm -f $(BIN)
+ rm -f *.o core *.core
Added: trunk/ffmpeg2theora/NEWS
===================================================================
Added: trunk/ffmpeg2theora/README
===================================================================
--- trunk/ffmpeg2theora/README 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/README 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,16 @@
+ffmpeg2theora
+
+with ffmpeg2theora you can convert any file that ffmpeg can
+decode to theora. right now the settings are hardcoded into
+the binary. the idea is to provide ffmpeg2theora as a binary
+along sites like v2v.cc to enable as many people as possible
+to encode video clips with the same settings.
+
+
+usage right now:
+ ./ffmpeg2theora clip.avi
+ will produce clip.avi.ogg
+ for more options run ffmpeg2theora -h
+
+ there is a export plugin for kino (http://kino.schirmacher.de/)
+ more info in kino_export/README
Added: trunk/ffmpeg2theora/TODO
===================================================================
--- trunk/ffmpeg2theora/TODO 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/TODO 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,5 @@
+- remove global variable info and outfile
+- more commandline options
+- fix bug that results in bad ogg packages than
+ using mpeg1/2 files as input with ffmpeg-0.48
+
Added: trunk/ffmpeg2theora/autogen.sh
===================================================================
--- trunk/ffmpeg2theora/autogen.sh 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/autogen.sh 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure --enable-maintainer-mode "$@"
Property changes on: trunk/ffmpeg2theora/autogen.sh
___________________________________________________________________
Name: svn:executable
+
Added: trunk/ffmpeg2theora/configure.ac
===================================================================
--- trunk/ffmpeg2theora/configure.ac 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/configure.ac 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,66 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.53)
+AC_INIT(ffmpeg2theora,0.8.1)
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+AM_DISABLE_SHARED
+AM_ENABLE_STATIC
+
+AC_PROG_CC
+AM_PROG_LIBTOOL
+
+dnl ffmpeg integration here
+AC_ARG_WITH(ffmpegprefix,
+ AS_HELP_STRING([--with-ffmpegprefix],
+ [prefix to ffmpeg source, if libavcodec and libavformat are not in . (default=.)]),
+ ffmpegprefix="$withval", ffmpegprefix="ffmpeg")
+
+AC_CHECK_FILES([$ffmpegprefix/libavcodec/libavcodec.a $ffmpegprefix/libavformat/libavformat.a],[HAVE_FFMPEG=yes])
+if test "x$HAVE_FFMPEG" != xyes; then
+ AC_CHECK_HEADER(ffmpeg/avcodec.h,[HAVE_SHARED_AVCODEC=yes])
+ AC_CHECK_HEADER(ffmpeg/avformat.h, [HAVE_SHARED_AVFORMAT=yes])
+ if test "x$HAVE_SHARED_AVCODEC$HAVE_SHARED_AVCODEC" != xyesyes; then
+ AC_MSG_ERROR([
+ you need libavcodec and libavformat from ffmpeg cvs
+ to get it run get_ffmpeg_cvs.sh or point configure to
+ your local copy with i.e.
+ ./configure --with-ffmpegprefix=/usr/local/src/ffmpeg
+ (see INSTALL for more information)
+ ])
+ else
+ dnl try to link against shared libs
+ dnl might need to check for the libs
+ FFMPEG_CFLAGS="-I/usr/include/ffmpeg -I/usr/local/include/ffmpeg"
+ FFMPEG_EXTLIBS="-lm -lz"
+ FFMPEG_LIBS="-lavformat -lavcodec -lm -lz"
+ fi
+ break
+else
+ dnl just link against shared libs for now.
+ FFMPEG_CFLAGS="-I$ffmpegprefix/libavformat -I$ffmpegprefix/libavcodec"
+ FFMPEG_EXTLIBS="-lm -lz"
+ FFMPEG_LIBS="$ffmpegprefix/libavformat/libavformat.a $ffmpegprefix/libavcodec/libavcodec.a $FFMPEG_EXTLIBS"
+fi
+
+dnl keep track of the api
+AC_ARG_ENABLE(ffmpegcvs,AS_HELP_STRING([--enable-ffmpegcvs],[use ffmpeg from cvs(to track api changes)]),ffmpegcvs="yes",ffmpegcvs="no")
+if test "x$ffmpegcvs" = xyes; then
+ FFMPEG_CFLAGS="$FFMPEG_CFLAGS -DFFMPEGCVS"
+fi
+
+AC_CHECK_LIB(faad,faacDecClose, [
+ 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"
+fi
+AC_SUBST(FFMPEG_CFLAGS)
+AC_SUBST(FFMPEG_LIBS)
+
+PKG_CHECK_MODULES(XIPH,ogg >= 1.1 vorbis vorbisenc theora )
+
+AC_SUBST(XIPH_CFLAGS)
+AC_SUBST(XIPH_LIBS)
+AC_OUTPUT([Makefile])
Added: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,543 @@
+/*
+ * ffmpeg2theora.c -- Convert ffmpeg supported a/v files to Ogg Theora
+ * Copyright (C) 2003-2004 <j at thing.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include "common.h"
+#include "avformat.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+
+#include "theora/theora.h"
+#include "vorbis/codec.h"
+#include "vorbis/vorbisenc.h"
+
+#include "theorautils.h"
+
+static double rint(double x)
+{
+ if (x < 0.0)
+ return (double)(int)(x - 0.5);
+ else
+ return (double)(int)(x + 0.5);
+}
+
+FILE *outfile;
+theoraframes_info info;
+static int using_stdin = 0;
+
+typedef struct ff2theora{
+ AVFormatContext *context;
+ int video_index;
+ int audio_index;
+
+ int frequency;
+ int channels;
+ int disable_audio;
+ float audio_quality;
+
+ int output_width;
+ int output_height;
+ double fps;
+ int audio_resample;
+ ImgReSampleContext *img_resample_ctx; /* for image resampling/resizing */
+ double aspect_numerator;
+ double aspect_denominator;
+ int video_quality;
+}
+*ff2theora;
+
+/* Allocate and initialise an AVFrame. */
+AVFrame *alloc_picture (int pix_fmt, int width, int height){
+ AVFrame *picture;
+ uint8_t *picture_buf;
+ int size;
+
+ picture = avcodec_alloc_frame ();
+ if (!picture)
+ return NULL;
+ size = avpicture_get_size (pix_fmt, width, height);
+ picture_buf = av_malloc (size);
+ if (!picture_buf){
+ av_free (picture);
+ return NULL;
+ }
+ avpicture_fill ((AVPicture *) picture, picture_buf,
+ pix_fmt, width, height);
+ return picture;
+}
+
+ff2theora ff2theora_init (){
+ ff2theora this = calloc (1, sizeof (*this));
+ if (this != NULL){
+ // initialise with sane values here.
+ this->disable_audio=0;
+ this->video_index = -1;
+ this->audio_index = -1;
+ this->frequency = 44100; // samplerate hmhmhm
+ this->channels = 2;
+ this->output_width=0; // set to 0 to not resize the output
+ this->output_height=0; // set to 0 to not resize the output
+ this->video_quality=31.5; // video quality 5
+ this->audio_quality=0.297;// audio quality 3
+ this->aspect_numerator=0;
+ this->aspect_denominator=0;
+ }
+ return this;
+}
+
+void ff2theora_output(ff2theora this) {
+ int i;
+ AVCodecContext *aenc = NULL;
+ AVCodecContext *venc = NULL;
+ AVStream *astream = NULL;
+ AVStream *vstream = NULL;
+ AVCodec *acodec = NULL;
+ AVCodec *vcodec = NULL;
+ ReSampleContext *resample = NULL;
+
+ double fps = 0.0;
+
+ for (i = 0; i < this->context->nb_streams; i++){
+ AVCodecContext *enc = &this->context->streams[i]->codec;
+ switch (enc->codec_type){
+ case CODEC_TYPE_VIDEO:
+ if (this->video_index < 0)
+ this->video_index = i;
+ break;
+ case CODEC_TYPE_AUDIO:
+ if (this->audio_index < 0 && !this->disable_audio)
+ this->audio_index = i;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (this->video_index >= 0){
+ vstream = this->context->streams[this->video_index];
+ venc = &this->context->streams[this->video_index]->codec;
+ vcodec = avcodec_find_decoder (venc->codec_id);
+ fps = (double) venc->frame_rate / venc->frame_rate_base;
+#ifdef FFMPEGCVS
+ if(venc->sample_aspect_ratio.num!=0){
+ this->aspect_numerator=venc->sample_aspect_ratio.num*(float)venc->width;
+ this->aspect_denominator=venc->sample_aspect_ratio.den*(float)venc->height;
+ //fprintf(stderr," Aspect %.2f/1\n",this->aspect_numerator/this->aspect_denominator);
+ }
+#else
+ if(venc->aspect_ratio!=0){
+ this->aspect_numerator=venc->aspect_ratio*10000;
+ this->aspect_denominator=10000;
+ //fprintf(stderr," Aspect %.2f/1\n",this->aspect_numerator/this->aspect_denominator);
+ }
+
+#endif
+ if (fps > 10000)
+ fps /= 1000;
+ if (vcodec == NULL || avcodec_open (venc, vcodec) < 0)
+ this->video_index = -1;
+ this->fps = fps;
+
+ if(this->output_height>0){
+ // we might need that for values other than /16?
+ int frame_topBand=0;
+ int frame_bottomBand=0;
+ int frame_leftBand=0;
+ int frame_rightBand=0;
+ int frame_padtop=0, frame_padbottom=0;
+ int frame_padleft=0, frame_padright=0;
+ /* ffmpeg cvs version */
+#ifdef FFMPEGCVS
+ this->img_resample_ctx = img_resample_full_init(
+ this->output_width, this->output_height,
+ venc->width, venc->height,
+ frame_topBand, frame_bottomBand,
+ frame_leftBand, frame_rightBand,
+ frame_padtop, frame_padbottom,
+ frame_padleft, frame_padright
+ );
+#else
+ /* ffmpeg 0.48 */
+ this->img_resample_ctx = img_resample_full_init(
+ this->output_width, this->output_height,
+ venc->width, venc->height,
+ frame_topBand, frame_bottomBand,
+ frame_leftBand, frame_rightBand
+ );
+#endif
+ fprintf(stderr," Resize: %dx%d => %dx%d\n",venc->width,venc->height,this->output_width,this->output_height);
+ }
+ else {
+ this->output_height=venc->height;
+ this->output_width=venc->width;
+ }
+
+ }
+
+ if (this->audio_index >= 0){
+ astream = this->context->streams[this->audio_index];
+ aenc = &this->context->streams[this->audio_index]->codec;
+ acodec = avcodec_find_decoder (aenc->codec_id);
+ if (this->channels != aenc->channels && aenc->codec_id == CODEC_ID_AC3)
+ aenc->channels = this->channels;
+ if (acodec != NULL && avcodec_open (aenc, acodec) >= 0)
+ resample = audio_resample_init (this->channels,aenc->channels,this->frequency,aenc->sample_rate);
+ else
+ this->audio_index = -1;
+ }
+
+ if (this->video_index >= 0 || this->audio_index >=0){
+ AVFrame *frame=NULL;
+ AVFrame *frame_tmp=NULL;
+ AVFrame *output=NULL;
+ AVFrame *output_tmp=NULL;
+ AVFrame *output_resized=NULL;
+
+ AVPacket pkt;
+ int len;
+ int len1;
+ int got_picture;
+ int first = 1;
+ uint8_t *ptr;
+ int16_t *audio_buf= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ int16_t *resampled= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
+
+ if(this->video_index >= 0)
+ info.audio_only=0;
+ else
+ info.audio_only=1;
+
+ if(this->audio_index>=0)
+ info.video_only=0;
+ else
+ info.video_only=1;
+
+ int ret;
+ if(!info.audio_only){
+ frame = alloc_picture(vstream->codec.pix_fmt,
+ vstream->codec.width,vstream->codec.height);
+ frame_tmp = alloc_picture(vstream->codec.pix_fmt,
+ vstream->codec.width,vstream->codec.height);
+ output_tmp =alloc_picture(PIX_FMT_YUV420P,
+ vstream->codec.width,vstream->codec.height);
+ output =alloc_picture(PIX_FMT_YUV420P,
+ vstream->codec.width,vstream->codec.height);
+ output_resized =alloc_picture(PIX_FMT_YUV420P,
+ this->output_width,this->output_height);
+ }
+
+ if(!info.audio_only){
+ /* video settings here */
+ /* config file? commandline options? v2v presets? */
+ theora_info_init (&info.ti);
+ info.ti.width = this->output_width;
+ info.ti.height = this->output_height;
+ info.ti.frame_width = this->output_width;
+ info.ti.frame_height = this->output_height;
+ info.ti.offset_x = 0;
+ info.ti.offset_y = 0;
+ info.ti.fps_numerator = 1000000 * (this->fps); /* fps= numerator/denominator */
+ info.ti.fps_denominator = 1000000;
+ /*
+ DV NTSC
+ 4:3 10:11 720x480
+ 16:9 40:33 720x480
+ DV PAL
+ 4:3 59:54 720x576
+ 16:9 118:81 720x576
+ ---
+ so this is the aspect ratio of the frame 4/3, 16/9 etc */
+ info.ti.aspect_numerator=this->aspect_numerator;
+ info.ti.aspect_denominator=this->aspect_denominator;
+ if(this->fps==25)
+ info.ti.colorspace = OC_CS_ITU_REC_470BG;
+ else if(abs(this->fps-30)<1)
+ info.ti.colorspace = OC_CS_ITU_REC_470M;
+ else
+ info.ti.colorspace = OC_CS_UNSPECIFIED;
+ //info.ti.target_bitrate=1200;
+ info.ti.quality = this->video_quality;
+ info.ti.dropframes_p = 0;
+ info.ti.quick_p = 1;
+ info.ti.keyframe_auto_p = 1;
+ info.ti.keyframe_frequency = 64;
+ info.ti.keyframe_frequency_force = 64;
+ //info.ti.keyframe_data_target_bitrate = info.ti.target_bitrate * 1.5;
+ info.ti.keyframe_auto_threshold = 80;
+ info.ti.keyframe_mindistance = 8;
+ info.ti.noise_sensitivity = 1;
+ }
+ /* audio settings here */
+ info.channels = this->channels;
+ info.frequency = this->frequency;
+ info.vorbis_quality = this->audio_quality;
+ theoraframes_init ();
+
+ do{
+ ret = av_read_packet (this->context, &pkt);
+
+ ptr = pkt.data;
+ len = pkt.size;
+
+ if (ret >= 0 && pkt.stream_index == this->video_index){
+
+ if(len == 0 && !first){
+ fprintf (stderr, "no frame available\n");
+ }
+ while(len > 0){
+ len1 = avcodec_decode_video(&vstream->codec, frame,&got_picture, ptr, len);
+ if(len1 < 0)
+ break;
+
+ if(got_picture){
+ /* might have to cast other progressive formats here */
+ if(venc->pix_fmt != PIX_FMT_YUV420P){
+ img_convert((AVPicture *)output,PIX_FMT_YUV420P,
+ (AVPicture *)frame,venc->pix_fmt,
+ venc->width,venc->height);
+
+ if(avpicture_deinterlace((AVPicture *)output_tmp,
+ (AVPicture *)output,PIX_FMT_YUV420P
+ ,venc->width,venc->height)<0){
+ output_tmp = output;
+ }
+ }
+ else{
+ /* there must be better way to do this, it seems to work like this though */
+ if(frame->linesize[0] != vstream->codec.width){
+ img_convert((AVPicture *)output_tmp,PIX_FMT_YUV420P,
+ (AVPicture *)frame,venc->pix_fmt,venc->width,venc->height);
+ }
+ else{
+ output_tmp=frame;
+ }
+ }
+ // now output_tmp
+ if(this->img_resample_ctx){
+ img_resample(this->img_resample_ctx,
+ (AVPicture *)output_resized, (AVPicture *)output_tmp);
+ }
+ else{
+ output_resized=output_tmp;
+ }
+ // now output_resized
+ first = 0;
+ if(theoraframes_add_video(output_resized->data[0],
+ this->output_width,this->output_height,output_resized->linesize[0])){
+ ret = -1;
+ fprintf (stderr,"No theora frames available\n");
+ break;
+ }
+ }
+ ptr += len1;
+ len -= len1;
+ }
+ }
+ else if(ret >= 0 && pkt.stream_index == this->audio_index){
+ int data_size;
+ while(len > 0 ){
+ len1 = avcodec_decode_audio(&astream->codec, audio_buf,&data_size, ptr, len);
+ if (len1 < 0 || data_size ==0) {
+ /* if error, we skip the frame */
+ break;
+ }
+
+ len -= len1;
+ ptr += len1;
+ if(data_size >0){
+ int samples =data_size / (aenc->channels * 2);
+ int samples_out = audio_resample(resample, resampled, audio_buf, samples);
+ if (theoraframes_add_audio(resampled, samples_out *(aenc->channels),samples_out)){
+ ret = -1;
+ fprintf (stderr,"No audio frames available\n");
+ break;
+ }
+ }
+ }
+ }
+
+ /* flush out the file */
+ theoraframes_flush ();
+ av_free_packet (&pkt);
+ }
+ while (ret >= 0);
+
+ av_free(audio_buf);
+
+ if (this->img_resample_ctx)
+ img_resample_close(this->img_resample_ctx);
+ if (this->audio_resample)
+ audio_resample_close(resample);
+
+ av_free(resampled);
+ theoraframes_close ();
+ }
+ else{
+ fprintf (stderr, "No video or audio stream found\n");
+ }
+}
+
+void ff2theora_close (ff2theora this){
+ /* clear out state */
+ av_free (this);
+}
+
+void print_usage (){
+ fprintf (stderr,
+ PACKAGE " " PACKAGE_VERSION "\n\n"
+ " usage: " PACKAGE " [options] input\n\n"
+ " Options:\n"
+ "\t --output,-o alternative output\n"
+ "\t --format,-f specify input format\n"
+ "\t --width, -x scale to given size\n"
+ "\t --height,-y scale to given size\n"
+ "\t --videoquality,-v encoding quality for video ( 1 to 10)\n"
+ "\t --audioquality,-a encoding quality for audio (-1 to 10)\n"
+ "\t --nosound,-n disable the sound from input, generate video only file\n"
+ "\t --help,-h this message\n"
+ "\n Examples:\n"
+
+ "\tffmpeg2theora videoclip.avi (will write output to videoclip.avi.ogg)\n\n"
+ "\tcat something.dv | ffmpeg2theora -f dv -o output.ogg -\n\n"
+ "\tLive encoding from a DV camcorder (needs a fast machine)\n"
+ "\tdvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -o output.ogg -\n"
+ "\n\tLive encoding and streaming to icecast server:\n"
+ "\t dvgrab --format raw - | \\\n"
+ "\t ffmpeg2theora -f dv -x 160 -y 128 -o /dev/stdout - | \\\n"
+ "\t oggfwd iccast2server 8000 password /theora.ogg\n"
+ "\n");
+ exit (0);
+}
+
+int main (int argc, char **argv){
+ int outputfile_set=0;
+ char outputfile_name[255];
+ char inputfile_name[255];
+ AVInputFormat *input_fmt=NULL;
+ ff2theora convert = ff2theora_init ();
+ av_register_all ();
+
+ int c,long_option_index;
+ const char *optstring = "o:f:x:y:v:a:n:h::";
+ struct option options [] = {
+ {"output",required_argument,NULL,'o'},
+ {"format",required_argument,NULL,'f'},
+ {"width",required_argument,NULL,'x'},
+ {"height",required_argument,NULL,'y'},
+ {"videoquality",required_argument,NULL,'v'},
+ {"audioquality",required_argument,NULL,'a'},
+ {"nosound",required_argument,NULL,'n'},
+ {"help",NULL,NULL,'h'},
+ {NULL,0,NULL,0}
+ };
+ if (argc == 1){
+ print_usage ();
+ }
+
+ while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF){
+ switch(c)
+ {
+ case 'o':
+ sprintf(outputfile_name,optarg);
+ outputfile_set=1;
+ break;
+ case 'f':
+ input_fmt=av_find_input_format(optarg);
+ break;
+ case 'x':
+ convert->output_width=atoi(optarg);
+ break;
+ case 'y':
+ convert->output_height=atoi(optarg);
+ break;
+ case 'v':
+ convert->video_quality = rint(atof(optarg)*6.3);
+ if(convert->video_quality <0 || convert->video_quality >63){
+ fprintf(stderr,"video quality out of range (choose 0 through 10)\n");
+ exit(1);
+ }
+ break;
+ case 'a':
+ convert->audio_quality=atof(optarg)*.099;
+ if(convert->audio_quality<-.1 || convert->audio_quality>1){
+ fprintf(stderr,"audio quality out of range (choose -1 through 10)\n");
+ exit(1);
+ }
+ break;
+ case 'n':
+ convert->disable_audio=1;
+ break;
+ case 'h':
+ print_usage ();
+ exit(1);
+ }
+ }
+
+ while(optind<argc){
+ /* assume that anything following the options must be a filename */
+ if(!strcmp(argv[optind],"-")){
+ sprintf(inputfile_name,"pipe:");
+ }
+ else{
+ sprintf(inputfile_name,"%s",argv[optind]);
+ if(outputfile_set!=1){
+ sprintf(outputfile_name,"%s.ogg",argv[optind]);
+ outputfile_set=1;
+ }
+ }
+ optind++;
+ }
+ using_stdin |= !strcmp(inputfile_name, "pipe:" ) ||
+ !strcmp( inputfile_name, "/dev/stdin" );
+
+ if(outputfile_set!=1){
+ fprintf(stderr,"you have to specifie an output file with -o output.ogg.\n");
+ exit(1);
+ }
+
+ if(convert->output_width % 16 || convert->output_height % 16){
+ fprintf(stderr,"output size must be a multiple of 16 for now.\n");
+ exit(1);
+ }
+
+ if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, NULL) >= 0){
+ outfile = fopen(outputfile_name,"wb");
+ if (av_find_stream_info (convert->context) >= 0){
+ dump_format (convert->context, 0,inputfile_name, 0);
+ if(convert->disable_audio){
+ fprintf(stderr," [audio disabled].\n");
+ }
+ ff2theora_output (convert);
+ convert->audio_index =convert->video_index = -1;
+ }
+ else{
+ fprintf (stderr,"Unable to decode input\n");
+ }
+ av_close_input_file (convert->context);
+ }
+ else{
+ fprintf (stderr, "Unable to open file %s\n", inputfile_name);
+ }
+ ff2theora_close (convert);
+ fprintf(stderr,"\n");
+ return(0);
+}
Added: trunk/ffmpeg2theora/get_ffmpeg_cvs.sh
===================================================================
--- trunk/ffmpeg2theora/get_ffmpeg_cvs.sh 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/get_ffmpeg_cvs.sh 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,2 @@
+#!/bin/sh
+cvs -d:pserver:cvs.mplayerhq.hu:/ffmpeg/ co ffmpeg
Property changes on: trunk/ffmpeg2theora/get_ffmpeg_cvs.sh
___________________________________________________________________
Name: svn:executable
+
Added: trunk/ffmpeg2theora/kino_export/README
===================================================================
--- trunk/ffmpeg2theora/kino_export/README 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/kino_export/README 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,3 @@
+put ffmpeg2theora.sh into /usr/share/kino/scripts/exports
+ffmpeg2theora needs to be in PATH
+
Added: trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh
===================================================================
--- trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+usage()
+{
+ # Title
+ echo "Title: OggTheora Export(ffmpeg2theora)"
+
+ # Usable?
+ command -v ffmpeg2theora --help 2> /dev/null
+ [ $? -eq 0 ] && echo Status: Active || echo Status: Inactive
+
+ # Type
+ echo Flags: single-pass file-producer
+}
+
+execute()
+{
+ # Arguments
+ normalisation="$1"
+ length="$2"
+ profile="$3"
+ file="$4"
+
+ # Determine info arguments
+ size=`[ "$normalisation" = "pal" ] && echo 352x288 || echo 352x240`
+ video_bitrate=1152
+ audio_bitrate=224
+
+ # Run the command
+ #ffmpeg -f dv -i - -f vcd -deinterlace -r "$normalisation" -s "$size" -b "$video_bitrate" -acodec mp2 -ab "$audio_bitrate" -y "$file".mpeg
+ [ "x$file" = "x" ] && file="kino_export_"`date +%Y-%m-%d_%H.%M.%S`
+ ffmpeg2theora -f dv -o "$file".ogg -
+}
+
+[ "$1" = "--usage" ] || [ -z "$1" ] && usage "$@" || execute "$@"
Property changes on: trunk/ffmpeg2theora/kino_export/ffmpeg2theora.sh
___________________________________________________________________
Name: svn:executable
+
Added: trunk/ffmpeg2theora/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/theorautils.c 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/theorautils.c 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,316 @@
+/*
+ * theorautils.c - Ogg Theora abstraction layer
+ * Copyright (C) 2003-2004 <j at thing.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#include "common.h"
+#include "avformat.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "theora/theora.h"
+#include "vorbis/codec.h"
+#include "vorbis/vorbisenc.h"
+
+#include "theorautils.h"
+
+FILE *outfile;
+theoraframes_info info;
+double timebase;
+
+
+
+static double rint(double x)
+{
+ if (x < 0.0)
+ return (double)(int)(x - 0.5);
+ else
+ return (double)(int)(x + 0.5);
+}
+
+void theoraframes_init (){
+ info.audio_bytesout = 0;
+ info.video_bytesout = 0;
+
+ /* yayness. Set up Ogg output stream */
+ srand (time (NULL));
+ ogg_stream_init (&info.vo, rand ());
+
+ if(!info.audio_only){
+ ogg_stream_init (&info.to, rand ()); /* oops, add one ot the above */
+ theora_encode_init (&info.td, &info.ti);
+ theora_info_clear (&info.ti);
+ }
+ /* init theora done */
+
+ /* initialize Vorbis too, if we have audio. */
+ if(!info.video_only){
+ vorbis_info_init (&info.vi);
+ /* Encoding using a VBR quality mode. */
+ int ret =vorbis_encode_init_vbr (&info.vi, info.channels,info.frequency,info.vorbis_quality);
+
+ if (ret){
+ fprintf (stderr,
+ "The Vorbis encoder could not set up a mode according to\n"
+ "the requested quality or bitrate.\n\n");
+ exit (1);
+ }
+
+ vorbis_comment_init (&info.vc);
+ vorbis_comment_add_tag (&info.vc, "ENCODER",PACKAGE_STRING);
+ /* set up the analysis state and auxiliary encoding storage */
+ vorbis_analysis_init (&info.vd, &info.vi);
+ vorbis_block_init (&info.vd, &info.vb);
+
+ }
+ /* audio init done */
+
+ /* write the bitstream header packets with proper page interleave */
+
+ /* first packet will get its own page automatically */
+ if(!info.audio_only){
+ theora_encode_header (&info.td, &info.op);
+ ogg_stream_packetin (&info.to, &info.op);
+ if (ogg_stream_pageout (&info.to, &info.og) != 1){
+ fprintf (stderr, "Internal Ogg library error.\n");
+ exit (1);
+ }
+ fwrite (info.og.header, 1, info.og.header_len, outfile);
+ fwrite (info.og.body, 1, info.og.body_len, outfile);
+
+ /* create the remaining theora headers */
+ theora_comment_init (&info.tc);
+ theora_encode_comment (&info.tc, &info.op);
+ ogg_stream_packetin (&info.to, &info.op);
+ theora_encode_tables (&info.td, &info.op);
+ ogg_stream_packetin (&info.to, &info.op);
+ }
+ if(!info.video_only){
+ ogg_packet header;
+ ogg_packet header_comm;
+ ogg_packet header_code;
+
+ vorbis_analysis_headerout (&info.vd, &info.vc, &header,
+ &header_comm, &header_code);
+ ogg_stream_packetin (&info.vo, &header); /* automatically placed in its own
+ * page */
+ if (ogg_stream_pageout (&info.vo, &info.og) != 1){
+ fprintf (stderr, "Internal Ogg library error.\n");
+ exit (1);
+ }
+ fwrite (info.og.header, 1, info.og.header_len, outfile);
+ fwrite (info.og.body, 1, info.og.body_len, outfile);
+
+ /* remaining vorbis header packets */
+ ogg_stream_packetin (&info.vo, &header_comm);
+ ogg_stream_packetin (&info.vo, &header_code);
+ }
+
+ /* Flush the rest of our headers. This ensures
+ * the actual data in each stream will start
+ * on a new page, as per spec. */
+ while (1 && !info.audio_only){
+ int result = ogg_stream_flush (&info.to, &info.og);
+ if (result < 0){
+ /* can't get here */
+ fprintf (stderr, "Internal Ogg library error.\n");
+ exit (1);
+ }
+ if (result == 0)
+ break;
+ fwrite (info.og.header, 1, info.og.header_len, outfile);
+ fwrite (info.og.body, 1, info.og.body_len, outfile);
+ }
+ while (1 && !info.video_only){
+ int result = ogg_stream_flush (&info.vo, &info.og);
+ if (result < 0){
+ /* can't get here */
+ fprintf (stderr,
+ "Internal Ogg library error.\n");
+ exit (1);
+ }
+ if (result == 0)
+ break;
+ fwrite (info.og.header, 1, info.og.header_len,outfile);
+ fwrite (info.og.body, 1, info.og.body_len, outfile);
+ }
+
+}
+
+
+/** theora_add_video adds the video the the stream
+ data hold the one frame in the format provided by img_convert */
+
+int theoraframes_add_video (uint8_t * data, int width, int height, int linesize){
+ /* map some things from info struk to local variables,
+ * just to understand the code better */
+ /* pysical pages */
+ yuv_buffer yuv;
+ /* Theora is a one-frame-in,one-frame-out system; submit a frame
+ * for compression and pull out the packet */
+ {
+ yuv.y_width = width;
+ yuv.y_height = height;
+ yuv.y_stride = linesize;
+
+ yuv.uv_width = width / 2;
+ yuv.uv_height = height / 2;
+ yuv.uv_stride = linesize / 2;
+
+ yuv.y = data;
+ yuv.u = data + width * height;
+ yuv.v = data + width * height * 5 / 4;
+ }
+
+ theora_encode_YUVin (&info.td, &yuv);
+ theora_encode_packetout (&info.td, 0, &info.op);
+ ogg_stream_packetin (&info.to, &info.op);
+ if(info.videoflag==0){
+ if (ogg_stream_pageout (&info.to, &info.videopage) > 0){
+ info.videoflag = 1;
+ return 0;
+ }
+ if (ogg_stream_eos (&info.to)){
+ info.videoflag = 0;
+ return 0;
+ }
+ }
+ info.videoflag = 0;
+ return 0;
+}
+
+/** theora_add_audio: fill the audio buffer
+ copy from the encoder_example.c need to be reworkes in order to work. */
+int theoraframes_add_audio (int16_t * buffer, int bytes, int samples){
+ int i, count = 0;
+ float **vorbis_buffer;
+ if (bytes <= 0 && samples <= 0){
+ /* end of file. this can be done implicitly, but it's
+ * easier to see here in non-clever fashion. Tell the
+ * library we're at end of stream so that it can handle the
+ * last frame and mark end of stream in the output properly */
+ vorbis_analysis_wrote (&info.vd, 0);
+ fprintf (stderr, "no audio samples at all\n");
+ }
+ else{
+ vorbis_buffer = vorbis_analysis_buffer (&info.vd, samples);
+ /* uninterleave samples */
+ for (i = 0; i < samples; i++){
+ vorbis_buffer[0][i] = buffer[count++] / 32768.f;
+ vorbis_buffer[1][i] = buffer[count++] / 32768.f;
+ }
+ vorbis_analysis_wrote (&info.vd, samples);
+ }
+ if (!info.audioflag){
+ while (vorbis_analysis_blockout (&info.vd, &info.vb) == 1){
+ /* analysis, assume we want to use bitrate management */
+ vorbis_analysis (&info.vb, NULL);
+ vorbis_bitrate_addblock (&info.vb);
+
+ /* weld packets into the bitstream */
+ while (vorbis_bitrate_flushpacket (&info.vd, &info.op))
+ ogg_stream_packetin (&info.vo, &info.op);
+ }
+ if (ogg_stream_pageout (&info.vo, &info.audiopage) > 0){
+ info.audioflag = 1;
+ return 0;
+ }
+ }
+ if (ogg_stream_eos (&info.vo)){
+ info.audioflag = 0;
+ return 0;
+ }
+ return 0;
+}
+
+
+void theoraframes_flush (){
+ /* setup complete. Raw processing loop */
+ /* fprintf(stderr,"Compressing....\n"); */
+
+ if (!info.audioflag && !info.videoflag)
+ return;
+
+ /* which is earlier; the end of the audio page or the end of the
+ * video page? Flush the earlier to stream */
+ {
+ int video = -1;
+ if(info.audioflag)
+ info.audiotime=vorbis_granule_time (&info.vd,ogg_page_granulepos(&info.audiopage));
+ if(info.videoflag)
+ info.videotime=theora_granule_time (&info.td,ogg_page_granulepos(&info.videopage));
+
+ //some debuging
+ //fprintf(stderr,"\ndiff: %f\n",info.audiotime-info.videotime);
+
+ if (info.videoflag){
+ /* flush a video page */
+ info.video_bytesout +=fwrite (info.videopage.header, 1,info.videopage.header_len, outfile);
+ info.video_bytesout +=fwrite (info.videopage.body, 1,info.videopage.body_len, outfile);
+ info.videoflag = 0;
+ video=1;
+ timebase = info.videotime;
+ }
+ if(info.audiotime < info.videotime && info.audioflag){
+ /* flush an audio page */
+ info.audio_bytesout +=fwrite (info.audiopage.header, 1,info.audiopage.header_len, outfile);
+ info.audio_bytesout +=fwrite (info.audiopage.body, 1,info.audiopage.body_len, outfile);
+ info.audioflag = 0;
+ timebase = info.audiotime;
+ video=0;
+ }
+ {
+ int hundredths = timebase * 100 - (long) timebase * 100;
+ int seconds = (long) timebase % 60;
+ int minutes = ((long) timebase / 60) % 60;
+ int hours = (long) timebase / 3600;
+ {
+ if (video)
+ info.vkbps = rint (info.video_bytesout *
+ 8. / timebase * .001);
+ else
+ info.akbps = rint (info.audio_bytesout *
+ 8. / timebase * .001);
+
+ fprintf (stderr,"\r %d:%02d:%02d.%02d audio: %dkbps video: %dkbps ",
+ hours, minutes, seconds, hundredths,info.akbps, info.vkbps);
+
+ }
+ }
+ }
+}
+
+
+void theoraframes_close (){
+ /* do we have to write last page do output file with EOS and stuff??*/
+ /* pysical pages */
+
+ ogg_stream_clear (&info.vo);
+ vorbis_block_clear (&info.vb);
+ vorbis_dsp_clear (&info.vd);
+ vorbis_comment_clear (&info.vc);
+ vorbis_info_clear (&info.vi);
+
+ ogg_stream_clear (&info.to);
+ theora_clear (&info.td);
+
+ if (outfile && outfile != stdout)
+ fclose (outfile);
+}
Added: trunk/ffmpeg2theora/theorautils.h
===================================================================
--- trunk/ffmpeg2theora/theorautils.h 2004-06-25 18:25:10 UTC (rev 6862)
+++ trunk/ffmpeg2theora/theorautils.h 2004-06-25 18:40:34 UTC (rev 6863)
@@ -0,0 +1,76 @@
+/*
+ * theorautils.h -- ogg/theora Utils for ffmpeg2ogg
+ * Copyright (C) 2003 <j at thing.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <stdint.h>
+#include "theora/theora.h"
+#include "vorbis/codec.h"
+#include "vorbis/vorbisenc.h"
+
+typedef struct
+{
+ int audio_only;
+ int video_only;
+ int frequency;
+ int channels;
+ double vorbis_quality;
+ int scale;
+ int wide;
+ double start;
+ double end;
+ int fps;
+ ogg_page videopage;
+ ogg_page audiopage;
+ int audioflag;
+ int videoflag;
+ double audiotime;
+ double videotime;
+ double timebase;
+ int vkbps;
+ int akbps;
+ ogg_int64_t audio_bytesout;
+ ogg_int64_t video_bytesout;
+
+ ogg_stream_state to; /* take physical pages, weld into a logical
+ * stream of packets */
+ ogg_stream_state vo; /* take physical pages, weld into a logical
+ * stream of packets */
+ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
+ ogg_packet op; /* one raw packet of data for decode */
+
+ theora_info ti;
+ theora_state td;
+ theora_comment tc;
+
+ vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */
+ vorbis_comment vc; /* struct that stores all the user comments */
+
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
+
+}
+theoraframes_info;
+
+
+extern void theoraframes_init ();
+extern int theoraframes_add_video (uint8_t * data, int width, int height,
+ int linesize);
+extern int theoraframes_add_audio (int16_t * readbuffer, int bytesread,
+ int samplesread);
+extern void theoraframes_flush ();
+extern void theoraframes_close ();
More information about the commits
mailing list