...
|
...
|
@@ -136,10 +136,6 @@ static int frame_height = 0;
|
136
|
136
|
static float frame_aspect_ratio = 0;
|
137
|
137
|
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
|
138
|
138
|
static enum SampleFormat audio_sample_fmt = SAMPLE_FMT_NONE;
|
139
|
|
-static int frame_topBand = 0;
|
140
|
|
-static int frame_bottomBand = 0;
|
141
|
|
-static int frame_leftBand = 0;
|
142
|
|
-static int frame_rightBand = 0;
|
143
|
139
|
static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
|
144
|
140
|
static AVRational frame_rate;
|
145
|
141
|
static float video_qscale = 0;
|
...
|
...
|
@@ -276,19 +272,6 @@ typedef struct AVOutputStream {
|
276
|
276
|
int original_height;
|
277
|
277
|
int original_width;
|
278
|
278
|
|
279
|
|
- /* cropping area sizes */
|
280
|
|
- int video_crop;
|
281
|
|
- int topBand;
|
282
|
|
- int bottomBand;
|
283
|
|
- int leftBand;
|
284
|
|
- int rightBand;
|
285
|
|
-
|
286
|
|
- /* cropping area of first frame */
|
287
|
|
- int original_topBand;
|
288
|
|
- int original_bottomBand;
|
289
|
|
- int original_leftBand;
|
290
|
|
- int original_rightBand;
|
291
|
|
-
|
292
|
279
|
/* audio only */
|
293
|
280
|
int audio_resample;
|
294
|
281
|
ReSampleContext *resample; /* for audio resampling */
|
...
|
...
|
@@ -395,23 +378,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
395
|
395
|
|
396
|
396
|
last_filter = ist->input_video_filter;
|
397
|
397
|
|
398
|
|
- if (ost->video_crop) {
|
399
|
|
- snprintf(args, 255, "%d:%d:%d:%d",
|
400
|
|
- codec->width, codec->height,
|
401
|
|
- ost->leftBand, ost->topBand);
|
402
|
|
- if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0)
|
403
|
|
- return ret;
|
404
|
|
- if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
|
405
|
|
- return ret;
|
406
|
|
- if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
|
407
|
|
- return ret;
|
408
|
|
- last_filter = filter;
|
409
|
|
- avfilter_graph_add_filter(graph, last_filter);
|
410
|
|
- }
|
411
|
|
-
|
412
|
|
- if((codec->width !=
|
413
|
|
- icodec->width - (frame_leftBand + frame_rightBand)) ||
|
414
|
|
- (codec->height != icodec->height - (frame_topBand + frame_bottomBand))) {
|
|
398
|
+ if (codec->width != icodec->width || codec->height != icodec->height) {
|
415
|
399
|
snprintf(args, 255, "%d:%d:flags=0x%X",
|
416
|
400
|
codec->width,
|
417
|
401
|
codec->height,
|
...
|
...
|
@@ -1113,9 +1080,6 @@ static void do_video_out(AVFormatContext *s,
|
1113
|
1113
|
int *frame_size)
|
1114
|
1114
|
{
|
1115
|
1115
|
int nb_frames, i, ret;
|
1116
|
|
-#if !CONFIG_AVFILTER
|
1117
|
|
- int64_t topBand, bottomBand, leftBand, rightBand;
|
1118
|
|
-#endif
|
1119
|
1116
|
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
|
1120
|
1117
|
AVFrame picture_crop_temp, picture_pad_temp;
|
1121
|
1118
|
AVCodecContext *enc, *dec;
|
...
|
...
|
@@ -1163,28 +1127,13 @@ static void do_video_out(AVFormatContext *s,
|
1163
|
1163
|
if (nb_frames <= 0)
|
1164
|
1164
|
return;
|
1165
|
1165
|
|
1166
|
|
-#if CONFIG_AVFILTER
|
1167
|
1166
|
formatted_picture = in_picture;
|
1168
|
|
-#else
|
1169
|
|
- if (ost->video_crop) {
|
1170
|
|
- if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
|
1171
|
|
- fprintf(stderr, "error cropping picture\n");
|
1172
|
|
- if (exit_on_error)
|
1173
|
|
- ffmpeg_exit(1);
|
1174
|
|
- return;
|
1175
|
|
- }
|
1176
|
|
- formatted_picture = &picture_crop_temp;
|
1177
|
|
- } else {
|
1178
|
|
- formatted_picture = in_picture;
|
1179
|
|
- }
|
1180
|
|
-#endif
|
1181
|
|
-
|
1182
|
1167
|
final_picture = formatted_picture;
|
1183
|
1168
|
padding_src = formatted_picture;
|
1184
|
1169
|
resampling_dst = &ost->pict_tmp;
|
1185
|
1170
|
|
1186
|
|
- if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|
1187
|
|
- || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|
|
1171
|
+ if ( ost->resample_height != ist->st->codec->height
|
|
1172
|
+ || ost->resample_width != ist->st->codec->width
|
1188
|
1173
|
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
|
1189
|
1174
|
|
1190
|
1175
|
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
|
...
|
...
|
@@ -1196,37 +1145,16 @@ static void do_video_out(AVFormatContext *s,
|
1196
|
1196
|
if (ost->video_resample) {
|
1197
|
1197
|
padding_src = NULL;
|
1198
|
1198
|
final_picture = &ost->pict_tmp;
|
1199
|
|
- if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|
1200
|
|
- || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|
|
1199
|
+ if( ost->resample_height != ist->st->codec->height
|
|
1200
|
+ || ost->resample_width != ist->st->codec->width
|
1201
|
1201
|
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
|
1202
|
1202
|
|
1203
|
|
- /* keep bands proportional to the frame size */
|
1204
|
|
- topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
|
1205
|
|
- bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
|
1206
|
|
- leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
|
1207
|
|
- rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
|
1208
|
|
-
|
1209
|
|
- /* sanity check to ensure no bad band sizes sneak in */
|
1210
|
|
- av_assert0(topBand <= INT_MAX && topBand >= 0);
|
1211
|
|
- av_assert0(bottomBand <= INT_MAX && bottomBand >= 0);
|
1212
|
|
- av_assert0(leftBand <= INT_MAX && leftBand >= 0);
|
1213
|
|
- av_assert0(rightBand <= INT_MAX && rightBand >= 0);
|
1214
|
|
-
|
1215
|
|
- ost->topBand = topBand;
|
1216
|
|
- ost->bottomBand = bottomBand;
|
1217
|
|
- ost->leftBand = leftBand;
|
1218
|
|
- ost->rightBand = rightBand;
|
1219
|
|
-
|
1220
|
|
- ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
|
1221
|
|
- ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
|
1222
|
|
- ost->resample_pix_fmt= ist->st->codec->pix_fmt;
|
1223
|
|
-
|
1224
|
1203
|
/* initialize a new scaler context */
|
1225
|
1204
|
sws_freeContext(ost->img_resample_ctx);
|
1226
|
1205
|
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
|
1227
|
1206
|
ost->img_resample_ctx = sws_getContext(
|
1228
|
|
- ist->st->codec->width - (ost->leftBand + ost->rightBand),
|
1229
|
|
- ist->st->codec->height - (ost->topBand + ost->bottomBand),
|
|
1207
|
+ ist->st->codec->width,
|
|
1208
|
+ ist->st->codec->height,
|
1230
|
1209
|
ist->st->codec->pix_fmt,
|
1231
|
1210
|
ost->st->codec->width,
|
1232
|
1211
|
ost->st->codec->height,
|
...
|
...
|
@@ -2209,18 +2137,9 @@ static int transcode(AVFormatContext **output_files,
|
2209
|
2209
|
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
|
2210
|
2210
|
ffmpeg_exit(1);
|
2211
|
2211
|
}
|
2212
|
|
- ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0);
|
2213
|
|
- ost->video_resample = ((codec->width != icodec->width -
|
2214
|
|
- (frame_leftBand + frame_rightBand)) ||
|
2215
|
|
- (codec->height != icodec->height -
|
2216
|
|
- (frame_topBand + frame_bottomBand)) ||
|
|
2212
|
+ ost->video_resample = (codec->width != icodec->width ||
|
|
2213
|
+ codec->height != icodec->height ||
|
2217
|
2214
|
(codec->pix_fmt != icodec->pix_fmt));
|
2218
|
|
- if (ost->video_crop) {
|
2219
|
|
- ost->topBand = ost->original_topBand = frame_topBand;
|
2220
|
|
- ost->bottomBand = ost->original_bottomBand = frame_bottomBand;
|
2221
|
|
- ost->leftBand = ost->original_leftBand = frame_leftBand;
|
2222
|
|
- ost->rightBand = ost->original_rightBand = frame_rightBand;
|
2223
|
|
- }
|
2224
|
2215
|
if (ost->video_resample) {
|
2225
|
2216
|
avcodec_get_frame_defaults(&ost->pict_tmp);
|
2226
|
2217
|
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
|
...
|
...
|
@@ -2230,8 +2149,8 @@ static int transcode(AVFormatContext **output_files,
|
2230
|
2230
|
}
|
2231
|
2231
|
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
|
2232
|
2232
|
ost->img_resample_ctx = sws_getContext(
|
2233
|
|
- icodec->width - (frame_leftBand + frame_rightBand),
|
2234
|
|
- icodec->height - (frame_topBand + frame_bottomBand),
|
|
2233
|
+ icodec->width,
|
|
2234
|
+ icodec->height,
|
2235
|
2235
|
icodec->pix_fmt,
|
2236
|
2236
|
codec->width,
|
2237
|
2237
|
codec->height,
|
...
|
...
|
@@ -2248,8 +2167,8 @@ static int transcode(AVFormatContext **output_files,
|
2248
|
2248
|
#endif
|
2249
|
2249
|
codec->bits_per_raw_sample= 0;
|
2250
|
2250
|
}
|
2251
|
|
- ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand);
|
2252
|
|
- ost->resample_width = icodec->width - (frame_leftBand + frame_rightBand);
|
|
2251
|
+ ost->resample_height = icodec->height;
|
|
2252
|
+ ost->resample_width = icodec->width;
|
2253
|
2253
|
ost->resample_pix_fmt= icodec->pix_fmt;
|
2254
|
2254
|
ost->encoding_needed = 1;
|
2255
|
2255
|
ist->decoding_needed = 1;
|
...
|
...
|
@@ -2744,64 +2663,10 @@ static int opt_bitrate(const char *opt, const char *arg)
|
2744
|
2744
|
return 0;
|
2745
|
2745
|
}
|
2746
|
2746
|
|
2747
|
|
-static void opt_frame_crop_top(const char *arg)
|
2748
|
|
-{
|
2749
|
|
- frame_topBand = atoi(arg);
|
2750
|
|
- if (frame_topBand < 0) {
|
2751
|
|
- fprintf(stderr, "Incorrect top crop size\n");
|
2752
|
|
- ffmpeg_exit(1);
|
2753
|
|
- }
|
2754
|
|
- if ((frame_topBand) >= frame_height){
|
2755
|
|
- fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
|
2756
|
|
- ffmpeg_exit(1);
|
2757
|
|
- }
|
2758
|
|
- fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
|
2759
|
|
- frame_height -= frame_topBand;
|
2760
|
|
-}
|
2761
|
|
-
|
2762
|
|
-static void opt_frame_crop_bottom(const char *arg)
|
2763
|
|
-{
|
2764
|
|
- frame_bottomBand = atoi(arg);
|
2765
|
|
- if (frame_bottomBand < 0) {
|
2766
|
|
- fprintf(stderr, "Incorrect bottom crop size\n");
|
2767
|
|
- ffmpeg_exit(1);
|
2768
|
|
- }
|
2769
|
|
- if ((frame_bottomBand) >= frame_height){
|
2770
|
|
- fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
|
2771
|
|
- ffmpeg_exit(1);
|
2772
|
|
- }
|
2773
|
|
- fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
|
2774
|
|
- frame_height -= frame_bottomBand;
|
2775
|
|
-}
|
2776
|
|
-
|
2777
|
|
-static void opt_frame_crop_left(const char *arg)
|
|
2747
|
+static int opt_frame_crop(const char *opt, const char *arg)
|
2778
|
2748
|
{
|
2779
|
|
- frame_leftBand = atoi(arg);
|
2780
|
|
- if (frame_leftBand < 0) {
|
2781
|
|
- fprintf(stderr, "Incorrect left crop size\n");
|
2782
|
|
- ffmpeg_exit(1);
|
2783
|
|
- }
|
2784
|
|
- if ((frame_leftBand) >= frame_width){
|
2785
|
|
- fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
|
2786
|
|
- ffmpeg_exit(1);
|
2787
|
|
- }
|
2788
|
|
- fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
|
2789
|
|
- frame_width -= frame_leftBand;
|
2790
|
|
-}
|
2791
|
|
-
|
2792
|
|
-static void opt_frame_crop_right(const char *arg)
|
2793
|
|
-{
|
2794
|
|
- frame_rightBand = atoi(arg);
|
2795
|
|
- if (frame_rightBand < 0) {
|
2796
|
|
- fprintf(stderr, "Incorrect right crop size\n");
|
2797
|
|
- ffmpeg_exit(1);
|
2798
|
|
- }
|
2799
|
|
- if ((frame_rightBand) >= frame_width){
|
2800
|
|
- fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
|
2801
|
|
- ffmpeg_exit(1);
|
2802
|
|
- }
|
2803
|
|
- fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
|
2804
|
|
- frame_width -= frame_rightBand;
|
|
2749
|
+ fprintf(stderr, "Option '%s' has been removed, use the crop filter instead\n", opt);
|
|
2750
|
+ return AVERROR(EINVAL);
|
2805
|
2751
|
}
|
2806
|
2752
|
|
2807
|
2753
|
static void opt_frame_size(const char *arg)
|
...
|
...
|
@@ -4211,10 +4076,10 @@ static const OptionDef options[] = {
|
4211
|
4211
|
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
|
4212
|
4212
|
{ "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
|
4213
|
4213
|
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format, 'list' as argument shows all the pixel formats supported", "format" },
|
4214
|
|
- { "croptop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_top}, "Deprecated, please use the crop avfilter", "size" },
|
4215
|
|
- { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "Deprecated, please use the crop avfilter", "size" },
|
4216
|
|
- { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "Deprecated, please use the crop avfilter", "size" },
|
4217
|
|
- { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "Deprecated, please use the crop avfilter", "size" },
|
|
4214
|
+ { "croptop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Deprecated, please use the crop avfilter", "size" },
|
|
4215
|
+ { "cropbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
|
|
4216
|
+ { "cropleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
|
|
4217
|
+ { "cropright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
|
4218
|
4218
|
{ "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
|
4219
|
4219
|
{ "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
|
4220
|
4220
|
{ "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
|