1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

add -xerror option, ffmpeg will now exit right when an error occurs

Originally committed as revision 15210 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Baptiste Coudurier 2008-09-04 23:23:44 +00:00
parent 52cf395407
commit f2abc55945

View File

@ -195,6 +195,7 @@ static char *video_standard;
static int audio_volume = 256; static int audio_volume = 256;
static int exit_on_error = 0;
static int using_stdin = 0; static int using_stdin = 0;
static int using_vhook = 0; static int using_vhook = 0;
static int verbose = 1; static int verbose = 1;
@ -495,6 +496,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx
bsfc->filter->name, pkt->stream_index, bsfc->filter->name, pkt->stream_index,
avctx->codec ? avctx->codec->name : "copy"); avctx->codec ? avctx->codec->name : "copy");
print_error("", a); print_error("", a);
if (exit_on_error)
av_exit(1);
} }
*pkt= new_pkt; *pkt= new_pkt;
@ -639,6 +642,8 @@ static void do_audio_out(AVFormatContext *s,
int len= size_out/istride[0]; int len= size_out/istride[0];
if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) { if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
printf("av_audio_convert() failed\n"); printf("av_audio_convert() failed\n");
if (exit_on_error)
av_exit(1);
return; return;
} }
buftmp = audio_out2; buftmp = audio_out2;
@ -768,6 +773,8 @@ static void do_subtitle_out(AVFormatContext *s,
if (pts == AV_NOPTS_VALUE) { if (pts == AV_NOPTS_VALUE) {
fprintf(stderr, "Subtitle packets must have a pts\n"); fprintf(stderr, "Subtitle packets must have a pts\n");
if (exit_on_error)
av_exit(1);
return; return;
} }
@ -861,6 +868,8 @@ static void do_video_out(AVFormatContext *s,
if (ost->video_crop) { if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) { if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
av_log(NULL, AV_LOG_ERROR, "error cropping picture\n"); av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
if (exit_on_error)
av_exit(1);
return; return;
} }
formatted_picture = &picture_crop_temp; formatted_picture = &picture_crop_temp;
@ -876,6 +885,8 @@ static void do_video_out(AVFormatContext *s,
if (ost->video_resample) { if (ost->video_resample) {
if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) { if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
av_log(NULL, AV_LOG_ERROR, "error padding picture\n"); av_log(NULL, AV_LOG_ERROR, "error padding picture\n");
if (exit_on_error)
av_exit(1);
return; return;
} }
resampling_dst = &picture_pad_temp; resampling_dst = &picture_pad_temp;
@ -2120,7 +2131,8 @@ static int av_encode(AVFormatContext **output_files,
if (verbose >= 0) if (verbose >= 0)
fprintf(stderr, "Error while decoding stream #%d.%d\n", fprintf(stderr, "Error while decoding stream #%d.%d\n",
ist->file_index, ist->index); ist->file_index, ist->index);
if (exit_on_error)
av_exit(1);
av_free_packet(&pkt); av_free_packet(&pkt);
goto redo; goto redo;
} }
@ -3795,6 +3807,7 @@ static const OptionDef options[] = {
{ "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, // { "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" }, { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
{ "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" }, { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
/* video options */ /* video options */
{ "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },