åº
é ä¿¡ã¬ãå¢ãªããããã¯ãã ã
è¤æ°ã®é³ã½ã¼ã¹ãæ··ããã(主ã«BGMã¨ãã¤ã¯ããããã¯ã²ã¼ã ãµã¦ã³ãã¨ãã¤ã¯)ãè¤æ°ã®åç»ãæ··ããã(è¦ã¯ã¯ã¤ããåºããã)ã¨æã£ã¦ããã¢ããªå´ã§å¯¾å¿ãã¦ãããã©ããã«ãããå·¦å³ãããã¨ã
COVID-19ã®æµè¡ã«ããä»ã¾ã§ãã¾ãé ä¿¡ãwebä¼è°ããããªé話ã«ç¸ããªãã£ã人ããããããã®ã使ãããã«ãªã£ãã ããã ããã«ä¼´ãããã£ã¨åã£ããã¨ããããã¨èãã¦ãã人ãããã¯ãã ã
ã ãããããªãã¨ã©ããã¦ããããµã¼ãå¿ è¦ã«ãªãã Roland VR-1HDãYAMAHA AG03ã®ãããªãããµã¼ã欲ããã ãããããããã¯çµæ§é«ãã (ã¤ãã§ã«è¨ãã¨ãä»ã¯åèã )
䏿¹ãPCã§ã¯ããæ¥å¸¸çã«ã½ããã¦ã§ã¢ãããµã¼ã¨ãããã®ã使ã£ã¦ããã ããã½ããã¦ã§ã¢ãããµã¼ããªããã°ãã²ã¨ã¤ã®ãµã¦ã³ãããã¤ã¹ããé³ãåºããã®ã¯ã²ã¨ã¤ã®ã¢ããªã±ã¼ã·ã§ã³ã ãã ã è¤æ°ã®ã¢ããªã±ã¼ã·ã§ã³ã®é³ãæ··ãã¦åºåãã¦ããã®ã¯ããã¼ãã¦ã§ã¢ã«ãã®æ©è½ãåãã£ã¦ããã®ã§ãªããã°ãã½ããã¦ã§ã¢ãããµã¼ã®ä»äºã ã
æ¬è¨äºã§ã¯ãLinuxãå©ç¨ãã¦ãã®æ©è½ãæ¡å¼µããPCå ã§æ±ãããããã½ã¼ã¹ãããã¯ã¹ãã¦åºåããå¼·åãªã½ããã¦ã§ã¢ãããµã¼ã¨ãã¦å©ç¨ãã話ãããã
ãªãããã®è¨äºã§ã¯å®å ¨ã«Linuxåºæã®æ©è½ãå«ãã 解説ã¨ãªã£ã¦ããã
é³å£°ç·¨
æ¦è¦
Linuxã®ãªã¼ãã£ãªæ©è½ã¯ãç¾å¨ä¸è¬çã«PulseAudioã使ç¨ããã¦ããã
ãPulseAudioã¯é³ãæªããã¨ããè¬é¢¨æ½®ãããããé常ã«ä¾¿å©ã§å¼·åãªãã®ã§ãããããã§ã¯PulseAudioã®ã«ã¼ãã£ã³ã°æ©è½ãæ´»ç¨ããã
ã¾ãPulseAudioç¨èªãçè§£ãã
sink
åºåããã¤ã¹ã®ãã¨ã ãµã¦ã³ãã«ã¼ãã®åºåãã¼ããªã©ãããã«ãªãã
PulseAudio Volume Controlã§ã¯ãåçãã¿ãã§é¸æã§ããé ç®ã«ãªãã é³ãåçãããã¨ããã¨ãã«åè£ã«ãªãã®ãsinkã
source
å ¥åããã¤ã¹ã®ãã¨ã主ã«ãã¤ã¯ã
PulseAudio Volume Controlã§ã¯ãé²é³ãã¿ãã§é¸æã§ããé ç®ã«ãªãã é²é³ã¨ããããããã¢ããªã±ã¼ã·ã§ã³ãé³ãæ¾ãã¨ãã«åè£ã«ãªãã®ãsource
monitor
ãã®sinkããé³´ã£ã¦ããããã¯ã¹æ¸ã¿ã®é³ã®ä»®æ³sourceã Windowsã§ããããã®ã
ç©ççãªsinkã§ããã°ãè¦ã¯ãã®ã¹ãã¼ã«ã¼ããé³´ãå ¨ã¦ã®é³ãã¨ãããã¨ã«ãªãã
sinkã®é³ã§ã¯ããããã©ã種å¥ã¯sourceã§ããã
䏿ºå
ã¾ãã¯ä»®æ³sinkãç¨æããã
ããã§ã¯sinkãç¨æãã¦ããããã©ãããã¯å®éã«sinkã¨ãã¦ä½¿ãããã§ã¯ãªããmonitorãé ä¿¡ã®sourceã«ããããã®ãã®ã§ããã
pacmd load-module module-null-sink sink_name=mixmicPulseAudioã®module-null-sinkã使ç¨ãã¦ããã
sink_nameã¯èå¥åãªã®ã§å¥½ãã«ã¤ãã¦è¯ããããããããããã®ã«ããã»ããè¯ãã
ããã«ãååãåããã¦ãããã
pacmd update-sink-proplist mixmic device.description=mixmicPulseAudio Volume Controlã«åæ ãããããæ··ä¹±ãé¿ããããåãååã«ãã¦ãããã»ããè¯ãã æ¬å½ã¯ä¸å¯§ãªååãã¤ãããã¨ããã ããdescriptionã«ãã¯ã¤ãã¹ãã¼ã¹ãå«ãã ååã¯æå®ã§ããªãã
ããã§å®ç¨ä¸ã¯åé¡ãªãããããã ã¨ãã®ä»®æ³sinkã®monitorã¯ãMonitor of Nullåºåãã¨ãªããé常ã«ãããã¥ããã ç¹ã«ãè¤æ°ã®ä»®æ³sinkã使ãå ´ååºå¥ã§ããªããªã£ã¦ãã¾ãã ããã§ãmonitorã®descriptionã夿´ãã¦ããã
pacmd update-source-proplist mixmic.monitor device.description=Monitor_of_mixmicããã«ãåæsinkãç¨æããã ããã¯ãåæsinkã«é³ãæµããã¨ããè¤æ°ã®sinkããé³ãé³´ãããã«ãªãã
ãããç¨æããã®ã¯ãè¿ããã®ããã§ããã ãããããè¿ãããå¿ è¦ãªããã¤ã¾ãé ä¿¡ãã¦ããé³ãä¸å確èªããå¿ è¦ããªãã®ã§ããã°ããã®åæsinkã¯å¿ è¦ãªãã
ã¾ãã¯
pacmd list-sinks | grep -F "name: "ã¨ãã¦ãsinkã確èªããã
<...>ã®å½¢å¼ã«ãªã£ã¦ãããä¸è§ã«ãã³ã®ä¸ã®å¤ã§åºåã«ä½¿ç¨ãããsinkã®ååã確èªããã
% pacmd list-sinks | grep name:
name: <alsa_output.usb-Native_Instruments_Audio_4_DJ_SN-vwr0bed2-00.analog-stereo-a>
name: <alsa_output.usb-Native_Instruments_Audio_4_DJ_SN-vwr0bed2-00.analog-stereo-b-output>
name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
name: <alsa_output.pci-0000_3b_00.1.hdmi-stereo-extra5>
name: <mixmic>
ããã¦ãåæsinkã«ãå ç¨ã®ä»®æ³sinkã¨å ±ã«åæããã
pacmd load-module module-combine-sink sink_name=combined slaves=alsa_output.pci-0000_00_1f.3.analog-stereo,mixmicããããPulseAudio Volume Control (ã³ãã³ãå pavucontrol)ãèµ·åãããã
æ··ãã¦åºåãã
è¿ãã®ãªã=ã¹ãã¼ã«ã¼ããåçããå¿
è¦ããªããã¤ã¾ãããã¾ã§ãã¤ã¯å
¥åã¨ãã¦æ±ãã°è¯ã鳿ºã¯ä»®æ³sink(å
ç¨ã®ä¾ã§ã¯mixmic)ã«åºåããã
䏿¹ãè¿ãããããã¹ãã¼ã«ã¼ããé³´ã£ã¦ããé³ã確èªããã鳿ºã¯åæsinkã«åºåããã
ãããã¯é³ãé³´ã£ã¦ããç¶æ ã§PulseAudio Volume Controlã®ãåçãã¿ãããsinkãé¸ã¹ã°è¯ãã
ã ããããã ãã§ã¯ãã¤ã¯ã®é³ãå«ããã¨ãã§ããªãã
module-loopbackã使ãã°ãã¤ã¯ã®å
¥åããã¤ã¬ã¯ãã«sinkã«æµããã¨ãã§ããã
ã¾ãã¯pacmd list-sources | grep -F name: | grep -F -v .monitorã¨ãã¦ãªãã¤ã¬ã¯ãããããã¤ã¯å
¥åã確èªãããã
% pacmd list-sources | grep -F name: | grep -v -F .monitor
name: <alsa_input.usb-Native_Instruments_Audio_4_DJ_SN-vwr0bed2-00.analog-stereo-a>
name: <alsa_input.usb-Native_Instruments_Audio_4_DJ_SN-vwr0bed2-00.analog-stereo-b-input>
name: <alsa_input.pci-0000_00_1f.3.analog-stereo>
name: <alsa_input.usb-046d_0825_D457DB60-02.mono-fallback>
ç®çã®ãã¤ã¯ãloopbackã®sourceã«è¨è¼ãããããã¦ãsinkã«æµãè¾¼ã¿ããsinkãæå®ããã
ãã¤ã¯ã¯è¿ãã¯ãããªãã ãããããä»®æ³sinkã«ãªãã ããã
pacmd load-module module-loopback source=alsa_input.usb-046d_0825_D457DB60-02.analog-mono sink=mixmicãã¤ã¯ã鏿ãã
ããã¯ç°¡åãªè©±ã§ãPulseAudio Volume Controlã§ãé²é³ãã¿ãããé ä¿¡ã¢ããªã±ã¼ã·ã§ã³ã®sourceãä»®æ³sinkã®monitorã«ããã°è¯ãã
åæsinkã®monitorã§ã¯ãªãã®ã§æ³¨æãããã¨ã
ããªã¥ã¼ã 調æ´
ã¢ããªã±ã¼ã·ã§ã³ããæµããé³é
ã¢ããªã±ã¼ã·ã§ã³å é¨ã®é³é調æ´ãå©ç¨ãããã ãããã¯ãåçãã¿ãããããªã¥ã¼ã ãã³ã³ããã¼ã«ããã
ãã¤ã¯ã®é³é
ãå ¥åè£ ç½®ãã¿ããããã¤ã¯ããã¤ã¹ã®é³éã
é ä¿¡ã¸ã®å ¥åå ¨ä½ã®é³é
ãå ¥åè£ ç½®ãããä»®æ³sinkã®monitorã®é³éã
è¿ãã®é³é
ãåºåè£ ç½®ãããå®éã«åºåãã¦ããã¹ãã¼ã«ã¼ããã¤ã¹ã®é³é
é³ãå²ãã
åã ã§ã¯å²ããã»ã©ã®å ¥åããªãã¦ããæ··ããã¨å²ãã¦ãã¾ããã¨ãããã
ãå ¥åè£ ç½®ãã§ããããã®å ¥åå¤ãä¸ããã ã¾ããåçããåæsinkãä»®æ³sinkã«æµãã¦ããå ´åã¯ããåçããããã®ã¢ããªã±ã¼ã·ã§ã³ã®é³éãä¸ããã
å ¨ä½ã®å ¥åãé大ã«ãªããªãããã«ããä¸ã§ãå ¨ä½ã®ãã©ã³ã¹ãã¨ã£ããããå ¥åè£ ç½®ãã®ä»®æ³sinkã®monitorã®é³éã§èª¿æ´ããã
è£è¶³äºé
combine-source
combine-sinkã¯è¤æ°ã®sinkã¸åºåãåé ãããã®ã§ããããéã«è¤æ°ã®sourceãéç´ããcombine-sourceã¯æ®å¿µãªãããªãã
é³å£°åºåãsourceã«ããããã®æ¹æ³ã¨ãã¦module-pipe-sourceã¨ããã®ããããããã¯
pacmd load-module module-pipe-source file=/tmp/pipe-source.fifoã®ããã«ãã¦fifoã使ã£ã¦èªã¿æ¸ãã§ãããããã«å¯¾ãã¦
ffmpeg -re -i source.mp4 -vn -f s16le -ac 2 -ar 48000 /tmp/pipe-source.fifoã®ããã«ãã¦é³ãå ¥åãããã¨ãã§ãã
ffmpeg -f alsa -i pulse recording.flacã®ããã«æ¾ããã¨ãã§ããã ãã®ä»çµã¿ã使ããã¨ã§ã«ã¹ã¿ã sourceãä½ããã¨ãã§ããããcombine-sourceã¯ãªãã®ã§ããã¯ã¹ãããã¨ãã§ããªãã
compressor
é³ãå²ããªãããã«ããããã«ã³ã³ãã¬ããµã¼ã使ããããã¨æããããããªãã
ã³ã³ãã¬ããµã¼ãã®ãã®ã¯åå¨ããä¾ãã°LADPSAã®swh-pluginsã使ã£ãã³ã³ãã¬ãã·ã§ã³ãå¯è½ã ããç§ã®æè¦ã¨ãã¦ã¯ãã¾ãå®ç¨çã§ã¯ãªãã SC4ã使ã£ãã®ã ããã³ã³ãã¬ããµã¼ã¨ãã¦ã®ã¾ãããããè¶³ããããªããã¿ã¼çãªä½¿ãæ¹ãããã«ãã¦ãã¡ãã£ã¨ãã¤ãã
ä½¿ãæ¹ã¨ãã¦ã¯
pacmd load-module module-ladspa-sink sink_name=compressor master=mixmic plugin=sc4_1882 label=sc4 control=1,1.5,401,-30,20,10,12ã¨ãã£ãæããcontrolã®å¤ãªã©è©³ããã¯ãã¡ãã
ããã§ã®é£ããã¯ããã²ã¨ã¤ãè¿ãã®æç¡ã§null sinkã¨combine sinkã使ãããã¦ããã¨ããã®ãããã å²ããªãããã«å§ç¸®ããã®ã§ããã°ã両æ¹ã«ã³ã³ãã¬ããµã¼ãæ¿ãå¿ è¦ãããã®ã ã ããããªãã¨ãcombine sinkânull sinkã§ãcombine sinkã§æ¢ã«å²ããç¶æ³ã«ã¯å¯¾å¿ã§ããªãã
ã¾ããå©ç¨ããã®ã§ããã°ç¾å®çã«ã²ã¤ãã¼ã¨ãã¦ã¯ä½¿ããªãã®ã§ãããããç®çã§ããã°ãã¤ã¯å ¥åã大ããã«è¨å®ãããªã©ããå¿ è¦ãããã
æ åç·¨
æ¦è¦
é³å£°ã§ã¯å¼·åãªPulseAudioããããµã¼ããããã¨ãã¦æ´»ç¨ããããæ åã«é¢ãã¦ã¯ãããããããµã¼ãããããã§ã¯ãªãã
æ åãæè»ã«æ±ãä¸ã§æ´»èºããã®ã
- v4l2ãã©ã¤ã
- ffmpeg
- mpv
ã§ããã
v4l2ã¯Linuxã«æ®éã¯å«ã¾ãã¦ãã(çµã¿è¾¼ã¾ãã¦ãã«ãããã¦ãã)ã ã¦ã§ãã«ã ãªã©ãæ±ãä¸ã§å¿ é ã ã
ffmpegã¯æ åãæ±ãé常ã«ä¾¿å©ãªã½ããã¦ã§ã¢ã ã ããã¦ãmpvã¯ã¡ãã£ã¢ãã¬ã¤ã¤ã¼ã ããã¨ãã§ããªãå¼·åãªæ©è½ãæã¤ã ãã¡ãããã¦ã§ãã«ã ã®æ åã®åçãªã©ãå¯è½ã ã
ããããé§ä½¿ãã¦åé¡ã解決ãã¦ããã
ã¹ã¯ãªã¼ã³ãã£ã¹ã
ç»é¢å ±ææ©è½ããªãå ´åãªã©ã«ããã¦ç»é¢ãæ ãããå ´åãv4l2loopbackãå©ç¨ããã
Arch Linuxã®å ´åãæ¬¡ã®ããã«ãã¦ã¤ã³ã¹ãã¼ã«ããã (AURããã±ã¼ã¸ãªã®ã§ãTrizenã使ã£ã¦ãã)
trizen -S v4l2-loopback-dkmsãªãã ã«ã¼ãã«ãããã¼ãå¿ è¦ãªã®ã§ãäºåã«ã¤ã³ã¹ãã¼ã«ãã¦ãããã¨ã
æºåã§ãããã¢ã¸ã¥ã¼ã«ããã¼ãããã
sudo modprobe v4l2loopback exclusive_caps=1ããã§ã/dev/video*ã«æ°ããä»®æ³ã«ã¡ã©ã追å ããã¦ããã¯ãã ã
% v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video0
ã§ã¯ffmpegã使ã£ã¦ãã®ã«ã¡ã©ã«æµãè¾¼ããã
ffmpeg -re -f x11grab -video_size 1920x1080 -i $DISPLAY -pix_fmt yuv420p -f v4l2 /dev/video0ãããªãµã¤ãºã¯å®éã«æµãããç»é¢ã®ãµã¤ãºã«ããã ãã«ããã£ã¹ãã¬ã¤ã®å ´åãªã©ã§ç¹å®ã®ãã£ã¹ãã¬ã¤ã®ã¿åºåãããå ´åã¯ãªãã»ãããå ããã
ffmpeg -re -f x11grab -video_size 1920x1080 -i $DISPLAY+0,1080 -pix_fmt yuv420p -f v4l2 /dev/video0ããã¯ããã£ã¹ãã¬ã¤ã®ä¸¦ã³ã«å½±é¿ãããã¨ããç¹ã«ãããããæ³¨æãã¦ã»ããã
ç§ã¯ä¸å¤®ã«4kãã£ã¹ãã¬ã¤ã§å·¦å³ã«FHDãã£ã¹ãã¬ã¤ãªã®ã ããå·¦å´ã®ãã£ã¹ãã¬ã¤ã¯4kãã£ã¹ãã¬ã¤ã¨ä¸ç«¯ãåããã¦ããã
ããããã¨ãã¬ã¤ã¢ã¦ãä¸ã®ä¸ç«¯ã縦ã®0ã«ãªããããå·¦ã®FHDãã£ã¹ãã¬ã¤ã®å·¦ä¸ã¯0,1080ã«ãªãã®ã§ããã
ããã§ãã«ã¡ã©ãããã¹ã¯ããããåºåãããã¨ãã§ããããã«ãªã£ãã
ãã¯ãã£ã¤ã³ãã¯ã㣠(ã¯ã¤ã)
ãã¹ã¯ããããæ ãã«ã¡ã©ãã§ããã®ã§ãåãæ¿ããªãã使ãã°è¯ãã¨æããããã«ã¡ã©ãåãæ¿ããæ©è½ããªããæåã«é¸æãããã®ã§åºå®ã§ãããã¨ããå ´åããããã¯ããã¨é¢ä¿ãªãã¦ã§ãã«ã¡ã©ã¨ãã¹ã¯ããããåæãããå ´åãªã©ã¯ã©ããããããã ãããã
ããã¯ãffmpegã®-filter_complexæ©è½ã使ãã®ã ãã話ã¨ãã¦ã¯ç¸å½è¤éã§ããã
çµè«ã示ãã¨ã
ffmpeg -re -f x11grab -framerate 24 -probesize 64M -video_size 1920x1080 -i $DISPLAY -pix_fmt yuv420p -f v4l2 -i /dev/video1 -pix_fmt yuv420p -filter_complex "[1:v] scale=360:-1,setpts=PTS-(10/TB) [1v]; [0:v][1v] overlay=x=25:y=25[outv]" -map "[outv]" -f v4l2 /dev/video0ã¿ããã«ããã®ã ããåé¡ã¨ãã¦ãéããã¦ãã¤ããã½ã¼ã¹ãã¹ã¯ãªã¼ã³ãã£ã¹ãã§ãªããã°ãããªã«åé¡ã¯ãªãã®ã ãã©ãã¹ã¯ãªã¼ã³ãã£ã¹ãã¨webcamã®çµã¿åããã ã¨å³ããããããã ã
ãããªãåé¡ã¨ãã¦ãã¢ããªã±ã¼ã·ã§ã³ã«ãã£ã¦ã¯ã²ã¨ã¤ã§ãã«ã¡ã©ãå©ç¨ä¸ã®ç¶æ ã§ã¯ã«ã¡ã©ã使ããªããã®ã¨ã¿ãªããã¨ãããã¨ãããããã ã ãã®å ´åãæ¢ã«ã¦ã§ãã«ã ã(åæã®ããã«)使ã£ã¦ãã¾ã£ã¦ããã®ã§ä½¿ããªããªã£ã¦ãã¾ãã
ããã§çºæ³ã®è»¢æã§ã²ã¨å·¥å¤«ããããè¤æ°ã®ã½ã¼ã¹ããé²ç»ãããã¨ãããããããªãã®ã ãã²ã¨ã¤ã®ã½ã¼ã¹ã«ãã¦ãã¾ãã°ããã
ã¨ããããã§ãã¾ãã¦ã§ãã«ã ãç»é¢ã«åºããã
mpv --ontop --no-osc --no-border av://v4l2:/dev/video1ããã§/dev/video1ã®ã¦ã§ãã«ã ãmpvã«ãã£ã¦åçããããã©ã°ãçµæ§å°ãªããããã¬ã¼ã ã¬ã¼ããåºãã
ç§»åã¨ãªãµã¤ãºã¯ãã¦ã£ã³ãã¦ããã¼ã¸ã£ã«ãããããAlt+å·¦ãã©ãã°ã§ç§»åã§ããã(GNOMEã¯Super+å·¦ãã©ãã°)ããªãµã¤ãºã¯Alt+å³ãã©ãã°ã§ãããã
ãã¦ãããã§ç»é¢ä¸ã«ã¦ã§ãã«ã ã®æ åãåºã¦ããã®ã§ã ãã£ã¹ãããã¹ã¯ãªã¼ã³ä¸ã«mpvã®ã¦ã£ã³ãã¦ãé ç½®ãããã ãã¨ã¯ãmpvã®ã¦ã£ã³ãã¦ãã¨ãã£ã¹ããã¦ãã¾ãã°ããã
ffmpeg -re -f x11grab -video_size 1920x1080 -i $DISPLAY -pix_fmt yuv420p -f v4l2 /dev/video0ããã§å ¨ãåé¡ãªã(ãã¡ãããã¦ã§ãã«ã ã®ã»ããè¥å¹²ã©ã°ãããæãã«ãªãã)ã
è£è¶³
ã²ã¼ã æ©ã«ããã²ã¼ã æ åãªã©ããããªãã£ããã£ã«ã¼ããªã©ã使ã£ã¦å¤é¨ã®å ¥åãåãåãå ´åããLinuxä¸ã§ã¯v4l2ãã©ã¤ãã使ããã¨ã«ãªããããã¦ã§ãã«ã ã¨åãæ±ããå¯è½ã
ä¾ãã°ãã£ããã£ããæ åã«ã¯ã¤ããè¼ãããã¨ãããããªå ´åããmpvã§ãã£ããã£æ åãåçãããã«mpvã§ã¦ã§ãã«ã ã®ã¯ã¤ãããããåºå®ã«ãã¦ããã®ç»é¢ããã£ã¹ãããã¨ããæ¹æ³ã使ããã
ããã¯ãã£ããã£æ åã§ã¯ãªãæå ã®ãããªã ã¨ããå ´åããåæ§ã«mpvã§ãããªãåçããã ãã®è©±ã§ç°¡åã ã
ãªããNvidiaãããªã«ã¼ãã§nvidiaãã©ã¤ãã使ã£ã¦ããå ´åãã¦ã£ã³ãã¦ãé¨åçã«æ¶ãã¦ãã¹ã¯ããããè¦ãã¦ãã¾ãã¨ããç»é¢æ¬ ããçºçããããã®ã§æ³¨æãã¦ã»ããã