Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avformat/img2enc: fix first image check
@ 2022-06-12 22:44 Marton Balint
  2022-06-12 22:44 ` [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern Marton Balint
  0 siblings, 1 reply; 4+ messages in thread
From: Marton Balint @ 2022-06-12 22:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Start image number was hardcoded to 1 for the first image check.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/img2enc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index b3a0801ec9..82a04e639b 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -36,6 +36,7 @@
 
 typedef struct VideoMuxData {
     const AVClass *class;  /**< Class for private options. */
+    int start_img_number;
     int img_number;
     int split_planes;       /**< use independent file for each Y, U, V plane */
     char tmp[4][1024];
@@ -69,6 +70,7 @@ static int write_header(AVFormatContext *s)
                              &&(desc->flags & AV_PIX_FMT_FLAG_PLANAR)
                              && desc->nb_components >= 3;
     }
+    img->img_number = img->start_img_number;
 
     return 0;
 }
@@ -162,7 +164,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
     } else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
                                       img->img_number,
                                       AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
-               img->img_number > 1) {
+               img->img_number > img->start_img_number) {
         av_log(s, AV_LOG_ERROR,
                "Could not get frame filename number %d from pattern '%s'. "
                "Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
@@ -246,7 +248,7 @@ static int query_codec(enum AVCodecID id, int std_compliance)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption muxoptions[] = {
     { "update",       "continuously overwrite one file", OFFSET(update),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0,       1, ENC },
-    { "start_number", "set first number in the sequence", OFFSET(img_number), AV_OPT_TYPE_INT,  { .i64 = 1 }, 0, INT_MAX, ENC },
+    { "start_number", "set first number in the sequence", OFFSET(start_img_number), AV_OPT_TYPE_INT,  { .i64 = 1 }, 0, INT_MAX, ENC },
     { "strftime",     "use strftime for filename", OFFSET(use_strftime),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
     { "frame_pts",    "use current frame pts for filename", OFFSET(frame_pts),  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
     { "atomic_writing", "write files atomically (using temporary files and renames)", OFFSET(use_rename), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern
  2022-06-12 22:44 [FFmpeg-devel] [PATCH 1/2] avformat/img2enc: fix first image check Marton Balint
@ 2022-06-12 22:44 ` Marton Balint
  2022-06-20 21:31   ` Marton Balint
  0 siblings, 1 reply; 4+ messages in thread
From: Marton Balint @ 2022-06-12 22:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Also warn the user that for single images -update should be used, for sequences
a proper pattern should be specified.

Fixes ticket #9748.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/img2enc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 82a04e639b..50e469dd96 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -163,13 +163,17 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     } else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
                                       img->img_number,
-                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
-               img->img_number > img->start_img_number) {
-        av_log(s, AV_LOG_ERROR,
-               "Could not get frame filename number %d from pattern '%s'. "
-               "Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
-               img->img_number, s->url);
-        return AVERROR(EINVAL);
+                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
+        if (img->img_number == img->start_img_number) {
+            av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url);
+            av_log(s, AV_LOG_WARNING,
+                   "Use a pattern such as %%03d for an image sequence or "
+                   "use the -update option (with -frames:v 1 if needed) to write a single image.\n");
+            av_strlcpy(filename, s->url, sizeof(filename));
+        } else {
+            av_log(s, AV_LOG_ERROR, "Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?\n");
+            return AVERROR(EINVAL);
+        }
     }
     for (i = 0; i < 4; i++) {
         av_dict_copy(&options, img->protocol_opts, 0);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern
  2022-06-12 22:44 ` [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern Marton Balint
@ 2022-06-20 21:31   ` Marton Balint
  2022-07-07 18:32     ` Marton Balint
  0 siblings, 1 reply; 4+ messages in thread
From: Marton Balint @ 2022-06-20 21:31 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



On Mon, 13 Jun 2022, Marton Balint wrote:

> Also warn the user that for single images -update should be used, for sequences
> a proper pattern should be specified.
>
> Fixes ticket #9748.

Ping for this. Note that this patch will show a warning for any 
non-sequence image filename (unless the -update option is specified) 
in order to help the user avoid unexpected results with filenames 
containing %d.

Regards,
Marton

>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavformat/img2enc.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
> index 82a04e639b..50e469dd96 100644
> --- a/libavformat/img2enc.c
> +++ b/libavformat/img2enc.c
> @@ -163,13 +163,17 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
>         }
>     } else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
>                                       img->img_number,
> -                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
> -               img->img_number > img->start_img_number) {
> -        av_log(s, AV_LOG_ERROR,
> -               "Could not get frame filename number %d from pattern '%s'. "
> -               "Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %%03d within the filename.\n",
> -               img->img_number, s->url);
> -        return AVERROR(EINVAL);
> +                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
> +        if (img->img_number == img->start_img_number) {
> +            av_log(s, AV_LOG_WARNING, "The specified filename '%s' does not contain an image sequence pattern or a pattern is invalid.\n", s->url);
> +            av_log(s, AV_LOG_WARNING,
> +                   "Use a pattern such as %%03d for an image sequence or "
> +                   "use the -update option (with -frames:v 1 if needed) to write a single image.\n");
> +            av_strlcpy(filename, s->url, sizeof(filename));
> +        } else {
> +            av_log(s, AV_LOG_ERROR, "Cannot write more than one file with the same name. Are you missing the -update option or a sequence pattern?\n");
> +            return AVERROR(EINVAL);
> +        }
>     }
>     for (i = 0; i < 4; i++) {
>         av_dict_copy(&options, img->protocol_opts, 0);
> -- 
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern
  2022-06-20 21:31   ` Marton Balint
@ 2022-07-07 18:32     ` Marton Balint
  0 siblings, 0 replies; 4+ messages in thread
From: Marton Balint @ 2022-07-07 18:32 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



On Mon, 20 Jun 2022, Marton Balint wrote:

>
>
> On Mon, 13 Jun 2022, Marton Balint wrote:
>
>>  Also warn the user that for single images -update should be used, for
>>  sequences
>>  a proper pattern should be specified.
>>
>>  Fixes ticket #9748.
>
> Ping for this. Note that this patch will show a warning for any non-sequence 
> image filename (unless the -update option is specified) in order to help the 
> user avoid unexpected results with filenames containing %d.

Will apply.

Regards,
Marton

>
> Regards,
> Marton
>
>>
>>  Signed-off-by: Marton Balint <cus@passwd.hu>
>>  ---
>>  libavformat/img2enc.c | 18 +++++++++++-------
>>  1 file changed, 11 insertions(+), 7 deletions(-)
>>
>>  diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
>>  index 82a04e639b..50e469dd96 100644
>>  --- a/libavformat/img2enc.c
>>  +++ b/libavformat/img2enc.c
>>  @@ -163,13 +163,17 @@ static int write_packet(AVFormatContext *s, AVPacket
>>  *pkt)
>>          }
>>      } else if (av_get_frame_filename2(filename, sizeof(filename), s->url,
>>                                        img->img_number,
>>  -                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) <
>>  0 &&
>>  -               img->img_number > img->start_img_number) {
>>  -        av_log(s, AV_LOG_ERROR,
>>  -               "Could not get frame filename number %d from pattern '%s'.
>>  "
>>  -               "Use '-frames:v 1' for a single image, or '-update'
>>  option, or use a pattern such as %%03d within the filename.\n",
>>  -               img->img_number, s->url);
>>  -        return AVERROR(EINVAL);
>>  +                                      AV_FRAME_FILENAME_FLAGS_MULTIPLE) <
>>  0) {
>>  +        if (img->img_number == img->start_img_number) {
>>  +            av_log(s, AV_LOG_WARNING, "The specified filename '%s' does
>>  not contain an image sequence pattern or a pattern is invalid.\n",
>>  s->url);
>>  +            av_log(s, AV_LOG_WARNING,
>>  +                   "Use a pattern such as %%03d for an image sequence or
>>  "
>>  +                   "use the -update option (with -frames:v 1 if needed)
>>  to write a single image.\n");
>>  +            av_strlcpy(filename, s->url, sizeof(filename));
>>  +        } else {
>>  +            av_log(s, AV_LOG_ERROR, "Cannot write more than one file with
>>  the same name. Are you missing the -update option or a sequence
>>  pattern?\n");
>>  +            return AVERROR(EINVAL);
>>  +        }
>>      }
>>      for (i = 0; i < 4; i++) {
>>          av_dict_copy(&options, img->protocol_opts, 0);
>>  --
>>  2.34.1
>>
>>  _______________________________________________
>>  ffmpeg-devel mailing list
>>  ffmpeg-devel@ffmpeg.org
>>  https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>  To unsubscribe, visit link above, or email
>>  ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-07 18:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12 22:44 [FFmpeg-devel] [PATCH 1/2] avformat/img2enc: fix first image check Marton Balint
2022-06-12 22:44 ` [FFmpeg-devel] [PATCH 2/2] avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern Marton Balint
2022-06-20 21:31   ` Marton Balint
2022-07-07 18:32     ` Marton Balint

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git