]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg.c
seek back at the end of file after updating header
[ffmpeg] / ffmpeg.c
index 6f7b381cfc5a30c5c1c1bd0e1eee32d48ae4df67..d12af7b232b403f91b3fe4769f257efc2e062304 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define HAVE_AV_CONFIG_H
+#include <signal.h>
 #include <limits.h>
 #include "avformat.h"
 #include "swscale.h"
 #include "opt.h"
 #include "fifo.h"
 
-#ifndef __MINGW32__
+#ifdef __MINGW32__
+#include <conio.h>
+#else
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <termios.h>
 #include <sys/resource.h>
-#include <signal.h>
 #endif
 #ifdef CONFIG_OS2
 #include <sys/types.h>
@@ -292,10 +294,13 @@ typedef struct AVInputFile {
 
 /* init terminal so that we can grab keys */
 static struct termios oldtty;
+#endif
 
 static void term_exit(void)
 {
+#ifndef __MINGW32__
     tcsetattr (0, TCSANOW, &oldtty);
+#endif
 }
 
 static volatile sig_atomic_t received_sigterm = 0;
@@ -309,6 +314,7 @@ sigterm_handler(int sig)
 
 static void term_init(void)
 {
+#ifndef __MINGW32__
     struct termios tty;
 
     tcgetattr (0, &tty);
@@ -324,9 +330,10 @@ static void term_init(void)
     tty.c_cc[VTIME] = 0;
 
     tcsetattr (0, TCSANOW, &tty);
+    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
+#endif
 
     signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
-    signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
     signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
     /*
     register a function to be called at normal program termination
@@ -340,6 +347,10 @@ static void term_init(void)
 /* read a key without blocking */
 static int read_key(void)
 {
+#ifdef __MINGW32__
+    if(kbhit())
+        return(getch());
+#else
     int n = 1;
     unsigned char ch;
 #ifndef CONFIG_BEOS_NETSERVER
@@ -359,6 +370,7 @@ static int read_key(void)
 
         return n;
     }
+#endif
     return -1;
 }
 
@@ -367,26 +379,6 @@ static int decode_interrupt_cb(void)
     return q_pressed || (q_pressed = read_key() == 'q');
 }
 
-#else
-
-static volatile int received_sigterm = 0;
-
-/* no interactive support */
-static void term_exit(void)
-{
-}
-
-static void term_init(void)
-{
-}
-
-static int read_key(void)
-{
-    return 0;
-}
-
-#endif
-
 static int read_ffserver_streams(AVFormatContext *s, const char *filename)
 {
     int i, err;
@@ -889,7 +881,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
         }
     }
 
-    ti = MAXINT64;
+    ti = INT64_MAX;
     enc = ost->st->codec;
     if (enc->codec_type == CODEC_TYPE_VIDEO) {
         frame_number = ost->frame_number;
@@ -1832,12 +1824,10 @@ static int av_encode(AVFormatContext **output_files,
         }
     }
 
-#ifndef __MINGW32__
     if ( !using_stdin && verbose >= 0) {
         fprintf(stderr, "Press [q] to stop encoding\n");
         url_set_interrupt_cb(decode_interrupt_cb);
     }
-#endif
     term_init();
 
     stream_no_data = 0;
@@ -2668,7 +2658,7 @@ static void opt_input_file(const char *filename)
             if (enc->time_base.den != rfps || enc->time_base.num != rfps_base) {
 
                 if (verbose >= 0)
-                    fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
+                    fprintf(stderr,"\nSeems stream %d codec frame rate differs from container frame rate: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
                             i, (float)enc->time_base.den / enc->time_base.num, enc->time_base.den, enc->time_base.num,
 
                     (float)rfps / rfps_base, rfps, rfps_base);
@@ -2931,6 +2921,7 @@ static void new_audio_stream(AVFormatContext *oc)
 
     audio_enc = st->codec;
     audio_enc->codec_type = CODEC_TYPE_AUDIO;
+    audio_enc->strict_std_compliance = strict;
 
     if(audio_codec_tag)
         audio_enc->codec_tag= audio_codec_tag;
@@ -2961,7 +2952,6 @@ static void new_audio_stream(AVFormatContext *oc)
             audio_enc->flags |= CODEC_FLAG_QSCALE;
             audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
         }
-        audio_enc->strict_std_compliance = strict;
         audio_enc->thread_count = thread_count;
         /* For audio codecs other than AC3 or DTS we limit */
         /* the number of coded channels to stereo   */
@@ -3244,6 +3234,10 @@ static void prepare_grab(void)
 
     if (has_video) {
         AVInputFormat *fmt1;
+#warning FIXME: find a better interface
+        if(video_device&&!strncmp(video_device,"x11:",4)) {
+            video_grab_format="x11grab";
+        }
         fmt1 = av_find_input_format(video_grab_format);
         vp->device  = video_device;
         vp->channel = video_channel;
@@ -3952,8 +3946,10 @@ int main(int argc, char **argv)
         int j;
         if (!(s->oformat->flags & AVFMT_NOFILE))
             url_fclose(&s->pb);
-        for(j=0;j<s->nb_streams;j++)
+        for(j=0;j<s->nb_streams;j++) {
+            av_free(s->streams[j]->codec);
             av_free(s->streams[j]);
+        }
         av_free(s);
     }
     for(i=0;i<nb_input_files;i++)
@@ -3971,14 +3967,13 @@ int main(int argc, char **argv)
     powerpc_display_perf_report();
 #endif /* POWERPC_PERFORMANCE_REPORT */
 
-#ifndef __MINGW32__
     if (received_sigterm) {
         fprintf(stderr,
             "Received signal %d: terminating.\n",
             (int) received_sigterm);
         exit (255);
     }
-#endif
+
     exit(0); /* not all OS-es handle main() return value */
     return 0;
 }