LINUX.ORG.RU

Видеозахват v4l2, Gstreamer и ошибка после просыпания

 , ,


0

1

Добого времени суток.
Ноут с gentoo на борту используется для записи видео с аналогового источника (захват через тюнер saa7134), звук - со встроенного микрофона.
Скрипт, который запускает захват видео:

#!/usr/bin/env bash

filename=$(date +"%F_%H-%M-%S")
VIDEO_DEVICE="/dev/video0"
VIDEO_CAPABILITIES="video/x-raw, format=UYVY, interlace-mode=interleaved, framerate=25/1, width=720, height=576"
TV_NORM="PAL"
AUDIO_DEVICE="hw:0"
AUDIO_CAPABILITIES="audio/x-raw, rate=44100, channels=2"
ENCODE_VIDEO_CODEC="mpeg2video"
ENCODE_VIDEO_OPTIONS="-qscale:v 2 -aspect 4:3 -flags +ilme+ildct -top 1"
ENCODE_AUDIO_CODEC="aac"
AUDIO_FILTER=""
VIDEO_FILTER=""
ENCODE_AUDIO_OPTIONS="-ac 1"
ENCODE_MUXER_FORMAT="mpegts"
ENCODE_MUXER_OPTIONS=""

v4l2-ctl --list-inputs
v4l2-ctl --set-input=2
v4l2-ctl --device="$VIDEO_DEVICE" --get-fmt-video

ffmpeg \
    -i <(
        gst-launch-1.0 -q \
            v4l2src device="$VIDEO_DEVICE" do-timestamp=true norm="$TV_NORM" pixel-aspect-ratio=1 \
                ! $VIDEO_CAPABILITIES \
                ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
                ! mux. \
            alsasrc device="$AUDIO_DEVICE" do-timestamp=true \
                ! $AUDIO_CAPABILITIES \
                ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
                ! mux. \
            matroskamux name=mux \
                ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 \
                ! fdsink fd=1
    ) \
		-c:v $ENCODE_VIDEO_CODEC $ENCODE_VIDEO_OPTIONS \
		-c:a $ENCODE_AUDIO_CODEC $ENCODE_AUDIO_OPTIONS \
		-f $ENCODE_MUXER_FORMAT $ENCODE_MUXER_OPTIONS \
		-map 0:v \
		-map 0:a \
		/home/john/Video/$filename.ts

После очередного выхода из спящего режима видеозахват работать перестал.
Сам тюнер работает - «ffplay -i /dev/video0» картинку показывает. Скипт ругается на 24 строку - gst-launch-1.0 Bus error.
$ ./svideo-mpeg2.sh
ioctl: VIDIOC_ENUMINPUT
        Input       : 0
        Name        : Television
        Type        : 0x00000001 (Tuner)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000000 (ok)
        Capabilities: 0x00000004 (SDTV standards)

        Input       : 1
        Name        : Composite1
        Type        : 0x00000002 (Camera)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000000 (ok)
        Capabilities: 0x00000004 (SDTV standards)

        Input       : 2
        Name        : S-Video
        Type        : 0x00000002 (Camera)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000102 (no signal, no hsync lock)
        Capabilities: 0x00000004 (SDTV standards)
