Ticket #1937 (open enhancement)
cdxl: wrong duration
| Reported by: | ami_stuff | Owned by: | |
|---|---|---|---|
| Priority: | wish | Component: | avformat |
| Version: | git-master | Keywords: | cdxl |
| Cc: | 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
Change History
comment:1 Changed 7 months ago by cehoyos
- Keywords cdxl added
- Status changed from new to open
- Version changed from unspecified to git-master
- Reproduced by developer set
$ 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 follow-up: ↓ 3 Changed 6 months ago by 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;
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 6 months ago by cehoyos
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 video bitrate?
comment:4 in reply to: ↑ 3 Changed 6 months ago by ami_stuff
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 Changed 6 months ago by cehoyos
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.
comment:6 Changed 6 months ago by ami_stuff
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 follow-up: ↓ 8 Changed 6 months ago by 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).
What happens if the user set the framerate?
comment:8 in reply to: ↑ 7 Changed 6 months ago by ami_stuff
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.



