Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -43,6 +43,7 @@ typedef struct {
|
| 43 | 43 |
char *video_size; /**< Set by a private option. */ |
| 44 | 44 |
char *framerate; /**< Set by a private option. */ |
| 45 | 45 |
int loop; |
| 46 |
+ int updatefirst; |
|
| 46 | 47 |
} VideoData; |
| 47 | 48 |
|
| 48 | 49 |
typedef struct {
|
| ... | ... |
@@ -391,10 +392,11 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) |
| 391 | 391 |
|
| 392 | 392 |
if (!img->is_pipe) {
|
| 393 | 393 |
if (av_get_frame_filename(filename, sizeof(filename), |
| 394 |
- img->path, img->img_number) < 0 && img->img_number==2) {
|
|
| 395 |
- av_log(s, AV_LOG_WARNING, |
|
| 396 |
- "Writing multiple frames to the same file, check the pattern '%s' if this is not what you want\n", |
|
| 397 |
- img->path); |
|
| 394 |
+ img->path, img->img_number) < 0 && img->img_number>1 && !img->updatefirst) {
|
|
| 395 |
+ av_log(s, AV_LOG_ERROR, |
|
| 396 |
+ "Could not get frame filename number %d from pattern '%s'\n", |
|
| 397 |
+ img->img_number, img->path); |
|
| 398 |
+ return AVERROR(EINVAL); |
|
| 398 | 399 |
} |
| 399 | 400 |
for(i=0; i<3; i++){
|
| 400 | 401 |
if (avio_open2(&pb[i], filename, AVIO_FLAG_WRITE, |
| ... | ... |
@@ -461,6 +463,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) |
| 461 | 461 |
|
| 462 | 462 |
#define OFFSET(x) offsetof(VideoData, x) |
| 463 | 463 |
#define DEC AV_OPT_FLAG_DECODING_PARAM |
| 464 |
+#define ENC AV_OPT_FLAG_ENCODING_PARAM |
|
| 464 | 465 |
static const AVOption options[] = {
|
| 465 | 466 |
{ "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
| 466 | 467 |
{ "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
| ... | ... |
@@ -469,6 +472,11 @@ static const AVOption options[] = {
|
| 469 | 469 |
{ NULL },
|
| 470 | 470 |
}; |
| 471 | 471 |
|
| 472 |
+static const AVOption muxoptions[] = {
|
|
| 473 |
+ { "updatefirst", "", OFFSET(updatefirst), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, ENC },
|
|
| 474 |
+ { NULL },
|
|
| 475 |
+}; |
|
| 476 |
+ |
|
| 472 | 477 |
/* input */ |
| 473 | 478 |
#if CONFIG_IMAGE2_DEMUXER |
| 474 | 479 |
static const AVClass img2_class = {
|
| ... | ... |
@@ -507,6 +515,12 @@ AVInputFormat ff_image2pipe_demuxer = {
|
| 507 | 507 |
|
| 508 | 508 |
/* output */ |
| 509 | 509 |
#if CONFIG_IMAGE2_MUXER |
| 510 |
+static const AVClass img2mux_class = {
|
|
| 511 |
+ .class_name = "image2 muxer", |
|
| 512 |
+ .item_name = av_default_item_name, |
|
| 513 |
+ .option = muxoptions, |
|
| 514 |
+ .version = LIBAVUTIL_VERSION_INT, |
|
| 515 |
+}; |
|
| 510 | 516 |
AVOutputFormat ff_image2_muxer = {
|
| 511 | 517 |
.name = "image2", |
| 512 | 518 |
.long_name = NULL_IF_CONFIG_SMALL("image2 sequence"),
|
| ... | ... |
@@ -516,7 +530,8 @@ AVOutputFormat ff_image2_muxer = {
|
| 516 | 516 |
.video_codec = CODEC_ID_MJPEG, |
| 517 | 517 |
.write_header = write_header, |
| 518 | 518 |
.write_packet = write_packet, |
| 519 |
- .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE |
|
| 519 |
+ .flags = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE, |
|
| 520 |
+ .priv_class = &img2mux_class, |
|
| 520 | 521 |
}; |
| 521 | 522 |
#endif |
| 522 | 523 |
#if CONFIG_IMAGE2PIPE_MUXER |