title: Use ffmpeg to encode raw bayer_rggb8 frames as video
body: <p>I have some industrial camera that records and outputs frames in raw bayer_rggb8 format. Frames are 1920x1080 in size, shot at ~90fps. I wan't to create video from it (format doesn't matter much, but preferably mp4 with x264 encoding). My frames are saved on the filesystem as <code>frame-00001.raw</code>, <code>frame-00002.raw</code> etc. Every now and then there's empty file.</p>
  
  <p>I can convert single image to say PNG with the following command:</p>
  
  <pre><code>ffmpeg -f image2 -c:v rawvideo -pix_fmt bayer_rggb8 -s:v 1920x1080 -i frame-00400.raw output.png
  </code></pre>
  
  <p>But when I try to encode it as video with the following command:</p>
  
  <pre><code>ffmpeg -f image2 -c:v rawvideo -pix_fmt bayer_rggb8 -s:v 1920x1080 -r 90 -i frame-%05d.raw -c:v libx264 output.mp4
  </code></pre>
  
  <p>I get this console output:</p>
  
  <pre><code>Input #0, image2, from 'frame-%05d.raw':
    Duration: 00:00:05.26, start: 0.000000, bitrate: N/A
      Stream #0:0: Video: rawvideo ([186]RG[8] / 0x84752BA), bayer_rggb8, 1920x1080, 90 tbr, 90 tbn, 90 tbc
  File 'output.mp4' already exists. Overwrite ? [y/N] y
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (rawvideo (native) -&gt; h264 (libx264))
  Press [q] to stop, [?] for help
  [libx264 @ 0x7fe5c400a200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
  [libx264 @ 0x7fe5c400a200] profile High 4:4:4 Predictive, level 5.1, 4:4:4 8-bit
  [libx264 @ 0x7fe5c400a200] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  Output #0, mp4, to 'output.mp4':
    Metadata:
      encoder         : Lavf58.29.100
      Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1920x1080, q=-1--1, 90 fps, 11520 tbn, 90 tbc
      Metadata:
        encoder         : Lavc58.54.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
  frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
  video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
  </code></pre>
  
  <p>The file is 262bytes big, <code>cat output.mp4</code> returns this:</p>
  
  <pre><code>ftypisomisomiso2avc1mp4fremdat�moovlmvhd�@budtaZmeta!hdlrmdirappl-ilst%�toodataLavf58.29.100%
  </code></pre>
  
  <p>I can't really spot the problem. It happens both on MacOS Catalina and Ubuntu 16.04.</p>