Registrazione da scheda acquisizione video

Discussioni inerenti al multimedia e ai giochi in ambiente Linux
Rispondi
gaglioffo
Arciere
Messaggi: 305
Iscritto il: 11 maggio 2016, 21:06

Registrazione da scheda acquisizione video

Messaggio da gaglioffo » 16 novembre 2018, 11:01

ciao,
c'è qualcuno che ha esperienza con schede di acquisizione video? sto provando a digitalizzare una VHS con questa scheda:

Codice: Seleziona tutto

04:07.0 Multimedia controller: Philips Semiconductors SAA7134/SAA7135HL Video Broadcast Decoder (rev 01)
La riproduzione funziona bene, sia con "tvtime" che con "mpv av://v4l2:/dev/video0", ma se provo a registrare con ffmpeg viene sempre fuori un file video scattoso, con tutte le opzioni che ho provato. Per esempio queste:

Codice: Seleziona tutto

$ ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv
ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.1.1 (GCC) 20180531
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[video4linux2,v4l2 @ 0x16295c0] The driver does not permit changing the time per frame
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1231.455790, bitrate: 92160 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 92160 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x162dd00] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0x162dd00] profile High, level 3.0
[libx264 @ 0x162dd00] 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=3 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, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 640x480, q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
^Came=  115 fps= 22 q=28.0 size=       1kB time=00:00:02.60 bitrate=   2.2kbits/s speed=0.505x  

Codice: Seleziona tutto

$ ffmpeg -i /dev/video0 -f avi -r 25 -vcodec libxvid -vtag XVID -vf scale=720:576 -maxrate 1800k -b 1500k -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -bf 2 -trellis 1 -flags +aic -cmp 2 -subcmp 2 -g 300 out.avi
ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.1.1 (GCC) 20180531
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1286.412822, bitrate: 92160 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 92160 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Please use -b:a or -b:v, -b is ambiguous
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (libxvid))
Press [q] to stop, [?] for help
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0: Video: mpeg4 (libxvid) (XVID / 0x44495658), yuv420p, 720x576, q=3-5, 1500 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.18.100 libxvid
frame=  134 fps= 15 q=7.0 Lsize=    1133kB time=00:00:08.28 bitrate=1121.4kbits/s speed=0.946x    
video:1123kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.929892%
Exiting normally, received signal 2.

Codice: Seleziona tutto

$ ffmpeg -i /dev/video0 out.avi
ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.1.1 (GCC) 20180531
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1330.370444, bitrate: 92160 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 92160 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.18.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=  198 fps= 25 q=31.0 Lsize=     705kB time=00:00:07.92 bitrate= 729.7kbits/s speed=   1x    
video:695kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.482288%
Exiting normally, received signal 2.
(con quest'ultima opzione il video non è scattoso ma la qualità è pessima, troppi artefatti).

Ho visto che lo "speed" di ffmpeg è sempre sotto l'1%, forse la mia vecchia CPU (Dual core 1,8GHz del 2006) non ce la fa?

Ho provato anche ad usare mencoder come indicato in questa guida, ma da errore:

Codice: Seleziona tutto

$ mencoder -tv driver=v4l2:device=/dev/video0:fps=30000/1001:chanlist=us-bcast:\ audiorate=32000:alsa:adevice=hw.0:input=0:amode=1:normid=4:width=576:height=432 \ -ovc x264 -x264encopts threads=2:bitrate=500:bframes=2:subq=1:me=1:frameref=4:8x8dct \ -oac mp3lame -lameopts cbr:br=64 -endpos $TIM -o pippo.avi
mencoder: /usr/lib/libssh.so.4: no version information available (required by /usr/lib/libavformat.so.58)
MEncoder SVN-r38101 (C) 2000-2018 MPlayer Team
Option tv: Unknown suboption  audiorate
Error parsing option on the command line: -tv

Exiting... (error parsing command line)

Codice: Seleziona tutto

$ mencoder -tv driver=v4l2:input=2:width=720:height=576:device=/dev/video0:fps=25:amode=2:norm=PAL-I tv:// -oac lavc -ovc lavc acodec=ac3:vcodec=mpeg4 -o test.avi
mencoder: /usr/lib/libssh.so.4: no version information available (required by /usr/lib/libavformat.so.58)
MEncoder SVN-r38101 (C) 2000-2018 MPlayer Team
success: format: 9  data: 0x0 - 0x0
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
Selected device: AOPEN VA1000 POWER
 Tuner cap: STEREO LANG1 LANG2
 Tuner rxs: MONO
 Capabilities:  video capture  video overlay  VBI capture device  tuner  read/write  streaming
 supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR; 4 = PAL; 5 = PAL-BG; 6 = PAL-H; 7 = PAL-I; 8 = PAL-DK; 9 = PAL-M; 10 = PAL-N; 11 = PAL-Nc; 12 = PAL-60; 13 = SECAM; 14 = SECAM-B; 15 = SECAM-G; 16 = SECAM-H; 17 = SECAM-DK; 18 = SECAM-L; 19 = SECAM-Lc;
 inputs: 0 = S-Video; 1 = Composite1; 2 = Television;
 Current input: 2
 Current format: YVU420
v4l2: current audio mode is : LANG1
Unable to open '/dev/dsp': No such file or directory
Unable to open '/dev/dsp': No such file or directory
Unable to open '/dev/dsp': No such file or directory
v4l2: 0 frames successfully processed, 0 frames dropped.
============ Sorry, this file format is not recognized/supported =============
=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===
Cannot open demuxer.

Exiting...

gaglioffo
Arciere
Messaggi: 305
Iscritto il: 11 maggio 2016, 21:06

Re: Registrazione da scheda acquisizione video

Messaggio da gaglioffo » 16 novembre 2018, 14:44

ho trovato un compromesso decente usando queste opzioni:

Codice: Seleziona tutto

ffmpeg -i /dev/video0 -f alsa -ar 44100 -i hw:0 -f avi  -vsync 1 -async 1 -r 25 -vcodec libxvid -vtag XVID -vf scale=640:480 -maxrate 1800k -b 1500k -qmin 3 -qmax 5 -bufsize 4096 out3.avi
Se avete altri suggerimenti sono ben accetti...

Rispondi