]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/mux.c
Detect and allow older versions of ffmpeg to be used in conjunction with VLC.
[vlc] / modules / codec / ffmpeg / mux.c
index 01b1b6ac942f51f1a7f53ba10014e75db31a6e6f..975921c10c6afd241f069f322af5981d053ceba3 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_block.h>
 #include <vlc_sout.h>
 
 /* ffmpeg header */
-#ifdef HAVE_FFMPEG_AVFORMAT_H
-#   include <ffmpeg/avformat.h>
+#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
+#   include <libavformat/avformat.h>
 #elif defined(HAVE_LIBAVFORMAT_TREE)
 #   include <avformat.h>
 #endif
@@ -41,7 +45,7 @@
 //#define AVFORMAT_DEBUG 1
 
 /* Version checking */
-#if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)
+#if defined(HAVE_LIBSWSCALE_SWSCALE_H) || defined(HAVE_FFMPEG_SWSCALE_H) || defined(HAVE_LIBSWSCALE_TREE)
 
 static const char *ppsz_mux_options[] = {
     "mux", NULL
@@ -252,6 +256,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         codec->time_base.den = p_input->p_fmt->video.i_frame_rate;
         codec->time_base.num = p_input->p_fmt->video.i_frame_rate_base;
         break;
+
+    default:
+        msg_Warn( p_mux, "Unhandled ES category" );
     }
 
     codec->bit_rate = p_input->p_fmt->i_bitrate;
@@ -360,7 +367,8 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
             I64C(1000000) / p_stream->time_base.num;
 
     /* this is another hack to prevent libavformat from triggering the "non monotone timestamps" check in avformat/utils.c */
-    p_stream->cur_dts = AV_NOPTS_VALUE;
+    p_stream->cur_dts = ( p_data->i_dts * p_stream->time_base.den /
+            I64C(1000000) / p_stream->time_base.num ) - 1;
 
     if( av_write_frame( p_sys->oc, &pkt ) < 0 )
     {
@@ -497,15 +505,4 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence )
     return 0;
 }
 
-#else /* HAVE_FFMPEG_AVFORMAT_H */
-
-int E_(OpenMux)( vlc_object_t *p_this )
-{
-    return VLC_EGENERIC;
-}
-
-void E_(CloseMux)( vlc_object_t *p_this )
-{
-}
-
-#endif /* HAVE_FFMPEG_AVFORMAT_H */
+#endif /* HAVE_LIBAVFORMAT_AVFORMAT_H */