]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg.c
Use put_signed_pixels_clamped where appropriate
[ffmpeg] / ffmpeg.c
index e81d38af41b0a2e0d341892e07e8429b63aa500d..189d7270faf65ef2f1ab4149ec28a32bac182d9e 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -83,7 +83,6 @@ typedef struct AVMetaDataMap {
 extern const OptionDef options[];
 
 static void show_help(void);
-static void opt_show_license(void);
 static int opt_default(const char *opt, const char *arg);
 
 #define MAX_FILES 20
@@ -409,6 +408,8 @@ get_sync_ipts(const AVOutputStream *ost)
 }
 
 static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
+    int ret;
+
     while(bsfc){
         AVPacket new_pkt= *pkt;
         int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
@@ -424,7 +425,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx
         bsfc= bsfc->next;
     }
 
-    av_interleaved_write_frame(s, pkt);
+    ret= av_interleaved_write_frame(s, pkt);
+    if(ret < 0){
+        print_error("av_interleaved_write_frame()", ret);
+        exit(1);
+    }
 }
 
 #define MAX_AUDIO_PACKET_SIZE (128 * 1024)
@@ -1358,8 +1363,7 @@ static int stream_index_from_inputs(AVFormatContext **input_files,
                                     enum CodecType type,
                                     int programid)
 {
-    int p, q, r, s, z;
-    AVInputStream *ist;
+    int p, q, z;
     for(z=0; z<nb_input_files; z++) {
         AVFormatContext *ic = input_files[z];
         for(p=0; p<ic->nb_programs; p++) {
@@ -2154,6 +2158,16 @@ static void opt_frame_rate(const char *arg)
     }
 }
 
+static void opt_bitrate(const char *opt, const char *arg)
+{
+    int codec_type = opt[0]=='a' ? CODEC_TYPE_AUDIO : CODEC_TYPE_VIDEO;
+
+    opt_default(opt, arg);
+
+    if (av_get_int(avctx_opts[codec_type], "b", NULL) < 1000)
+        fprintf(stderr, "WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s\n");
+}
+
 static void opt_frame_crop_top(const char *arg)
 {
     frame_topBand = atoi(arg);
@@ -3592,6 +3606,12 @@ static void opt_bsf(const char *opt, const char *arg)
     *bsfp= bsfc;
 }
 
+static void opt_show_license(void)
+{
+    show_license();
+    exit(0);
+}
+
 static void opt_show_version(void)
 {
     show_version(program_name);
@@ -3683,6 +3703,8 @@ const OptionDef options[] = {
     { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
 
     /* video options */
+    { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "" },
+    { "vb", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "" },
     { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[CODEC_TYPE_VIDEO]}, "set the number of video frames to record", "number" },
     { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[CODEC_TYPE_DATA]}, "set the number of data frames to record", "number" },
     { "r", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
@@ -3729,6 +3751,7 @@ const OptionDef options[] = {
     { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
 
     /* audio options */
+    { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "" },
     { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[CODEC_TYPE_AUDIO]}, "set the number of audio frames to record", "number" },
     { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
     { "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
@@ -3762,12 +3785,6 @@ const OptionDef options[] = {
     { NULL, },
 };
 
-static void opt_show_license(void)
-{
-    show_license();
-    exit(0);
-}
-
 /**
  * Trivial log callback.
  * Only suitable for show_help and similar since it lacks prefix handling.