loop reverse
ffmpeg -i c-stab.mp4 -vf reverse c-reverse.mp4
ffmpeg -i c-stab.mp4 -vf tpad=stop_mode=clone:stop_duration=2 c-stab-pad.mp4
ffmpeg -i c-reverse.mp4 -vf tpad=stop_mode=clone:stop_duration=1 c-reverse-pad.mp4
ffmpeg -i c-stab-pad.mp4 -i c-reverse-pad.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1 [v]" -map "[v]" c-loop.mp4
ffmpeg -i c-stab-pad.mp4 -i c-reverse.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1 [v]" -map "[v]" c-loop2.mp4
burn in subtitles
ffmpeg -i "input.m4v" -vf subtitles="sub.srt" output.mp4
nope(missing =) extracted subtitles instead
ffmpeg -i "input.m4v" -vf subtitles "sub.srt" output.mp4
MJpeg from mjpeg streamer to youtube
Lousy camera that can't do many fps, camera locks up and needs a dis-connect-reconnect to get it restarted, so limit it to 1 fps, seems to limit it to 2-4fps, but close enough.
mjpg_streamer -i 'input_uvc.so -f 1' -o output_http.so
verify
ffplay "http://192.168.0.155:8080/?action=stream"
OBS capturing the ffplay and sending to youtube would stop every 0.5 - 9 hours.
Laptop that runs the camera can't encode video, the camera says it can h264 it but I didn't trust it since I got mjpeg streamer to work, so run ffmpeg from another computer to do the transcode.
ffmpeg -re -f mjpeg -use_wallclock_as_timestamps 1 -i "http://192.168.0.155:8080/?action=stream" -f lavfi -i anullsrc -vf setpts=PTS-STARTPTS -vsync 0 -c:v libx264 -c:a aac -ar 44100 -ac 2 -f flv "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx-xxxx"
key thing seem to be -use_wallclock_as_timestamps 1
and -vf setpts=PTS-STARTPTS -vsync 0
C:\Users\Stephen>ffmpeg -re -f mjpeg -use_wallclock_as_timestamps 1 -i "http://192.168.0.155:8080/?action=stream" -f lavfi -i anullsrc -vf setpts=PTS-STARTPTS -vsync 0 -c:v libx264 -c:a aac -ar 44100 -ac 2 -f flv "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx-xxxx"
ffmpeg version 2020-12-06-git-2aab42bc40-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 62.100 / 56. 62.100
libavcodec 58.115.100 / 58.115.100
libavformat 58. 65.100 / 58. 65.100
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 92.100 / 7. 92.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, mjpeg, from 'http://192.168.0.155:8080/?action=stream':
Duration: N/A, start: 1626537599.499261, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x480, 25 tbr, 1200k tbn, 25 tbc
Input #1, lavfi, from 'anullsrc':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #1:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_u8 (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000232a0f6ce00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000232a0f6ce00] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 00000232a0f6ce00] 264 - core 161 r3027 4121277 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=15 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=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://a.rtmp.youtube.com/live2/
xxxx
-
xxxx
-
xxxx
-
xxxx
-
xxxx
':
Metadata:
encoder : Lavf58.65.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt470bg/unknown/unknown, progressive), 640x480, q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc58.115.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) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.115.100 aac
[libx264 @ 00000232a0f6ce00] non-strictly-monotonic PTS.00 bitrate=N/A speed= 0x
[mjpeg @ 00000232a0f0f740] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[libx264 @ 00000232a0f6ce00] non-strictly-monotonic PTS0.02 bitrate=41067.1kbits/s speed=0.00137x
frame= 1192 fps=3.8 q=22.0 size= 8226kB time=00:04:56.19 bitrate= 227.5kbits/s speed=0.948x
SomeTimes this error:
[mjpeg @ 000001f75ef7f740] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
av_interleaved_write_frame(): Unknown errortime=00:32:00.44 bitrate= 229.2kbits/s speed=0.987x
Last message repeated 1 times
[flv @ 000001f75efe1b80] Failed to update header with correct duration.
[flv @ 000001f75efe1b80] Failed to update header with correct filesize.
Error writing trailer of rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx-xxxx: Error number -10053 occurred
flags to try
-fflags nobuffer and -rtsp_transport tcp
seems to be a bug:
https://trac.ffmpeg.org/ticket/7547
Version 3.4.8-0ubuntu0.2 seems to not have the issue.
It seems that a "Intel(R) Atom(TM) CPU Z520 @ 1.33GHz" can trancode at about
frame= 5855 fps=6.4 q=-1.0 Lsize= 11528kB time=00:15:03.96 bitrate= 104.5kbits/s speed=0.995x
So maybe I should have just used that instead.