[FFmpeg-devel] Image sequence file names

Robert Petka robert.petka at gmail.com
Tue Aug 30 21:34:49 CEST 2011


Dňa 26. 8. 2011 4:40, Michael Niedermayer  wrote / napísal(a):
> 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
>
>
> [...]
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Hi again,
here is my latest try to send you patch. I have used different editor 
this time. Patcheck writes just bunch of grep unrecognized option messages.

Buffer size is now passed to get_directory_from_path as argument.
last_digit is used as small helper to localize numeric pattern in file name.

Please let me know whether iit is somehow acceptable now :)

Regards,
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: image_range.diff
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110830/c0806e6f/attachment.ksh>


More information about the ffmpeg-devel mailing list