[FFmpeg-devel] Image sequence file names

Michael Niedermayer michaelni at gmx.at
Fri Aug 26 04:40:22 CEST 2011


On Thu, Aug 25, 2011 at 10:12:25PM +0200, Robert Petka wrote:
> Dňa 24. 8. 2011 23:22, Carl Eugen Hoyos wrote / napísal(a):
>> Robert Petka<robert.petka<at>  gmail.com>  writes:
>>
>>> recently I`ve been solving issue mentioned in following ticket
>>> http://avcodec.org/trac/ffmpeg/ticket/247
>>>
>>> I had to solve this issue for my project, so I want to share a solution
>>> with you. I was able to compile this code on MinGW under windows, but I
>>> do not have opportunity to try it on other platforms. This solution is
>>> not maybe nicest, kind a brute-force, but seems to work (it is also fast).
>> Please send patches made with git diff libavformat/img2.c>patchfile.diff
>> If you cannot install git (it works fine on Windows), at least copy the original
>> img2.c and try diff -uw libavformat/img2orig.c libavformat/img2.c>patchfile.diff
>>
>> And please run tools/patcheck patchfile.diff, we use "for() {" and "if () {".
>>
>> Carl Eugen
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> Hi,
> as I'm currently using version 0.7-rc1 I have cloned latest git and  
> updated changes to that version. Attached you can find patch file.
>
> Regards,
> Robert

>  img2.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 79 insertions(+), 13 deletions(-)
> 796ccc8732643ff8d7eff5ef582908d3b6ff5963  image_range.diff
> diff --git a/libavformat/img2.c b/libavformat/img2.c
> index 77145cb..be51ad7 100644
> --- a/libavformat/img2.c
> +++ b/libavformat/img2.c
> @@ -30,6 +30,9 @@
>  #include "avio_internal.h"
>  #include "internal.h"
>  #include <strings.h>
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <dirent.h>
>  
>  typedef struct {
>      const AVClass *class;  /**< Class for private options. */
> @@ -133,27 +136,90 @@ static enum CodecID av_str2id(const IdStrMap *tags, const char *str)
>      return CODEC_ID_NONE;
>  }
>  
> +static void get_directory_from_path(const char* inPath, char* dirPath)
> +{
> +	int length, i;
> +	length = strlen(inPath);
> +
> +	for(i=length-1;i>=0;i--)
> +		if(inPath[i] == '\\' || inPath[i] =='/')
> +			break;
> +
> +	if(i == -1) {
> +		/* Files are in same directory as application */
> +		snprintf(dirPath, MAX_PATH,"./");
> +	} else {
> +		av_strlcpy(dirPath, inPath, i + 1);
> +		dirPath[i + 1] = '\0';
> +	}
> +}

I suggest to pass the length of the output array as parameter and not
just assume how large it is.


> +
> +static int get_index_for_file(const char* path)
> +{
> +	int length, i, last_digit, first_digit, index;
> +	length = strlen(path);
> +
> +	first_digit = -1;
> +	last_digit = -1;
> +
> +	for(i=length-1;i>=0;i--) {
> +		if(last_digit == -1) {
> +			if(isdigit(path[i]))
> +				last_digit = i;
> +		} else {
> +			if(isdigit(path[i]))
> +				first_digit = i;
> +			else
> +				break;
> +		}
> +	}

last_digit seems unused


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110826/61649964/attachment.asc>


More information about the ffmpeg-devel mailing list