shithub: sox

Download patch

ref: 81cae8475c46dd7e376efb542f97b52dc53c89fd
parent: ae4e7fe7d1f259058eea7e975ba1e5ac8569cf79
author: rrt <rrt>
date: Sat Apr 14 13:15:07 EDT 2007

Add ffmpeg support (read-only for now).

Closes #616766 (which only asks for reading of AC3) and addresses the
reading side of the FRs for AAC (#1649279) and AMR (#728875).

Some other small documentation tweaks.

--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
   o Added AMR-WB format.  (robs)
   o Added M3U playlist format [FR# 1667341].  (robs)
   o Added libao support.  (Reuben Thomas)
+  o Added read-only ffmpeg support.  (Reuben Thomas)
 
   Effects:
 
--- a/INSTALL
+++ b/INSTALL
@@ -44,18 +44,20 @@
 
 SoX can detect and use the following libraries:
 
-Ogg Vorbis - More information available at http://www.vorbis.com
+  Ogg Vorbis - http://www.vorbis.com/
 
-Lame MP3 encoder - http://lame.sourceforge.net/
+  Lame MP3 encoder - http://lame.sourceforge.net/
 
-MAD MP3 decoder - http://www.underbit.com/products/mad/
+  MAD MP3 decoder - http://www.underbit.com/products/mad/
 
-FLAC - http://flac.sourceforge.net/
+  FLAC - http://flac.sourceforge.net/
 
-Secret Rabbit Code - http://www.mega-nerd.com/SRC/
+  Secret Rabbit Code - http://www.mega-nerd.com/SRC/
 
-libsndfile - http://www.mega-nerd.com/libsndfile/
+  libsndfile - http://www.mega-nerd.com/libsndfile/
 
+  ffmpeg - http://ffmpeg.mplayerhq.hu/
+  
 If any libraries are installed in a non-standard locations in your
 system then you can use the CPPFLAGS and LDFLAGS variables to allow
 configure to find them. For example:
@@ -89,4 +91,3 @@
 If your adding new features to SoX or want to perform advance tests
 on a new platform then you can use the scripts "tests.sh" and
 "testall.sh" to stress SoX.
-
--- a/README
+++ b/README
@@ -34,7 +34,11 @@
   o GSM files
   o Macintosh HCOM files
   o Amiga MAUD files
-  o MP3 files (with optional external library)
+  o AMR-WB files
+  o MP3 (with optional external libraries)
+  o MP4, AAC, AC3 files (read-only, with optional external libraries)
+  o Ogg Vorbis files (with optional external library)
+  o FLAC files (with optional external library)
   o IRCAM SoundFile files
   o NIST SPHERE files
   o Turtle beach SampleVision files
@@ -41,8 +45,6 @@
   o Soundtool (DOS) files
   o Yamaha TX-16W sampler files
   o Sound Blaster .VOC files
-  o Ogg Vorbis files (with optional external library)
-  o FLAC files (with optional external library)
   o Dialogic/OKI ADPCM files (.VOX)
   o Microsoft .WAV files
     o PCM, u-law, A-law
@@ -53,7 +55,7 @@
   o Maxis XA Audio files
     o EA ADPCM (read support only, for now)
   o Pseudo-file formats that allow direct playing/recording
-    from some audio devices under UNIX
+    from most audio devices
   o The "null" pseudo-file that reads and writes from/to nowhere
 
 Most sound formats are auto-detected.
--- a/configure.ac
+++ b/configure.ac
@@ -179,6 +179,12 @@
     fi
 fi
 
+dnl Check for ffmpeg libraries
+AC_CHECK_HEADER(ffmpeg/avformat.h,
+    [with_ffmpeg=yes
+    AC_CHECK_LIB(avformat, av_open_input_file,, with_ffmpeg=no)],
+    with_ffmpeg=no)
+
 dnl Check for MAD libraries
 AC_ARG_WITH(mad,
     AC_HELP_STRING([--without-mad],
@@ -247,6 +253,7 @@
 echo "libsndfile formats................ $with_sndfile"
 echo "Ogg Vorbis format................. $with_ogg_vorbis"
 echo "FLAC format....................... $using_flac"
+echo "ffmpeg formats.................... $with_ffmpeg"
 echo "MAD MP3 reader.................... $using_mad"
 echo "LAME MP3 writer................... $using_lame"
 echo "Secret Rabbit Code resampling..... $using_samplerate"
--- a/sox.1
+++ b/sox.1
@@ -743,12 +743,13 @@
 .B -t
 option (see above). File types that can be determined by a filename
 extension are listed with their names preceded by a dot. File types
-that require optional libsndfile support are marked
-`\fB(libsndfile)\fR'. File types that can be handled by libsndfile
-using \fB\-t sndfile\fR are marked `\fB(also with \-t sndfile)\fR'.
-This might be useful if you have a file that doesn't work with SoX's
-default format readers and writers, and there's a libsndfile reader
-and writer for that format.
+that require an external library, such as ffmpeg or libsndfile, are
+marked e.g. `\fB(ffmpeg)\fR'. File types that can be handled by an
+external library via its pseudo file type (currently libsndfile or
+ffmpeg) are marked e.g. `\fB(also with \-t sndfile)\fR'. This might be
+useful if you have a file that doesn't work with SoX's default format
+readers and writers, and there's an external reader or writer for that
+format.
 .SP
 .TP
 .B .raw (also with \-t sndfile)
@@ -899,6 +900,12 @@
 See
 .BR .paf .
 .TP
+.B ffmpeg
+This is a pseudo-type that forces ffmpeg to be used. At the moment,
+ffmpeg support is read-only. The actual file type is deduced from the
+file. This pseudo-type depends on SoX having been built with optional
+ffmpeg support.
+.TP
 .B .flac (also with \-t sndfile)
 Free Lossless Audio CODEC compressed audio.
 FLAC is an open, patent-free CODEC designed for compressing
@@ -996,7 +1003,7 @@
 MP3 support in
 SoX is optional and requires access to either or both the external
 libmad and libmp3lame libraries.  To
-see if there is support for Mp3 run
+see if there is support for MP3 run
 .EX
 	sox -h
 .EE
@@ -1003,6 +1010,15 @@
 and look for it under the list of supported file formats as `mp3'.
 .SP
 .TP
+\&\fB.mp4\fR, \fB.m4a\fR \fB(ffmpeg)\fR
+MP4 compressed audio.  MP3 (MPEG 4) is part of the
+MPEG standards for audio and video compression.  See
+.B mp3
+for more information.
+.SP
+MP4 support in SoX is optional and requires access to the external
+ffmpeg libraries. Currently it is read-only.
+.TP
 .B .nist (also with \-t sndfile)
 See \fB.sph\fR.
 .TP
@@ -1097,10 +1113,9 @@
 .BR .au .
 .TP
 .B sndfile
-This is a pseudo-type that forces libsndfile to be used, even for file
-types normally handled internally by SoX. For writing files, the
+This is a pseudo-type that forces libsndfile to be used. For writing files, the
 actual file type is then taken from the output file name; for reading
-them, it is deduced from the file and any other format parameters.
+them, it is deduced from the file.
 This pseudo-type depends on SoX having been built with optional
 libsndfile support.
 .TP
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,8 +13,8 @@
 include_HEADERS = sox.h soxstdint.h
 
 formats = 8svx.c adpcm.c adpcm.h adpcms.c adpcms.h aiff.c ao.c au.c auto.c avr.c \
-	  cdr.c cvsd.c cvsdfilt.h dat.c flac.c g711.c g711.h g721.c g723_24.c \
-	  g723_40.c g72x.c g72x.h gsm.c hcom.c ima_rw.c ima_rw.h \
+	  cdr.c cvsd.c cvsdfilt.h dat.c ffmpeg.c flac.c g711.c g711.h g721.c \
+	  g723_24.c g723_40.c g72x.c g72x.h gsm.c hcom.c ima_rw.c ima_rw.h \
 	  maud.c mp3.c nulfile.c prc.c raw.c sf.c sfircam.h skelform.c smp.c \
 	  sndfile.c sndrtool.c sphere.c tx16w.c voc.c vorbis.c vox.c wav.c \
 	  wav.h wve.c xa.c amr-wb.c
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -32,6 +32,9 @@
   sox_cvsd_format_fn,
   sox_dat_format_fn,
   sox_dvms_format_fn,
+#ifdef HAVE_LIBAVFORMAT
+  sox_ffmpeg_format_fn,
+#endif
 #ifdef HAVE_LIBFLAC
   sox_flac_format_fn,
 #endif
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -236,6 +236,9 @@
 extern const sox_format_t *sox_cvsd_format_fn(void);
 extern const sox_format_t *sox_dvms_format_fn(void);
 extern const sox_format_t *sox_dat_format_fn(void);
+#ifdef HAVE_LIBAVFORMAT
+extern const sox_format_t *sox_ffmpeg_format_fn(void);
+#endif
 #ifdef HAVE_LIBFLAC
 extern const sox_format_t *sox_flac_format_fn(void);
 #endif