[FFmpeg-user] Correct fps value for h.264 stream
Oliver Fromme
oliver at fromme.com
Mon Apr 1 18:37:26 CEST 2013
Hello,
This is probably a very special problem, but maybe someone
has an answer ...
I've got an .m4v file that contains a h.264 video stream.
First thing I did is to convert it to .mkv because I can
handle Matroska files much better. So far, so good.
The container format (both .m4v and .mkv) reports a frame
rate of 25 fps, but there is something wrong with the video
stream: While mplayer plays the .mkv file fine, my media
runs riot on it. It reports "-1 fps" (!), so I extracted
the video stream from the container for examination: When
I run "mplayer -identify" on it, it reports 180000 fps, and
when I feed it into ffmpeg, it says 6203.12 fps. Something
is definitely wrong with the stream.
My first attempt was to re-encode the video stream with
ffmpeg. This worked fine, and now the media player can
play it, too. But this is not satisfactory because the
re-encoding is not lossless. So I tried various options
for ffmpeg with -vcodec copy, but it didn't work. No
matter what I did, the h.264 stream didn't change (I
checked with MD5) and the fps information was still wrong.
I assume this is to be expected when using -vcodec copy,
but, well, I had to try anyway.
Just in case this information is useful, this is what I
get without any options except "-vcodec copy":
$ ffmpeg1 -i vstream-orig.h264 -vcodec copy vstream-new.h264
ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 16 2013 13:55:27 with gcc 4.2.1 (GCC) 20070831 patched [FreeBSD]
configuration: --enable-x11grab --prefix=/usr/local --mandir=/usr/local/man --incdir=/usr/local/include/ffmpeg1 --libdir=/usr/local/lib/ffmpeg1 --shlibdir=/usr/local/lib/ffmpeg1 --datadir=/usr/local/share/ffmpeg1 --build-suffix=1 --progs-suffix=1 --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-pthreads --enable-memalign-hack --disable-libstagefright-h264 --disable-libutvideo --cc=cc --extra-cflags='-msse -I/usr/local/include/vorbis -I/usr/local/include' --extra-ldflags='-L/usr/local/lib ' --extra-libs=-pthread --disable-debug --disable-libaacplus --disable-indev=alsa --disable-outdev=alsa --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libass --disable-libcdio --disable-libcelt --enable-libfaac --disable-libfdk-aac --enable-fontconfig --enable-libfreetype --disable-frei0r --disable-gnutls --disable-libgsm --enable-libmp3lame --enable-libbluray --enable-libv4l2 --disable-libmodplug --disable-openal --enable-libopencv --enable-libo!
penjpeg --disable-libpulse --disab libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[h264 @ 0x8094c1420] Stream #0: not enough frames to estimate rate; consider increasing probesize
[h264 @ 0x8094c1420] Estimating duration from bitrate, this may be inaccurate
Input #0, h264, from 'vstream-orig.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p, 720x432 [SAR 64:45 DAR 64:27], 6203.12 fps, 90k tbr, 1200k tbn, 180k tbc
Output #0, h264, to 'vstream-new.h264':
Metadata:
encoder : Lavf54.29.104
Stream #0:0: Video: h264, yuv420p, 720x432 [SAR 64:45 DAR 64:27], q=2-31, 6203.12 fps, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36023 < 36024 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36024 < 36025 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36025 < 36026 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36026 < 36027 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36027 < 36028 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36028 < 36029 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36029 < 36030 invalid, clipping
[h264 @ 0x8094c1a20] st:0 PTS: -9223372036854775808 DTS: 36030 < 36031 invalid, clipping
... and so on ...
Those last lines reapeat A LOT. I guess one line per frame.
When I add "-r 25" for both input and output, the only thing
that changes is this:
Output #0, h264, to 'vstream-new.h264':
Metadata:
encoder : Lavf54.29.104
Stream #0:0: Video: h264, yuv420p, 720x432 [SAR 64:45 DAR 64:27], q=2-31, 6203.12 fps, 90k tbn, 25 tbc
i.e. the tbc value changes from 90k to 25. I still get the
"DTS invalid, clipping" lines, and it still says 6203.12 fps
for both input and output. The next thing I tried was
to add "-vsync drop". Now the "... clipping" lines were
gone, but of course the resulting file still didn't change.
I tried a lot of other options, but to no avail.
So, now my question is: Is there a way to correct the
wrong fps setting in the h.264 stream without re-encoding
it, i.e. without loss?
Please let me know if I have to provide more output or if
you want me to try more commands. Unfortunately I cannot
attach or upload the original file.
Best regards
Oliver
--
More information about the ffmpeg-user
mailing list