diff options
author | Guy Sheffer <guysoft@gmail.com> | 2022-07-11 13:14:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 13:14:13 +0300 |
commit | 9c07cd0171b38dd04be12060a7e876c024055aed (patch) | |
tree | bb6b9793d94d69910a60e0db055717d8d13860d0 | |
parent | 6cb38c20755f9d1dc3cff493545b88738fc8e41d (diff) | |
parent | c8045f46959aefe27e43a2ac6a46ad32b8fefec2 (diff) |
Merge pull request #784 from chudsaviet/feature/hls-v4l2m2m
HLS V4L2 M2M encoder
-rw-r--r-- | src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service | 6 | ||||
-rwxr-xr-x | src/modules/octopi/start_chroot_script | 41 |
2 files changed, 35 insertions, 12 deletions
diff --git a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service index 2b15d8d..3a1f463 100644 --- a/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service +++ b/src/modules/octopi/filesystem/root/etc/systemd/system/ffmpeg_hls.service @@ -18,7 +18,7 @@ ExecStartPre=/bin/chown -R webcam:webcam /run/webcam ExecStartPre=/bin/chmod -R 0755 /run/webcam ExecStart=/usr/bin/sudo -u webcam \ - /usr/bin/ffmpeg \ + /opt/ffmpeg-hls/ffmpeg \ \ -framerate 30 -video_size 640x480 \ -i /dev/video0 \ @@ -28,7 +28,7 @@ ExecStart=/usr/bin/sudo -u webcam \ -f image2 -r 1 -update 1 -atomic_writing 1 \ /run/webcam/jpeg/frame.jpg \ \ - -c:v h264_omx -profile:v high \ + -c:v h264_v4l2m2m -level:v 4.0 \ -b:v 1264k -flags +cgop \ -g 30 -keyint_min 30 \ \ @@ -40,7 +40,7 @@ ExecStart=/usr/bin/sudo -u webcam \ \ -vf scale=-1:240 \ \ - -c:v h264_omx -profile:v high \ + -c:v h264_v4l2m2m -level:v 4.0 \ -b:v 240k -flags +cgop \ -g 30 -keyint_min 30 \ \ diff --git a/src/modules/octopi/start_chroot_script b/src/modules/octopi/start_chroot_script index 7c3b03f..91e08e9 100755 --- a/src/modules/octopi/start_chroot_script +++ b/src/modules/octopi/start_chroot_script @@ -11,7 +11,7 @@ export LC_ALL=C source /common.sh -if [ -n "$OCTOPI_APTMIRROR" ]; +if [ -n "$OCTOPI_APTMIRROR" ]; then echo "Switching apt mirror in /etc/apt/sources.list to $OCTOPI_APTMIRROR" cp /etc/apt/sources.list /etc/apt/sources.list.backup @@ -19,6 +19,8 @@ then fi WEBCAM_USER=webcam +FFMPEG_HLS_COMMIT=c6fdbe26ef30fff817581e5ed6e078d96111248a +FFMPEG_HLS_DIR=/opt/ffmpeg-hls ### Script #### @@ -66,7 +68,7 @@ pushd /home/"${BASE_USER}" apt-get -y --force-yes install libjpeg8-dev fi fi - + apt-get -y --force-yes --no-install-recommends install imagemagick ffmpeg libv4l-dev wget $OCTOPI_MJPGSTREAMER_ARCHIVE -O mjpg-streamer.zip @@ -120,11 +122,32 @@ EOT # FFMPEG HLS if [ "$OCTOPI_INCLUDE_FFMPEG_HLS" == "yes" ] then - apt-get install -y --force-yes --no-install-recommends ffmpeg nginx + apt-get install -y --force-yes --no-install-recommends nginx + + FFMPEG_BUILD_DIR=$(mktemp -d) + pushd ${FFMPEG_BUILD_DIR} + FFMPEG_ARCHIVE=ffmpeg.tar.gz + wget https://api.github.com/repos/FFmpeg/FFmpeg/tarball/${FFMPEG_COMMIT} -O ${FFMPEG_ARCHIVE} + tar xvzf ${FFMPEG_ARCHIVE} + cd FFmpeg* + ./configure \ + --disable-doc \ + --disable-htmlpages \ + --disable-manpages \ + --disable-podpages \ + --disable-txtpages \ + --disable-ffplay \ + --disable-ffprobe + make -j$(nproc) + mkdir -p ${FFMPEG_HLS_DIR} + cp ffmpeg ${FFMPEG_HLS_DIR} + popd + rm -r ${FFMPEG_BUILD_DIR} + useradd ${WEBCAM_USER} usermod -aG video ${WEBCAM_USER} fi - + #CuraEngine if [ "$OCTOPI_INCLUDE_CURAENGINE" == "yes" ] then @@ -151,7 +174,7 @@ EOT # fetch current yq build and install to /usr/local/bin wget -O yq $OCTOPI_YQ_DOWNLOAD && chmod +x yq && mv yq /usr/local/bin - + popd #Make sure user pi / ${BASE_USER} has access to serial ports @@ -197,13 +220,13 @@ do done for ip in $(hostname -I); -do +do echo " http://$ip" done echo echo "https is also available, with a self-signed certificate." -echo +echo echo "------------------------------------------------------------" echo EOT @@ -276,7 +299,7 @@ systemctl_if_exists enable streamer_select.service if [ "$OCTOPI_INCLUDE_MJPGSTREAMER" == "yes" ] then systemctl_if_exists enable webcamd.service -### use legacy camera stack on bullseye for now +### use legacy camera stack on bullseye for now if grep "camera_auto_detect=1" /boot/config.txt then sed -i "s/camera_auto_detect=1/camera_auto_detect=0/g" /boot/config.txt @@ -304,7 +327,7 @@ apt-get -y install avrdude apt-get clean apt-get autoremove -y -if [ -n "$OCTOPI_APTMIRROR" ]; +if [ -n "$OCTOPI_APTMIRROR" ]; then echo "Reverting /etc/apt/sources.list" mv /etc/apt/sources.list.backup /etc/apt/sources.list |