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.
Related
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!
So, I made 2 scripts that convert CCTV footage in mp4 videos. One of them is just a -vcodec copy and creates a mp4 with the same size of the footage (huge, btw) and my other alternative was tweak with some parameters and figure out what was the best I could do without sacrifice too much quality and make it "fast".
Then I come up with c:v libx264 -crf 30 -preset veryfast -filter:v fps=fps=20 which took something like 2 secs in my machine to run an average 6MB file and transform into a 600kB file.
Happy with the results I decided to put it on AWS lambda (to avoid bottlenecks), and then people started to complain about missing files, so I increase the timeout and the memory to 380MB. And even after that, I am still getting a few lambda errors...
Anyway, the lambda is going to cost me too much compared to just store the file without compression, there is another way to decrease size without sacrificing time?
[UPDATE]
I crunch some numbers and even tho using lambda is not what I expected, I am still saving a lot of cash monthly by reducing the file size 10x times.
As asked, this is the logs for the ffmpeg.
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10 (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 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-liblensfun --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-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzvbi --enable-lv2 --enable-avfilter --enable-avresample --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 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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, dhav, from 'ch1_principal_28122020030156_28122020030600.dav':
Duration: N/A, start: 1609124514.000000, bitrate: N/A
Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt709), 960x480, 30 fps, 30 tbr, 1k tbn
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x556ce99e7100] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x556ce99e7100] profile High, level 3.1, 4:2:0, 8-bit
[libx264 # 0x556ce99e7100] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 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=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=20 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=30.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '_test1.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 960x480, q=-1--1, 20 fps, 10240 tbn, 20 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[dhav # 0x556ce99b8400] Packet corrupt (stream = 0, dts = NOPTS).te= 127.1kbits/s speed=10.9x
ch1_principal_28122020030156_28122020030600.dav: corrupt input packet in stream 0
frame= 805 fps=226 q=-1.0 Lsize= 682kB time=00:00:40.10 bitrate= 139.4kbits/s speed=11.2x
video:672kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.521397%
[libx264 # 0x556ce99e7100] frame I:4 Avg QP:27.76 size: 31382
[libx264 # 0x556ce99e7100] frame P:205 Avg QP:30.62 size: 2110
[libx264 # 0x556ce99e7100] frame B:596 Avg QP:33.91 size: 217
[libx264 # 0x556ce99e7100] consecutive B-frames: 1.1% 0.2% 0.7% 97.9%
[libx264 # 0x556ce99e7100] mb I I16..4: 8.3% 41.1% 50.6%
[libx264 # 0x556ce99e7100] mb P I16..4: 0.9% 3.0% 0.4% P16..4: 16.9% 4.1% 1.3% 0.0% 0.0% skip:73.4%
[libx264 # 0x556ce99e7100] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 1.4% 0.4% 0.0% direct: 0.9% skip:96.9% L0:42.0% L1:48.0% BI: 9.9%
[libx264 # 0x556ce99e7100] 8x8 transform intra:63.1% inter:40.6%
[libx264 # 0x556ce99e7100] coded y,uvDC,uvAC intra: 55.6% 40.9% 5.0% inter: 1.4% 2.1% 0.0%
[libx264 # 0x556ce99e7100] i16 v,h,dc,p: 27% 28% 24% 21%
[libx264 # 0x556ce99e7100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 16% 26% 6% 6% 6% 7% 11% 7%
[libx264 # 0x556ce99e7100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 17% 15% 9% 6% 6% 7% 13% 6%
[libx264 # 0x556ce99e7100] i8c dc,h,v,p: 63% 16% 16% 5%
[libx264 # 0x556ce99e7100] Weighted P-Frames: Y:8.8% UV:1.0%
[libx264 # 0x556ce99e7100] kb/s:136.66
libx264
You have to choose a balance between encoding speed and encoding efficiency.
Choose the slowest -preset you have patience for.
Choose the highest -crf value that provides an acceptable quality.
See FFmpeg Wiki: H.264 for more info.
libx265
If libx264 does not make a small enough file try libx265, but it takes longer to encode.
See FFmpeg Wiki: HEVC/H.265 for more info.
Hardware accelerated encoder
If you have the proper hardware, then you can use NVENC, QuickSync, or some other implementation.
Encoding will be fast, but it will not match the quality per bit provided by libx264 or libx265.
See FFmpeg Wiki: Hardware for more info.
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.
I working on a programmatic sketch to cut, crop and fade in/out audio from a single input video file.
Everything works pretty well except for the audio fade in fade out.
Everything work fine if I set a fade in and fade out time of 1 (or more) seconds. Here's my command:
ffmpeg -ss 0:1:11.10 -i INPUT_FILE.mp4 -filter:a afade=t=in:st=0:d=1.0,afade=t=out:st=55.867:d=1.0 -filter:v crop=720:720:138:0 -to 0:0:56.86 OUTPUT_FILE.mp4
Fade filter stop working if I set time less than 1 secs (say 100ms like the following example).
ffmpeg -ss 0:1:11.10 -i INPUT_FILE.mp4 -filter:a afade=t=in:st=0:d=0.1,afade=t=out:st=56.767:d=0.1 -filter:v crop=720:720:138:0 -to 0:0:56.86 OUTPUT_FILE.mov
I mean, ffmpeg is not complaining about any error but the output video file simply has no fade in or fade out.
Why?
What I'm doing wrong?
Thank you so much for your support
Edit 22/07/2020:
here's the output from the second command:
ffmpeg -ss 0:1:11.10 -i 2020-07-20_00-13-35.mkv -filter:a afade=t=in:st=0:d=0.1,afade=t=out:st=56.767:d=0.1 -filter:v crop=720:720:138:0 -to 0:0:56.86 ./_selections/2020-07-20_00-13-35_R1_crop2_w_fadein_fadeout_0:1:11.10.mov
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
WARNING: library configuration mismatch
avcodec 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 --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
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
Input #0, matroska,webm, from '2020-07-20_00-13-35.mkv':
Metadata:
ENCODER : Lavf57.83.100
Duration: 00:03:19.23, start: 0.000000, bitrate: 2661 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1440x900, 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
Metadata:
DURATION : 00:03:19.233000000
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
Metadata:
title : audio desktop
DURATION : 00:03:19.065000000
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x564dad2f9680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x564dad2f9680] profile High, level 3.1
[libx264 # 0x564dad2f9680] 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=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=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, mov, to './_selections/2020-07-20_00-13-35_R1_crop2_w_fadein_fadeout_0:1:11.10.mov':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 720x720, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
DURATION : 00:03:19.233000000
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
title : audio desktop
DURATION : 00:03:19.065000000
encoder : Lavc57.107.100 aac
frame= 1706 fps=140 q=-1.0 Lsize= 2685kB time=00:00:56.86 bitrate= 386.7kbits/s speed=4.67x
video:1681kB audio:942kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.351145%
[libx264 # 0x564dad2f9680] frame I:7 Avg QP:15.76 size: 60653
[libx264 # 0x564dad2f9680] frame P:448 Avg QP:23.13 size: 1372
[libx264 # 0x564dad2f9680] frame B:1251 Avg QP:31.17 size: 545
[libx264 # 0x564dad2f9680] consecutive B-frames: 1.3% 2.3% 1.4% 95.0%
[libx264 # 0x564dad2f9680] mb I I16..4: 29.2% 37.7% 33.1%
[libx264 # 0x564dad2f9680] mb P I16..4: 0.1% 0.4% 0.5% P16..4: 2.1% 0.2% 0.2% 0.0% 0.0% skip:96.4%
[libx264 # 0x564dad2f9680] mb B I16..4: 0.0% 0.3% 0.2% B16..8: 1.5% 0.1% 0.1% direct: 0.0% skip:97.8% L0:51.7% L1:46.3% BI: 2.0%
[libx264 # 0x564dad2f9680] 8x8 transform intra:43.2% inter:27.7%
[libx264 # 0x564dad2f9680] coded y,uvDC,uvAC intra: 35.4% 42.2% 40.1% inter: 0.3% 0.5% 0.3%
[libx264 # 0x564dad2f9680] i16 v,h,dc,p: 61% 37% 2% 0%
[libx264 # 0x564dad2f9680] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 7% 59% 2% 0% 0% 0% 1% 1%
[libx264 # 0x564dad2f9680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 17% 25% 10% 4% 5% 5% 7% 7%
[libx264 # 0x564dad2f9680] i8c dc,h,v,p: 66% 19% 7% 7%
[libx264 # 0x564dad2f9680] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x564dad2f9680] ref P L0: 65.1% 15.3% 13.6% 5.9%
[libx264 # 0x564dad2f9680] ref B L0: 68.1% 27.1% 4.8%
[libx264 # 0x564dad2f9680] ref B L1: 95.3% 4.7%
[libx264 # 0x564dad2f9680] kb/s:242.09
[aac # 0x564dad2f25a0] Qavg: 606.451
I have five *.jpeg image files: m01.jpeg to m05.jpeg.
I'd like to make a video of a sequence of these five images and upload it to Prezi to use in a presentation.
FFMPEG seems to be the tool for the job here. I am generating a video using the following command:
ffmpeg -r 2 -i m%02d.jpeg -pix_fmt yuvj420p myvideo.mp4
This generates a video that I can play fine locally. Unfortunately, when I try to upload the video to Prezi, I always get the following error...
"Technical details: id: 2110 the reason is: Event [Event type="stateChange" bubbles=false cancelable=false eventPhase=2]"
...which isn't particularly informative.
If I upload a sample MP4 from the web to Prezi, it works fine.
My question: Does anybody know what I need to give FFMPEG as parameters here so that it will generate a Prezi-compatible video from these images?
EDIT: As requested, here's the complete console output for FFMPEG. Unfortunately there are no glaring warnings or errors that I can see.
sam#x220sm:~/tmp$ ffmpeg -r 2 -i m%02d.jpeg -pix_fmt yuvj420p myvideo.mp4
ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311
configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --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-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --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-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mjpeg # 0xd8e620] Changeing bps to 8
Input #0, image2, from 'm%02d.jpeg':
Duration: 00:00:00.20, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 800x600 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 # 0xd910c0] using SAR=1/1
[libx264 # 0xd910c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0xd910c0] profile High, level 3.1
[libx264 # 0xd910c0] 264 - core 148 r2643 5c65704 - 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=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=2 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 'myvideo.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p(pc), 800x600 [SAR 1:1 DAR 4:3], q=-1--1, 2 fps, 16384 tbn, 2 tbc
Metadata:
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 5 fps=0.0 q=-1.0 Lsize= 1170kB time=00:00:01.50 bitrate=6390.8kbits/s
video:1169kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.073660%
[libx264 # 0xd910c0] frame I:1 Avg QP:25.54 size:289842
[libx264 # 0xd910c0] frame P:4 Avg QP:20.54 size:226716
[libx264 # 0xd910c0] mb I I16..4: 0.0% 0.2% 99.8%
[libx264 # 0xd910c0] mb P I16..4: 16.8% 23.8% 59.4% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip: 0.0%
[libx264 # 0xd910c0] 8x8 transform intra:19.1% inter:0.0%
[libx264 # 0xd910c0] coded y,uvDC,uvAC intra: 84.5% 85.6% 79.2% inter: 50.0% 100.0% 100.0%
[libx264 # 0xd910c0] i16 v,h,dc,p: 95% 1% 4% 0%
[libx264 # 0xd910c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 6% 8% 38% 7% 7% 6% 11% 9% 9%
[libx264 # 0xd910c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 8% 9% 23% 9% 9% 8% 14% 9% 11%
[libx264 # 0xd910c0] i8c dc,h,v,p: 72% 10% 5% 13%
[libx264 # 0xd910c0] Weighted P-Frames: Y:50.0% UV:50.0%
[libx264 # 0xd910c0] ref P L0: 50.0% 50.0%
[libx264 # 0xd910c0] kb/s:3829.46
Make sure to use a "standard" frame rate and a compatible chroma subsampling scheme:
ffmpeg -framerate 2 -i m%02d.jpeg -r 25 -pix_fmt yuv420p -profile:v baseline -movflags +faststart output.mp4
Options:
-framerate 2 Set input frame rate to 2. Note that the image demuxer uses -framerate instead of -r.
-r 25 Set the output frame rate to 25.
-pix_fmt yuv420p Ensures 4:2:0 chroma subsampling.
-profile:v baseline Use Baseline H.264 profile. Possibly not needed for Prezi.
-movflags +faststart For playback via progressive download–allows video to begin playback before file is completely downloaded. Possibly not needed for Prezi, but does not harm anything to include it.