Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#921 closed defect (fixed)

ffprobe may not correctly format json filesizes (patch attached)

Reported by: elkq Owned by: stefano
Priority: normal Component: ffprobe
Version: git-master Keywords: filesize
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

Filesizes greater than 2GB are not always json formatted as expected, (smaller files are fine) for example:

ffprobe -show_format -print_format json plus2GB.avi

ffprobe version N-36904-g71a2c9b Copyright (c) 2007-2012 the FFmpeg developers

built on Jan 17 2012 11:46:02 with gcc 4.6.1
configuration: --enable-shared --enable-gpl --enable-libfaac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
libavutil 51. 34.101 / 51. 34.101
libavcodec 53. 57.100 / 53. 57.100
libavformat 53. 30.100 / 53. 30.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 59.101 / 2. 59.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 51. 2.100 / 51. 2.100

{

"format": {

"filename": "plus2GB.avi",
"nb_streams": 2,
"format_name": "avi",
"format_long_name": "AVI format",
"start_time": "0.000",
"duration": "2012.040",
"size": "-1862884042",
"bit_rate": "9670118",
"tags": {

"encoder": "Lavf53.29.100"

}

}

the -prefix option has similar unexpected behaviour.

ffprobe -prefix -show_format -print_format json plus2GB.avi

Attachments (1)

0001-correct-reporting-of-2GB-file-sizes.patch (2.4 KB) - added by elkq 5 years ago.
[PATCH] correct reporting of +2GB file sizes

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by elkq

[PATCH] correct reporting of +2GB file sizes

comment:1 Changed 5 years ago by cehoyos

l = snprintf(buf, buf_size, "%ld", (int64_t)vald);

This should be 'snprintf(buf, buf_size, "%"PRId64, (int64_t)vald);' and similar below.

comment:2 in reply to: ↑ description ; follow-up: Changed 5 years ago by saste

  • Analyzed by developer set
  • Status changed from new to open

Replying to elkq:

Filesizes greater than 2GB are not always json formatted as expected, (smaller files are fine) for example:

ffprobe -show_format -print_format json plus2GB.avi

[...]

the -prefix option has similar unexpected behaviour.

I noticed the patch only after I already committed a fix, which is very similar to yours so sorry for not crediting (and you're right, maybe I should also change the size of the index).

Anyway should be fixed in:

commit 54661219c12905e70ea360b8aab1386438cae99d
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Wed Jan 18 00:01:07 2012 +0100

    ffprobe: fix printing of unit values which cannot be contained in an int
    
    Use long long int to contain such values instead of an int, which is
    required to contain at least 64 bits, so it is guaranteed to contain also
    int64_t values, which are used by some fields.
    
    In particular, should fix trac ticket #921.

Please confirm that it is fixed, thanks for the report&patch.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 5 years ago by elkq

Replying to saste:

Replying to elkq:

Filesizes greater than 2GB are not always json formatted as expected, (smaller files are fine) for example:

ffprobe -show_format -print_format json plus2GB.avi

[...]

the -prefix option has similar unexpected behaviour.

I noticed the patch only after I already committed a fix, which is very similar to yours so sorry for not crediting (and you're right, maybe I should also change the size of the index).

Anyway should be fixed in:

commit 54661219c12905e70ea360b8aab1386438cae99d
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Wed Jan 18 00:01:07 2012 +0100

    ffprobe: fix printing of unit values which cannot be contained in an int
    
    Use long long int to contain such values instead of an int, which is
    required to contain at least 64 bits, so it is guaranteed to contain also
    int64_t values, which are used by some fields.
    
    In particular, should fix trac ticket #921.

Please confirm that it is fixed, thanks for the report&patch.

Unfortunately we missed a case, the -unit option, i.e.:
$ ffprobe -unit -show_format -print_format json plus2GB.avi

So we probably also need to change line 129:

 - else            l = snprintf(buf, buf_size, "%d",   (int)vald);
 + else            l = snprintf(buf, buf_size, "%lld",   (long long int)vald);

comment:4 in reply to: ↑ 3 ; follow-up: Changed 5 years ago by saste

Replying to elkq:
[...]

Unfortunately we missed a case, the -unit option, i.e.:
$ ffprobe -unit -show_format -print_format json plus2GB.avi

So we probably also need to change line 129:

 - else            l = snprintf(buf, buf_size, "%d",   (int)vald);
 + else            l = snprintf(buf, buf_size, "%lld",   (long long int)vald);

Should be fixed in a later commit, please confirm if it works for you.

comment:5 Changed 5 years ago by saste

  • Keywords json removed
  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from open to closed

Tested with latest ffprobe in master, should be fixed, thanks again for reporting&patch.

comment:6 in reply to: ↑ 4 Changed 5 years ago by elkq

Replying to saste:

Replying to elkq:
[...]

Unfortunately we missed a case, the -unit option, i.e.:
$ ffprobe -unit -show_format -print_format json plus2GB.avi

So we probably also need to change line 129:

 - else            l = snprintf(buf, buf_size, "%d",   (int)vald);
 + else            l = snprintf(buf, buf_size, "%lld",   (long long int)vald);

Should be fixed in a later commit, please confirm if it works for you.

Yes, 54661219c12905e70ea360b8aab1386438cae99d corrects this behaviour,
all seems fixed, thank-you.

Note: See TracTickets for help on using tickets.