Opened 12 years ago

Closed 10 years ago

#1937 closed enhancement (fixed)

cdxl: wrong duration

Reported by: ami_stuff Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: cdxl
Cc: Michael Niedermayer Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

C:\>ffmpeg -i Fruit.CDXL out.avi
ffmpeg version N-46755-ge70144c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 15 2012 02:38:20 with gcc 4.5.0 (GCC) 20100414 (Fedora MinGW 4.5.
0-1.fc14)
  configuration: --prefix=/var/www/users/research/ffmpeg/snapshots/build --arch=
x86 --target-os=mingw32 --cross-prefix=i686-pc-mingw32- --cc='ccache i686-pc-min
gw32-gcc' --enable-w32threads --enable-memalign-hack --enable-runtime-cpudetect
--enable-cross-compile --enable-static --disable-shared --extra-libs='-lws2_32 -
lwinmm -lpthread' --extra-cflags='--static -I/var/www/users/research/ffmpeg/snap
shots/build/include' --extra-ldflags='-static -L/var/www/users/research/ffmpeg/s
napshots/build/lib' --enable-bzlib --enable-zlib --enable-gpl --enable-version3
--enable-nonfree --enable-libx264 --enable-libspeex --enable-libtheora --enable-
libvorbis --enable-libfaac --enable-libxvid --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx
  libavutil      52.  6.100 / 52.  6.100
  libavcodec     54. 71.100 / 54. 71.100
  libavformat    54. 36.100 / 54. 36.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.100 /  3. 23.100
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[cdxl @ 0x1edc2c0] Estimating duration from bitrate, this may be inaccurate
Input #0, cdxl, from 'Fruit.CDXL':
  Duration: 00:01:15.54, start: 0.000000, bitrate: 88 kb/s
    Stream #0:0: Video: cdxl, pal8, 128x80, 29.97 fps, 29.96 tbr, 11025 tbn
    Stream #0:1: Audio: pcm_s8, 11025 Hz, mono, u8, 88 kb/s
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf54.36.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 128x80, q=2-31, 200
kb/s, 29.96 tbn, 29.96 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 11025 Hz, mono, s16p
Stream mapping:
  Stream #0:0 -> #0:0 (cdxl -> mpeg4)
  Stream #0:1 -> #0:1 (pcm_s8 -> libmp3lame)
Press [q] to stop, [?] for help
frame=  150 fps=0.0 q=2.0 Lsize=      89kB time=00:00:05.01 bitrate= 145.6kbits/
s
video:64kB audio:10kB subtitle:0 global headers:0kB muxing overhead 21.236188%

Attachments (2)

Fruit.CDXL (813.3 KB ) - added by ami_stuff 12 years ago.
cdxl2.diff (1.8 KB ) - added by ami_stuff 12 years ago.

Download all attachments as: .zip

Change History (15)

by ami_stuff, 12 years ago

Attachment: Fruit.CDXL added

comment:1 by Carl Eugen Hoyos, 12 years ago

Keywords: cdxl added
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master
$ ffmpeg -i Fruit.CDXL -f null -
ffmpeg version N-46928-g52b7823 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 20 2012 22:01:42 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      52.  8.100 / 52.  8.100
  libavcodec     54. 74.100 / 54. 74.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.101 /  3. 23.101
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
[cdxl @ 0x2b7f280] Estimating duration from bitrate, this may be inaccurate
Input #0, cdxl, from 'Fruit.CDXL':
  Duration: 00:01:15.54, start: 0.000000, bitrate: 88 kb/s
    Stream #0:0: Video: cdxl, pal8, 128x80, 29.97 fps, 29.96 tbr, 11025 tbn
    Stream #0:1: Audio: pcm_s8, 11025 Hz, mono, u8, 88 kb/s
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf54.37.100
    Stream #0:0: Video: rawvideo, pal8, 128x80, q=2-31, 200 kb/s, 90k tbn, 29.96 tbc
    Stream #0:1: Audio: pcm_s16le, 11025 Hz, mono, s16, 176 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (cdxl -> rawvideo)
  Stream #0:1 -> #0:1 (pcm_s8 -> pcm_s16le)
