2

I have a sequence of PNG files (3D renders) that I want to encode as an H.264 video @ 30fps.

I'm using the following command (I happen to be compositing a background under the renders):

ffmpeg -loop 1 -i bg.jpg -r 30 -i renders/frame_%04d.png -c:v libx264 -preset veryfast \
       -profile:v main -filter_complex overlay -shortest -r 30 -pix_fmt yuv420p -t 16 \
       video.h264

The resulting video plays in VLC, but I can't seek properly (always corrupts like no keyframes), it shows no duration, and it shows no elapsed time as it plays.

If I use ffprobe to analyze the result, I see this:

$ ffprobe video.h264 
ffprobe version N-81995-gd790e48 Copyright (c) 2007-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
  libavutil      55. 32.100 / 55. 32.100
  libavcodec     57. 61.103 / 57. 61.103
  libavformat    57. 52.100 / 57. 52.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 64.100 /  6. 64.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, h264, from 'surround-view_front.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuv420p, 1920x1208, 30 fps, 30 tbr, 1200k tbn, 60 tbc

Why does that show Duration: N/A, bitrate: N/A, and how do I fix it?

1

You're outputting to a raw bitstream. Usually, you want to output to a container like .mp4, .mov or .mkv.

H.264 raw bitstreams have no index and individual frames have no timestamps (PTS/DTS). The definitive way to estimate the duration is by counting the frames and dividing by the frame rate. Of course, this only holds for streams to be shown at a constant framerate.

  • I appreciate the comment. In this case I am intentionally omitting a container because I am feeding the raw stream to an internal system that normally receives data from live cameras, and which is designed to work with H264 streams without containers. – Phrogz Nov 3 '16 at 16:18
  • I haven't seen a (ffmpeg-produced) H264 bitstream with duration since there's no global index or timestamps. At best you can count frames with ffprobe, and divide by the framerate. – Gyan Nov 3 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.