Transcode WEBM to RTMP - ffmpeg

Summary
My goal is to take a webcam stream from the browser and feed it into a program called Restreamer that takes in an RTMP stream.
I've deduced that the browser Recording API produces Blobs that can be saved as WEBM.
In order to stream the WEBM content to Restreamer I am attempting to use FFmpeg. I've read that forcing FLV format is required but otherwise all of the arguments are Greek to me. I've been unable to find a comparable topic where someone has tried to go from WEBM to RTMP. I have found examples of going the other direction, but reversing the FFmpeg command proved unfruitful.
Saving to FLV works fine. Using the following command, I am able to transcode a WEBM file to FLV and play it on VLC:
ffmpeg -i ~/big-buck-bunny_trailer.webm -f flv out.flv
However, if instead of outputting to a file I pass it to RTMP I get the following output:
ffmpeg -i ~/Downloads/big-buck-bunny_trailer.webm -f flv "rtmp://example.com/live"
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, matroska,webm, from '/home/kyjus25/big-buck-bunny_trailer.webm':
Metadata:
encoder : http://sourceforge.net/projects/yamka
creation_time : 2010-05-20T08:21:12.000000Z
Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)
Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
HandShake: client signature does not match!
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> flv1 (flv))
Stream #0:1 -> #0:1 (vorbis (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, flv, to 'rtmp://example.com/live':
Metadata:
encoder : Lavf59.16.100
Stream #0:0(eng): Video: flv1 ([2][0][0][0] / 0x0002), yuv420p(tv, bt470bg/unknown/unknown, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 1k tbn (default)
Metadata:
encoder : Lavc59.18.100 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, mono, fltp (default)
Metadata:
encoder : Lavc59.18.100 libmp3lame
WriteN, RTMP send error 32 (136 bytes)7kB time=00:00:00.39 bitrate= 136.7kbits/s speed=71.2x
WriteN, RTMP send error 32 (35 bytes)
WriteN, RTMP send error 9 (42 bytes)
av_interleaved_write_frame(): Operation not permitted
Last message repeated 1 times
[flv # 0x55d0dd0af700] Failed to update header with correct duration.
[flv # 0x55d0dd0af700] Failed to update header with correct filesize.
Error writing trailer of rtmp://example.com/live: Operation not permitted
frame= 53 fps=0.0 q=4.3 Lsize= 146kB time=00:00:02.45 bitrate= 486.8kbits/s speed=42.8x
video:128kB audio:19kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Error closing file rtmp://example.com/live: Operation not permitted
Conversion failed!
There are several interesting rabbit holes to follow here, but after following all of them I've come up with nothing.
• HandShake: client signature does not match!:
More of a warning than an error, I assumed because I was going from "WEBM -> FLV" instead of the more traditional "MP4 -> FLV".
• av_interleaved_write_frame(): Operation not permitted:
I found several issues on this. One of them calling it a storage issue, the other calling it a file permissions issue. I have plenty of disk space and have tried setting the input file to 777 permissions. However, the examples I've found on it being a file permissions issue all deal with outputting to a file rather than to an an RTMP IP.
• Failed to update header with correct duration:
Advice I found was to add -flvflags no_duration_filesize to the command, which does suppress both "Failed to update..." errors, but does not fix the over-arching issue.
What I've Tried
• Multi-format transcoding
MP4 to RTMP does work correctly:
ffmpeg -i ~/Downloads/big-buck-bunny_trailer.mp4 -f flv "rtmp://example.com/live"
Theoretically, I could stream the WEBM to a file, transcode that to an MP4 file, and then transcode that to FLV/RTMP. Sounds awful.
• Pay for a service (Wowza, Flashphoner, api.video, etc)
Unfortunately precisely what I am trying to avoid.
• WebRTC to RTMP?
WebRTC seems to be a peer-to-peer connection and doesn't play nicely with a server/client scenario.
• WebRTC to other ingest formats
Restreamer also supports incoming streams of HLS, DASH, RTP, RTSP, RTMP, and SRT. However, these all seem to be examples of network sources that would be exposed via an IP URL. I am not sure that FFmpeg can do that.
• Utilizing ffmpeg-wasm instead of CLI
Available here, I thought that maybe by using a browser implementation I may get different results. But no. Not even an error to the console.
• Streaming from OBS
For the record, yes, I have tried streaming from OBS instead of going through FFmpeg and the Restreamer platform itself does work for normal use. I use it often.
Post Script
I've not been able to find any relevant solutions online. I am shocked that streaming from a browser webcam has not been solved 1000 times prior. This is related to a question made 7 years ago but it was not resolved and Flash is no longer an option.
Recommendations
• Adding -c:v libx264 -flags:v +global_header -c:a aac -ac 2:
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, matroska,webm, from '/home/kyjus25/big-buck-bunny_trailer.webm':
Metadata:
encoder : http://sourceforge.net/projects/yamka
creation_time : 2010-05-20T08:21:12.000000Z
Duration: 00:00:32.48, start: 0.000000, bitrate: 533 kb/s
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)
Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
HandShake: client signature does not match!
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (vorbis (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x561564271fc0] using SAR=1/1
[libx264 # 0x561564271fc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x561564271fc0] profile High, level 3.0, 4:2:0, 8-bit
[libx264 # 0x561564271fc0] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=11 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, flv, to 'rtmp://example.com/live':
Metadata:
encoder : Lavf59.16.100
Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p(tv, bt470bg/unknown/unknown, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 1k tbn (default)
Metadata:
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc59.18.100 aac
Larger timestamp than 24-bit: 0xffffff77kB time=00:00:30.18 bitrate= 460.0kbits/s speed=19.7x
[flv # 0x56156425e440] Failed to update header with correct duration.
[flv # 0x56156425e440] Failed to update header with correct filesize.
frame= 812 fps=475 q=-1.0 Lsize= 1901kB time=00:00:32.52 bitrate= 479.0kbits/s speed= 19x
video:1354kB audio:508kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.123872%
[libx264 # 0x561564271fc0] frame I:21 Avg QP:15.05 size: 8839
[libx264 # 0x561564271fc0] frame P:293 Avg QP:20.78 size: 3087
[libx264 # 0x561564271fc0] frame B:498 Avg QP:22.20 size: 593
[libx264 # 0x561564271fc0] consecutive B-frames: 14.7% 7.6% 9.2% 68.5%
[libx264 # 0x561564271fc0] mb I I16..4: 42.6% 41.9% 15.5%
[libx264 # 0x561564271fc0] mb P I16..4: 4.0% 8.0% 0.9% P16..4: 22.7% 8.0% 4.0% 0.0% 0.0% skip:52.4%
[libx264 # 0x561564271fc0] mb B I16..4: 1.4% 1.5% 0.2% B16..8: 12.0% 1.0% 0.2% direct: 3.3% skip:80.5% L0:44.1% L1:47.1% BI: 8.8%
[libx264 # 0x561564271fc0] 8x8 transform intra:53.6% inter:57.0%
[libx264 # 0x561564271fc0] coded y,uvDC,uvAC intra: 35.1% 37.7% 11.2% inter: 7.8% 9.5% 2.4%
[libx264 # 0x561564271fc0] i16 v,h,dc,p: 56% 21% 14% 9%
[libx264 # 0x561564271fc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 26% 21% 3% 3% 4% 4% 3% 4%
[libx264 # 0x561564271fc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 18% 4% 7% 7% 6% 5% 4%
[libx264 # 0x561564271fc0] i8c dc,h,v,p: 62% 21% 15% 2%
[libx264 # 0x561564271fc0] Weighted P-Frames: Y:20.8% UV:19.5%
[libx264 # 0x561564271fc0] ref P L0: 70.3% 17.7% 9.0% 2.9% 0.0%
[libx264 # 0x561564271fc0] ref B L0: 89.3% 8.9% 1.9%
[libx264 # 0x561564271fc0] ref B L1: 96.4% 3.6%
[libx264 # 0x561564271fc0] kb/s:341.30
[aac # 0x561564223140] Qavg: 952.636
Seems to complete successfully, but does so rather quickly. Log outputs a new Larger timestamp than 24-bit: 0xffffff77kB

Was able to get it to work by using:
ffmpeg -re -i sample.webm -c:v h264 -c:a aac -f flv "rtmp://example.com/live"
The -re was essential to make it stream in real time, otherwise #Gyan's suggestion would have also worked!

Related

omxplayer freezes with videos generated with FFMPEG

Omxplayer won't play any videos generated with FFmpeg on a Raspberry Pi
I found this thread showing that it is necessary to include '-profile baseline -level 3.0' parameters: https://github.com/popcornmix/omxplayer/issues/577
The full command is:
ffmpeg -framerate 1/10 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p -profile baseline -level 3.0 images.mp4
I did that and now I am experiencing intermittent behavior.
Sometimes it works and sometimes it does not work. I cannot explain why/when it plays or not.
I also found a thread showing that it is necessary to upgrade the firmware and player. I did that and still having the same issue.
Here is an example. First time it plays ok. Second time it freezes.
First time: creating mp4
(env) pi#raspberrypi:~/mkt $ ffmpeg -framerate 1/10 -pattern_type glob -i 'mensagens/*.jpeg' -c:v libx264 -pix_fmt yuv420p -profile baseline -level 3.0 images.mp4
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --prefix=/usr --extra-version='1~deb10u1+rpt1' --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, image2, from 'mensagens/*.jpeg':
Duration: 00:01:10.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 1024x768 [SAR 72:72 DAR 4:3], 0.10 fps, 0.10 tbr, 0.10 tbn, 0.10 tbc
Please use -profile:a or -profile:v, -profile is ambiguous
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler # 0x182ad70] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x17b1170] using SAR=1/1
[libx264 # 0x17b1170] frame MB size (64x48) > level limit (1620)
[libx264 # 0x17b1170] using cpu capabilities: none!
[libx264 # 0x17b1170] profile Constrained Baseline, level 3.0
[libx264 # 0x17b1170] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=2 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=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=1 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 'images.mp4':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], q=-1--1, 0.10 fps, 16384 tbn, 0.10 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 7 fps=0.7 q=15.0 Lsize= 79kB time=00:01:00.00 bitrate= 10.8kbits/s speed=5.66x
video:78kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.085207%
[libx264 # 0x17b1170] frame I:3 Avg QP: 2.03 size: 14789
[libx264 # 0x17b1170] frame P:4 Avg QP: 5.28 size: 8794
[libx264 # 0x17b1170] mb I I16..4: 91.0% 0.0% 9.0%
[libx264 # 0x17b1170] mb P I16..4: 26.1% 0.0% 3.8% P16..4: 3.4% 1.3% 1.0% 0.0% 0.0% skip:64.4%
[libx264 # 0x17b1170] coded y,uvDC,uvAC intra: 6.5% 0.0% 0.0% inter: 2.8% 0.0% 0.0%
[libx264 # 0x17b1170] i16 v,h,dc,p: 97% 1% 2% 0%
[libx264 # 0x17b1170] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 19% 20% 4% 3% 4% 3% 3% 3%
[libx264 # 0x17b1170] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x17b1170] ref P L0: 55.1% 44.9%
[libx264 # 0x17b1170] kb/s:9.09
First time playing mp4 (it plays OK):
(env) pi#raspberrypi:~/mkt $ omxplayer images.mp4
Invalid framerate 0, using forced 25fps and just trust timestamps
Video codec omx-h264 width 1024 height 768 profile 578 fps 25.000000
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: 1024x768#0.10 interlace:0 deinterlace:0 anaglyph:0 par:1.00 display:0 layer:0 alpha:255 aspectMode:0
have a nice day ;)
Second time creating mp4 (nothing changes):
(env) pi#raspberrypi:~/mkt $ ffmpeg -framerate 1/10 -pattern_type glob -i 'mensagens/*.jpeg' -c:v libx264 -pix_fmt yuv420p -profile baseline -level 3.0 images.mp4
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --prefix=/usr --extra-version='1~deb10u1+rpt1' --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, image2, from 'mensagens/*.jpeg':
Duration: 00:01:10.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 1024x768 [SAR 72:72 DAR 4:3], 0.10 fps, 0.10 tbr, 0.10 tbn, 0.10 tbc
Please use -profile:a or -profile:v, -profile is ambiguous
File 'images.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler # 0x1c5fd70] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x1be6170] using SAR=1/1
[libx264 # 0x1be6170] frame MB size (64x48) > level limit (1620)
[libx264 # 0x1be6170] using cpu capabilities: none!
[libx264 # 0x1be6170] profile Constrained Baseline, level 3.0
[libx264 # 0x1be6170] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=2 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=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=1 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 'images.mp4':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1024x768 [SAR 1:1 DAR 4:3], q=-1--1, 0.10 fps, 16384 tbn, 0.10 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 7 fps=0.7 q=15.0 Lsize= 79kB time=00:01:00.00 bitrate= 10.8kbits/s speed=5.78x
video:78kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.085207%
[libx264 # 0x1be6170] frame I:3 Avg QP: 2.03 size: 14789
[libx264 # 0x1be6170] frame P:4 Avg QP: 5.28 size: 8794
[libx264 # 0x1be6170] mb I I16..4: 91.0% 0.0% 9.0%
[libx264 # 0x1be6170] mb P I16..4: 26.1% 0.0% 3.8% P16..4: 3.4% 1.3% 1.0% 0.0% 0.0% skip:64.4%
[libx264 # 0x1be6170] coded y,uvDC,uvAC intra: 6.5% 0.0% 0.0% inter: 2.8% 0.0% 0.0%
[libx264 # 0x1be6170] i16 v,h,dc,p: 97% 1% 2% 0%
[libx264 # 0x1be6170] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 19% 20% 4% 3% 4% 3% 3% 3%
[libx264 # 0x1be6170] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x1be6170] ref P L0: 55.1% 44.9%
[libx264 # 0x1be6170] kb/s:9.09
Second time playing mp4 (it freezes. I had to ctrl-c to interrupt):
(env) pi#raspberrypi:~/mkt $ omxplayer images.mp4
Invalid framerate 0, using forced 25fps and just trust timestamps
Video codec omx-h264 width 1024 height 768 profile 578 fps 25.000000
Subtitle count: 0, state: off, index: 1, delay: 0
Stopped at: 00:00:00
have a nice day ;)
Most players don't like such a low frame rate. Add -r 10 output option:
ffmpeg -framerate 1/10 -pattern_type glob -i 'mensagens/*.jpeg' -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -r 10 images.mp4
You don't have to use -r 10 specifically. It was an arbitrary example that should be high enough for most players but feel free to experiment.
Frames will be duplicated to go from 1/10 to 10, but the output will look the same and play at the correct speed.
You may not need -level, or at least not 3.0 (which your input attributes exceed anyway). You may not even need -profile:v, or try -profile:v main instead.

ffmpeg: problems playing video on android

(Translated) Hello! I have the following problem. I concatenate multiple ts files and convert to mp4 with ffmpeg. I do this operation multiple times in an automated way, so I don't always check the results, but whenever I do, on the computer, the result obtained is as expected. However, some videos, when played on an Android device, are seen incorrectly in any application: Chrome, Firefox, Vlc, etc. The version of ffmpeg I use is the latest. This is the command I use:
ffmpeg.exe -hwaccel dxva2 -y -f concat -i list.txt -acodec copy -vcodec copy output.mp4 -preset normal
Results:
PC
Android
This is the output of ffmpeg:
ffmpeg version n4.3.1-26-gca55240b8c Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3-win32 (GCC) 20200320
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Trailing option(s) found in the command: may be ignored.
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, 29.50 fps, 29.50 tbr, 90k tbn, 180k tbc
Stream #0:2: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 64 kb/s
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, q=2-31, 29.50 fps, 29.50 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 9504 fps=8330 q=-1.0 Lsize= 24561kB time=00:07:42.26 bitrate= 435.3kbits/s speed= 405x
video:21200kB audio:3100kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.073735%
Not all videos are "yuv420p (tv, unknown / bt470bg / unknown, progressive)", but this should not be the problem, since other videos with this information are seen correctly on Android.
To correct this type of video I do the following:
ffmpeg -y -f concat -i list.txt -c:v libx264 -preset slow -crf 22 -pix_fmt yuv420p -c:a aac -b:a 128k output.mp4
So I get the video to play correctly both on pc and Android. Unfortunately, automating the process by always using this last line occasionally causes problems (starting file 40MB, ending file> 1GB, more than 2 hours)
I would like, if possible, help me identify which videos will be viewed incorrectly on Android. Thank you very much in advance. Finally, this is the answer that ffmpeg gives when executing the line with which I fix the file:
ffmpeg version n4.3.1-26-gca55240b8c Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3-win32 (GCC) 20200320
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Data: timed_id3 (ID3 / 0x20334449)
Stream #0:1: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/bt470bg/unknown, progressive), 320x568, 29.50 fps, 29.50 tbr, 90k tbn, 180k tbc
Stream #0:2: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:2 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001efdbaee540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001efdbaee540] profile High, level 3.0, 4:2:0, 8-bit
[libx264 # 000001efdbaee540] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'd.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x568, q=-1--1, 29.50 fps, 15104 tbn, 29.50 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s
Metadata:
encoder : Lavc58.91.100 aac
More than 1000 frames duplicated 8960kB time=00:02:06.74 bitrate= 579.1kbits/s dup=999 drop=0 speed=15.7x
frame=13638 fps=468 q=-1.0 Lsize= 32033kB time=00:07:42.20 bitrate= 567.8kbits/s dup=4134 drop=0 speed=15.9x
video:25547kB audio:5995kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.557852%
[libx264 # 000001efdbaee540] frame I:87 Avg QP:19.17 size: 12750
[libx264 # 000001efdbaee540] frame P:4630 Avg QP:21.89 size: 4286
[libx264 # 000001efdbaee540] frame B:8921 Avg QP:23.89 size: 583
[libx264 # 000001efdbaee540] consecutive B-frames: 8.9% 8.6% 9.1% 73.4%
[libx264 # 000001efdbaee540] mb I I16..4: 12.2% 76.2% 11.6%
[libx264 # 000001efdbaee540] mb P I16..4: 3.7% 11.0% 0.8% P16..4: 37.1% 16.2% 5.7% 0.0% 0.0% skip:25.4%
[libx264 # 000001efdbaee540] mb B I16..4: 0.3% 0.9% 0.1% B16..8: 30.4% 3.1% 0.3% direct: 0.8% skip:64.2% L0:51.4% L1:44.3% BI: 4.3%
[libx264 # 000001efdbaee540] 8x8 transform intra:71.2% inter:66.8%
[libx264 # 000001efdbaee540] direct mvs spatial:99.9% temporal:0.1%
[libx264 # 000001efdbaee540] coded y,uvDC,uvAC intra: 52.5% 42.1% 5.5% inter: 9.7% 9.0% 0.3%
[libx264 # 000001efdbaee540] i16 v,h,dc,p: 19% 21% 9% 50%
[libx264 # 000001efdbaee540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 11% 13% 6% 9% 11% 9% 11% 8%
[libx264 # 000001efdbaee540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 9% 8% 6% 14% 14% 11% 9% 6%
[libx264 # 000001efdbaee540] i8c dc,h,v,p: 46% 20% 23% 12%
[libx264 # 000001efdbaee540] Weighted P-Frames: Y:2.9% UV:0.8%
[libx264 # 000001efdbaee540] ref P L0: 72.3% 12.2% 11.3% 2.1% 1.9% 0.2% 0.0%
[libx264 # 000001efdbaee540] ref B L0: 93.1% 5.5% 1.1% 0.3%
[libx264 # 000001efdbaee540] ref B L1: 97.6% 2.4%
[libx264 # 000001efdbaee540] kb/s:452.67
[aac # 000001efdbaee9c0] Qavg: 10682.834

FFMPEG, can't stream rtmp static image with mp3

I try to stream on my own rtmp nginx server an single static jpeg image with an mp3 which have about an hour, and from my nginx rtmp to YouTube, but audio is not constant and without image...
This is what I used...
#! /bin/bash
VBR="1500k"
FPS="30"
QUAL="ultrafast"
YOUTUBE_URL="rtmp://localhost:1935/live"
YOUTUBE_KEY="test"
VIDEO_SOURCE="image.jpg"
AUDIO_SOURCE="music.mp3"
AUDIO_ENCODER="libmp3lame"
ffmpeg \
-loop 1 \
-re \
-framerate $FPS \
-i "$VIDEO_SOURCE" \
-thread_queue_size 512 \
-i "$AUDIO_SOURCE" \
-c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR \
-c:a $AUDIO_ENCODER -threads "$(nproc)" -ar 44100 -b:a 128k -bufsize 512k -pix_fmt yuv420p \
-vf scale=1280x720,setsar=1:1 \
-f flv $YOUTUBE_URL/$YOUTUBE_KEY
Output:
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, image2, from 'unsplash.jpg':
Duration: 00:00:00.03, start: 0.000000, bitrate: 1976946 kb/s
Stream #0:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 7952x4472 [SAR 72:72 DAR 994:559], 30 tbr, 30 tbn, 30 tbc
Input #1, mp3, from 'ArtOfTrippyCode.mp3':
Metadata:
encoder : Lavf58.29.100
Duration: 01:07:25.34, start: 0.023021, bitrate: 141 kb/s
Stream #1:0: Audio: mp3, 48000 Hz, stereo, fltp, 141 kb/s
Metadata:
encoder : Lavc58.54
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[swscaler # 0x564a7bd3ed80] deprecated pixel format used, make sure you did set range correctly
[libx264 # 0x564a7b3e9680] VBV maxrate unspecified, assuming CBR
[libx264 # 0x564a7b3e9680] using SAR=1/1
[libx264 # 0x564a7b3e9680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x564a7b3e9680] profile Constrained Baseline, level 3.1
[libx264 # 0x564a7b3e9680] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=2 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=60 keyint_min=6 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=cbr mbtree=0 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1500 vbv_bufsize=512 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
Output #0, flv, to 'rtmp://localhost:1935/live/test':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1500 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 512000 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54.100 libmp3lame
[flv # 0x564a7b3e8340] Failed to update header with correct duration.863.7kbits/s speed=0.0424x
[flv # 0x564a7b3e8340] Failed to update header with correct filesize.
frame= 15 fps=1.6 q=-1.0 Lsize= 97kB time=00:00:00.47 bitrate=1686.4kbits/s speed=0.0511x
video:88kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.021540%
[libx264 # 0x564a7b3e9680] frame I:1 Avg QP:34.00 size: 25690
[libx264 # 0x564a7b3e9680] frame P:14 Avg QP:29.21 size: 4569
[libx264 # 0x564a7b3e9680] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 # 0x564a7b3e9680] mb P I16..4: 0.5% 0.0% 0.0% P16..4: 16.0% 0.0% 0.0% 0.0% 0.0% skip:83.5%
[libx264 # 0x564a7b3e9680] coded y,uvDC,uvAC intra: 51.0% 11.4% 1.2% inter: 8.2% 3.3% 0.1%
[libx264 # 0x564a7b3e9680] i16 v,h,dc,p: 32% 25% 31% 13%
[libx264 # 0x564a7b3e9680] i8c dc,h,v,p: 82% 11% 7% 0%
[libx264 # 0x564a7b3e9680] kb/s:1434.54

Improve ffmpeg x11grab screen capture performance

I have been doing screen-only (no sound) capture using ffmpeg with libx264 for the encoding quite successfully on an old machine built around a Core2 Quad Q6600 processor. I now need to include audio in this, but the fans on this ancient machine are too loud. So, I found a fanless motherboard (https://www.asrock.com/mb/Intel/J5005-ITX/index.asp) that has an Intel Pentium Silver J5005 processor and decided to use this instead. The CPU's benchmarks put it in a similar bracket to the Q6600, and the general performance seems to be significantly better, presumably at least in part because it's now using DDR4 memory that's faster access.
However, the machine fails horribly at the screen capture. It's missing frames all over the place; I actually end up with video that's missing almost half the frames, and plays back at about double speed. Also, any audio is just messed up so badly I can hardly think how to describe it, best I can come up with is that I get perhaps a quarter second of sound then a few seconds pause (the video meanwhile is actually still playing back, albeit with no sense of time).
Some things occur to me that might be the cause, or cure, of my troubles, some of which I might be able to fix, others not so much. What other things should I try? (I'd prefer to avoid simply throwing money at the issue with random ideas that are baseless!)
1) perhaps the CPU lacks some "extensions" to the instruction set (I recall years ago some CPUs gaining MMX extensions") so that the CPU is fast at mundane computing but sucks at video encoding.
2) perhaps the fact that the old machine had a dedicated graphics card, while this new one is sharing main memory with the graphics system means that reading the screen pixels is much slower.
3) perhaps the fact that this new machine has a single DDR4 memory stick in it means that I'm forcing all the memory reads and writes for the computations through the same memory as is holding the screen, and that's too much (implying that adding an additional memory stick might jus possibly help?)
4) perhaps there's some bios setting that would allow more efficient sharing of video memory?
5) my favorite, perhaps there's a better compression library that I could use to get decent quality screen capture with much less CPU usage.
I should also note that I have tried this with -threads 0, and the CPU usage hovers between 100% and 200%; around 100% when the screen is static, and rising as I move windows around and otherwise create more output.
6) the motherboard claims to have some kind of hardware video encoder built into it. I haven't paid this any attention to this point, as I assumed it was for the purpose of taking HDMI input and encoding it, but maybe there's a way to use this, if so, what libraries might I need to get ffmpeg to do this.
Edits:
This is an off the shelf ffmpeg. I'm certainly willing to try building it myself if I have some idea what I should do different.
The motherboard claims to have hardware encoders, but I'm struggling to find out what they are (seems like it's an Intel chip called "UHD Graphics 605" but nothing I can find suggests ffmpeg can work with that)
command line right now has been (without audio):
ffmpeg -video_size 1280x720 -f x11grab -i ${DISPLAY}+100,100 -vcodec libx264 -f alsa -i pulse -acodec ac3 -threads 0 ./video$(date +%F-%H-%M-%S).mp4
Log from a short recording session is:
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[x11grab # 0x561a723e5ac0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0+100,100':
Duration: N/A, start: 1578693116.465807, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Unknown decoder 'libx264'
simon#studio:~$ ffmpeg -video_size 1280x720 -f x11grab -i ${DISPLAY}+100,100 -vcodec libx264 -threads 0 ./video$(date +%F-%H-%M-%S).mp4
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[x11grab # 0x558225bc29a0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0+100,100':
Duration: N/A, start: 1578693132.513351, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x558225bcd360] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 # 0x558225bcd360] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 # 0x558225bcd360] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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 './video2020-01-10-14-52-12.mp4':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1280x720, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Past duration 0.806847 too large 256kB time=00:00:00.43 bitrate=4835.3kbits/s dup=16 drop=0 speed=0.207x
frame= 371 fps= 29 q=-1.0 Lsize= 639kB time=00:00:12.27 bitrate= 426.6kbits/s dup=16 drop=14 speed=0.971x
video:634kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.813096%
[libx264 # 0x558225bcd360] frame I:2 Avg QP:18.16 size:221502
[libx264 # 0x558225bcd360] frame P:93 Avg QP:14.97 size: 2007
[libx264 # 0x558225bcd360] frame B:276 Avg QP:20.13 size: 69
[libx264 # 0x558225bcd360] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 # 0x558225bcd360] mb I I16..4: 44.6% 0.0% 55.4%
[libx264 # 0x558225bcd360] mb P I16..4: 0.2% 0.0% 0.3% P16..4: 0.7% 0.1% 0.1% 0.0% 0.0% skip:98.5%
[libx264 # 0x558225bcd360] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 1.0% 0.0% 0.0% direct: 0.0% skip:99.0% L0:50.9% L1:49.0% BI: 0.1%
[libx264 # 0x558225bcd360] coded y,u,v intra: 41.3% 37.5% 37.4% inter: 0.1% 0.0% 0.0%
[libx264 # 0x558225bcd360] i16 v,h,dc,p: 58% 41% 1% 0%
[libx264 # 0x558225bcd360] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 30% 14% 2% 4% 4% 5% 3% 5%
[libx264 # 0x558225bcd360] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x558225bcd360] ref P L0: 59.2% 8.8% 25.5% 6.5%
[libx264 # 0x558225bcd360] ref B L0: 59.4% 39.0% 1.6%
[libx264 # 0x558225bcd360] ref B L1: 96.5% 3.5%
[libx264 # 0x558225bcd360] kb/s:419.29
Exiting normally, received signal 2.

avconv on debian jessie throws error when trying to convert raw video to mp4

I am trying to convert a raw video captured using a Logitech USB Cam(YUYV) to mp4 using avconv. I have tried the below to do so:
avconv -i out.raw -c copy output.mp4
avconv -i out.raw -vcodec copy -acodec copy output.mp4
but I get an error as shown below.
root#beaglebone:~/BBB_CV/boneCV# avconv -i out.raw -c copy output.mp4
avconv version 11.9-6:11.9-1~deb8u1, Copyright (c) 2000-2017 the Libav developersbuilt on Apr 23 2017 23:00:54 with gcc 4.9.2 (Debian 4.9.2-10)
out.raw: Invalid data found when processing input
I have checked here, but did not find any relevant examples for the above purpose.
Edit: Added more details--
I tried doing the below by adding the infile options as suggested:
root#beaglebone:~/BBB_CV/boneCV# avconv -s 640x480 -framerate 30 -pix_fmt yuyv422 -f rawvideo -i out.raw -c copy output.mp4
This got me rid of the previous error and some new ones popped up as shown below.
root#beaglebone:~/BBB_CV/boneCV# avconv -s 640x480 -framerate 30 -pix_fmt yuyv422 -f rawvideo -i out.raw -c copy output.mp4
avconv version 11.9-6:11.9-1~deb8u1, Copyright (c) 2000-2017 the Libav
developers built on Apr 23 2017 23:00:54 with gcc 4.9.2 (Debian 4.9.2-10)
[rawvideo # 0x17e21c0] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'out.raw':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, yuyv422, 640x480, 30 tbn
[mp4 # 0x17eb840] Codec for stream 0 does not use global headers but
container format requires global headers
[mp4 # 0x17eb840] track 0: could not find tag, codec not currently
supported in container
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf56.1.0
Stream #0.0: Video: rawvideo, yuyv422, 640x480, q=2-31, 30 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?):
Operation not permitted
The output.mp4 is being generated but when tried to open it throws an error.
Edit: I ran a "sudo apt-get install libav-tools" an then tried. This is what I got.
root#beaglebone:~/BBB_CV/boneCV# avconv -s 640x480 -framerate 30 -pix_fmt
yuyv422 -f rawvideo -i out.raw -c copy output.mp4
ffmpeg version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-
strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro'
-cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-
nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-
libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-
libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-
libvpx --enable-libschroedinger --disable-encoder=libschroedinger --
enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter -
enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-
libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/arm-linux-gnueabihf -
-disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-
frei0r --enable-openssl --enable-libass --enable-libopus --enable-
fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --
disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample
--disable-htmlpages --disable-podpages --enable-libutvideo --enable-
libfdk-aac --enable-libx265 --enable-libiec61883 --enable-libdc1394 --
disable-altivec --shlibdir=/usr/lib/arm-linux-gnueabihf
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[rawvideo # 0x18465e0] Estimating duration from bitrate, this may be
inaccurate
Input #0, rawvideo, from 'out.raw':
Duration: 00:00:00.10, start: 0.000000, bitrate: 146626 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456
kb/s, 30 tbr, 30 tbn, 30 tbc
[mp4 # 0x184f790] Could not find tag for codec rawvideo in stream #0,
codec not currently supported in container
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf56.25.101
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, q=2-
31, 147456 kb/s, 30 tbr, 30 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
I ran "ffmpeg -s 640x480 -framerate 30 -pix_fmt yuv420p -f rawvideo -i out.raw output.mp4" and below is what I got.
root#beaglebone:~/BBB_CV/boneCV# ffmpeg -s 640x480 -framerate 30 -pix_fmt yuv420p -f rawvideo -i out.raw output.mp4
ffmpeg version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/arm-linux-gnueabihf --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/arm-linux-gnueabihf
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
[rawvideo # 0x1d55e0] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'out.raw':
Duration: 00:00:00.13, start: 0.000000, bitrate: 109969 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 110592 kb/s, 30 tbr, 30 tbn, 30 tbc
[libx264 # 0x1df6c0] using cpu capabilities: ARMv6 NEON
[libx264 # 0x1df6c0] profile High, level 3.0
[libx264 # 0x1df6c0] 264 - core 146 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 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 : Lavf56.25.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc56.26.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[rawvideo # 0x1de3a0] Invalid buffer size, packet size 450428 < expected frame_size 460800
Error while decoding stream #0:0: Invalid argument
frame= 3 fps=1.7 q=29.0 Lsize= 263kB time=00:00:00.03 bitrate=64692.6kbits/s
video:262kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.318205%
[libx264 # 0x1df6c0] frame I:1 Avg QP:33.09 size:100676
[libx264 # 0x1df6c0] frame P:2 Avg QP:32.99 size: 83672
[libx264 # 0x1df6c0] mb I I16..4: 0.0% 95.4% 4.6%
[libx264 # 0x1df6c0] mb P I16..4: 0.0% 45.7% 3.0% P16..4: 35.9% 10.7% 4.8% 0.0% 0.0% skip: 0.0%
[libx264 # 0x1df6c0] 8x8 transform intra:94.6% inter:86.1%
[libx264 # 0x1df6c0] coded y,uvDC,uvAC intra: 100.0% 100.0% 100.0% inter: 53.6% 100.0% 100.0%
[libx264 # 0x1df6c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 56% 12% 24% 2% 0% 1% 1% 2% 3%
[libx264 # 0x1df6c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 82% 11% 4% 0% 0% 0% 1% 0% 1%
[libx264 # 0x1df6c0] i8c dc,h,v,p: 48% 30% 14% 7%
[libx264 # 0x1df6c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1df6c0] ref P L0: 83.5% 7.9% 8.6%
[libx264 # 0x1df6c0] kb/s:21441.60
Since the input is raw, avconv doesn't know input properties. It needs to register those into the MOOV box of the MP4 it creates. So, before -i out.raw, you need to specify -s WxH -framerate N -pix_fmt P where the values should be substituted in. YUYV will usually be yuyv422.

Resources