Press [q] to stop, [?] for help
[null @ 0x2b7fc80] Encoder did not produce proper pts, making some up.
frame=  150 fps=0.0 q=0.0 Lsize=       0kB time=00:00:05.00 bitrate=   0.0kbits/s
video:14kB audio:108kB subtitle:0 global headers:0kB muxing overhead -100.000000%

comment:2 by ami_stuff, 12 years ago

the correct duration shoud be calculated like this:

int64_t filesize = avio_size(s->pb);

st->duration = (filesize /* - audiotrack_size */ ) / video_size / calculated_fps;

in reply to:  2 ; comment:3 by Carl Eugen Hoyos, 12 years ago

Replying to ami_stuff:

the correct duration shoud be calculated like this:

int64_t filesize = avio_size(s->pb);

st->duration = (filesize /* - audiotrack_size */ ) / video_size / calculated_fps;

If "video_size" and "calculated_fps" are known, wouldn't it be much easier to set the bitrate?

Version 0, edited 12 years ago by Carl Eugen Hoyos (next)

in reply to:  3 comment:4 by ami_stuff, 12 years ago

Replying to cehoyos:

If "video_size" and "calculated_fps" are known, wouldn't it be much easier to set the video bitrate?

True, but I have a problem with fps. Any idea how do I get value printed by ffmpeg?

st->codec->bit_rate      = (video_size * 8) /* * av_q2d(st->avg_frame_rate) /*

?

comment:5 by Carl Eugen Hoyos, 12 years ago

There is an if-then-else-block "if (cdxl->framerate)" inside the else-block of "if (cdxl->read_chunk && audio_size)", if the user did not specify a frame-rate, it may be possible to use the sample_rate instead.

by ami_stuff, 12 years ago

Attachment: cdxl2.diff added

comment:6 by ami_stuff, 12 years ago

Attached patch works for me (I couldn't get correct values while setting bit_rate).

It looks like Amiga software calculates duration the same way:

xlinfo fruit.cdxl
XLInfo 1.10 by Pantaray, Inc. Ukiah CA

      Type   Frame #    Size    Back   Image  Audio     X     Y  Pixel CMap
FIRST 1.0000 0000001    5552       0    5120    368   128    80      4   32

EST Total Frames: 150, Total Bytes 5552 out of 832800
Total Playing Time (at aprox. 27.68 FPS)  Seconds: 05.42

comment:7 by Carl Eugen Hoyos, 12 years ago

You could use the frame-counter in "AV_RB16(&cdxl->header[12]);" (I don't know if it is better, but it is possible).

What happens if the user set the framerate?

in reply to:  7 comment:8 by ami_stuff, 12 years ago

Replying to cehoyos:

You could use the frame-counter in "AV_RB16(&cdxl->header[12]);" (I don't know if it is better, but it is possible).

This value changes to random number at probing.
(for example when you use -framerate 5 then it will change to 28 from 150)

What happens if the user set the framerate?

I fixed this case - patch sent to ml.

comment:9 by Elon Musk, 12 years ago

Component: undeterminedavformat
Priority: normalwish
Type: defectenhancement

comment:10 by Michael Niedermayer, 10 years ago

does cdxl store the number of frames or bitrate somewhere ?
if not (and i dont see where) then the patch from ami is probably the best that can be done without reading the whole file

comment:11 by Michael Niedermayer, 10 years ago

Cc: michaelni added

comment:12 by Michael Niedermayer, 10 years ago

Cc: Michael Niedermayer added; michaelni removed

comment:13 by Michael Niedermayer, 10 years ago

Resolution: fixed
Status: openclosed

Fixed in 75cc85b23970b1238d6e3107ac817120e42a6686 by applying ami_stuffs patch

Note: See TracTickets for help on using tickets.