Video input set to 2 (S-Video: Camera, no signal, no hsync lock)
Format Video Capture:
        Width/Height      : 720/576
        Pixel Format      : 'UYVY' (UYVY 4:2:2)
        Field             : Interlaced
        Bytes per Line    : 1440
        Size Image        : 829440
        Colorspace        : SMPTE 170M
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Limited Range)
        Flags             : 
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.0 (Gentoo 9.3.0-r2 p4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.3.1/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-march=core2 -O2 -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-version3 --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libtls --disable-libxml2 --disable-lzma --enable-network --disable-opencl --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --disable-vaapi --disable-vdpau --disable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --enable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --disable-libv4l2 --enable-libpulse --disable-libdrm --disable-libjack --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --enable-librsvg --disable-ffnvcodec --enable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libtesseract --disable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-libaom --disable-libopenh264 --disable-librav1e --disable-libsnappy --enable-libtheora --disable-libtwolame --disable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-sse4 --disable-sse42 --disable-xop --cpu=core2 --disable-doc --disable-htmlpages --enable-manpages
  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
./svideo-mpeg2.sh: line 24:  6313 Bus error               gst-launch-1.0 -q v4l2src device="$VIDEO_DEVICE" do-timestamp=true norm="$TV_NORM" pixel-aspect-ratio=1 ! $VIDEO_CAPABILITIES ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! mux. alsasrc device="$AUDIO_DEVICE" do-timestamp=true ! $AUDIO_CAPABILITIES ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! mux. matroskamux name=mux ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! fdsink fd=1
/dev/fd/63: Invalid data found when processing input

Запуск gst-launch-1.0 без аргументов, выдаёт ту же ошибку:
$ gst-launch-1.0
Bus error
$

Гуглил-гуглил, но так и не нашёл ничего проясняющего. Каюсь, совершил неодобримое - запустил скрипт от рута. Запись пошла:
# ./svideo-mpeg2.sh 
ioctl: VIDIOC_ENUMINPUT
        Input       : 0
        Name        : Television
        Type        : 0x00000001 (Tuner)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000000 (ok)
        Capabilities: 0x00000004 (SDTV standards)

        Input       : 1
        Name        : Composite1
        Type        : 0x00000002 (Camera)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000000 (ok)
        Capabilities: 0x00000004 (SDTV standards)

        Input       : 2
        Name        : S-Video
        Type        : 0x00000002 (Camera)
        Audioset    : 0x00000000
        Tuner       : 0x00000000
        Standard    : 0x0000000000FFBFFF (PAL-B/B1/G/H/I/D/D1/K/M/N/Nc/60 NTSC-M/M-JP/M-KR SECAM-B/D/G/H/K/K1/L/Lc)
        Status      : 0x00000102 (no signal, no hsync lock)
        Capabilities: 0x00000004 (SDTV standards)
Video input set to 2 (S-Video: Camera, no signal, no hsync lock)
Format Video Capture:
        Width/Height      : 720/576
        Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)
        Field             : Interlaced
        Bytes per Line    : 2160
        Size Image        : 1244160
        Colorspace        : SMPTE 170M
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             : 
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.0 (Gentoo 9.3.0-r2 p4)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.3.1/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-march=core2 -O2 -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-version3 --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libtls --disable-libxml2 --disable-lzma --enable-network --disable-opencl --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --disable-vaapi --disable-vdpau --disable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --enable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --disable-libv4l2 --enable-libpulse --disable-libdrm --disable-libjack --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --enable-librsvg --disable-ffnvcodec --enable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libtesseract --disable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-libaom --disable-libopenh264 --disable-librav1e --disable-libsnappy --enable-libtheora --disable-libtwolame --disable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-sse4 --disable-sse42 --disable-xop --cpu=core2 --disable-doc --disable-htmlpages --enable-manpages
  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
XDG_RUNTIME_DIR (/run/user/1000) is not owned by us (uid 0), but by uid 1000! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, matroska,webm, from '/dev/fd/63':
  Metadata:
    encoder         : GStreamer matroskamux version 1.16.2
    creation_time   : 2021-01-19T19:12:57.000000Z
  Duration: N/A, start: 0.000000, bitrate: 1411 kb/s
    Stream #0:0(eng): Video: rawvideo (UYVY / 0x59565955), uyvy422(tv, smpte170m/smpte170m/bt709), 720x576, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng): Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      title           : Audio
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to '/home/john/Video/2021-01-19_21-12-56.ts':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0(eng): Video: mpeg2video (4:2:2), yuv422p(top first), 720x576 [SAR 16:15 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      title           : Video
      encoder         : Lavc58.91.100 mpeg2video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(eng): Audio: aac (LC), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      title           : Audio
      encoder         : Lavc58.91.100 aac
frame=   56 fps= 23 q=2.0 Lsize=     119kB time=00:00:02.43 bitrate= 401.1kbits/s speed=1.01x    
video:79kB audio:21kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 19.197416%
[aac @ 0x55cb1e5e6600] Qavg: 122.734


Такое впечатление, что что-то нарушилось с правами для обычного пользователя.
Прошу помощи.

Проблема решилась удалением папок ~/.cache и ~/.dbus

sspphheerraa ()
Для того чтобы оставить комментарий войдите или зарегистрируйтесь.