<div dir="ltr">Okay, Looks like capturing the Pulse source works fine. I'll just have to resolve the audio down to the Pulse device. I'll clean up the code a little bit more and put it on github if anyone finds it useful.<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">----------------<br>Robert LeBlanc<br>PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1</div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 6, 2018 at 11:19 AM Robert LeBlanc <<a href="mailto:robert@leblancnet.us">robert@leblancnet.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The only issue I've run into with ffmpeg is sometimes the V4l2 buffer is not ready. I'm watching for that and relaunching ffmepg if that happens. My ffmpeg command is:<div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">2018-12-06 10:45:00,247 DEBUG - mythuc.py:194 - __init__() ffmpeg command: ffmpeg -f v4l2 -video_size 1920x1200 -framerate 60.0 -input_format yuyv422 -thread_queue_size 2048 -i /dev/video0 -f alsa -thread_queue_size 2048 -i hw:1,0 -map 0:v -map 1:a -f </span>mpegts -acodec mp3 -loglevel error -pix_fmt yuv420p -preset superfast -vcodec libx264 - -nostdin<br>
<br></span><div><div class="gmail-m_8719952241408853718gmail_signature">Here is my logs when the v4l2 buffer isn't ready:</div><div class="gmail-m_8719952241408853718gmail_signature"><span style="font-family:monospace"><span style="color:rgb(0,0,0)">2018-12-06 10:45:00,259 DEBUG - mythuc.py:209 - start() Wating for ffmpeg to warm up.
</span><br>2018-12-06 10:45:00,600 DEBUG - mythuc.py:278 - loggy() Ffmpeg: b'[video4linux2,v4l2 @ 0x556843eeaf00] Dequeued v4l2 buffer contains 1579180 bytes, but 4608000 were expected. Flags: 0x00012001.\n'
<br>2018-12-06 10:45:00,600 WARNING - mythuc.py:280 - loggy() Ffmpeg not getting v4l2 stream. Going to restart ffmpeg...
<br>2018-12-06 10:45:00,601 DEBUG - mythuc.py:212 - start() ffmpeg warmed up with state: ERROR
<br>2018-12-06 10:45:00,601 DEBUG - mythuc.py:215 - start() Ffmpeg in error state. Restart (1)
<br>2018-12-06 10:45:00,602 DEBUG - mythuc.py:217 - start() ffmpeg sent terminate
<br>2018-12-06 10:45:01,352 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 54400 to 48692
<br>2018-12-06 10:45:01,368 DEBUG - mythuc.py:219 - start() Restarting FFmpeg...
<br>2018-12-06 10:45:01,372 DEBUG - mythuc.py:271 - loggy() Loggy thread running...
<br>2018-12-06 10:45:01,373 DEBUG - mythuc.py:209 - start() Wating for ffmpeg to warm up.
<br>2018-12-06 10:45:01,674 DEBUG - mythuc.py:278 - loggy() Ffmpeg: b'[alsa @ 0x5625c200b500] cannot open audio device hw:1,0 (Device or resource busy)\n'
<br>2018-12-06 10:45:01,674 DEBUG - mythuc.py:278 - loggy() Ffmpeg: b'hw:1,0: Input/output error\n'
<br>2018-12-06 10:45:02,108 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 48692 to 52640
<br>2018-12-06 10:45:02,308 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 52640 to 57904
<br>2018-12-06 10:45:02,373 DEBUG - mythuc.py:212 - start() ffmpeg warmed up with state: INIT
<br>2018-12-06 10:45:02,374 DEBUG - mythuc.py:99 - ms_run() MythtvSend main thread starting...
<br>2018-12-06 10:45:02,374 DEBUG - mythuc.py:415 - cmd_resp() Command reply: OK:Started
<br>2018-12-06 10:45:02,375 INFO - mythuc.py:439 - get_cmd() Received command: 'XON'
<br>2018-12-06 10:45:02,376 DEBUG - mythuc.py:415 - cmd_resp() Command reply: OK
<br>2018-12-06 10:45:02,509 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 57904 to 63168
<br>2018-12-06 10:45:02,709 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 63168 to 126336
<br>2018-12-06 10:45:02,910 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 126336 to 252672
<br>2018-12-06 10:45:03,110 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 252672 to 505344
<br>2018-12-06 10:45:03,311 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 505344 to 1010688
<br>2018-12-06 10:45:03,511 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 1010688 to 1048576
<br>2018-12-06 10:50:00,320 INFO - mythuc.py:439 - get_cmd() Received command: 'CloseRecorder'
<br>2018-12-06 10:50:00,320 INFO - mythuc.py:243 - close() Shutting down ffmpeg
<br>2018-12-06 10:50:00,321 INFO - mythuc.py:252 - close() Ffmpeg shut down successfully.
<br>2018-12-06 10:50:00,321 INFO - mythuc.py:84 - close() Shutting down the MythTV sender.
<br>2018-12-06 10:50:00,321 INFO - mythuc.py:96 - close() MythTV sender queue drained.
<br>2018-12-06 10:50:00,321 DEBUG - mythuc.py:415 - cmd_resp() Command reply: OK:Terminating<br>
<br></span></div><div dir="ltr" class="gmail-m_8719952241408853718gmail_signature">----------------<br>Robert LeBlanc<br>PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 6, 2018 at 10:55 AM John P Poet <<a href="mailto:jppoet@gmail.com" target="_blank">jppoet@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Thu, Dec 6, 2018 at 10:48 AM Robert LeBlanc <<a href="mailto:robert@leblancnet.us" target="_blank">robert@leblancnet.us</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I've got just about everything set up to capture from my USB capture device. When my script is run from Mythbackend, the hw:1 device is not available to my recorder script when watching LiveTV (frontend on the same box). When I run the script stand alone with Mythbackend and Mythfrontend running but not watching LiveTV get both video and audio. I tried setting the Mythfrontend to use the null sound device and it still holds on to hw:1. I tried both hw:1 and hw:1,0 with the same results.<div><br></div><div>The backend segfaults probably because of a corrupted stream from ffmpeg because of this. If I don't try to capture the audio, then I can see the LiveTV stream just fine of course there is no audio.</div><div><br></div><div> Any ideas how to get around this problem?<div><br></div><div>Here is some logs from my ExternalRecorder script.</div><div><br></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0)">2018-12-06 10:25:20,226 DEBUG - mythuc.py:209 - start() Wating for ffmpeg to warm up.
</span><br>2018-12-06 10:25:20,506 DEBUG - mythuc.py:278 - loggy() Ffmpeg: b'[alsa @ 0x55838b4c2500] cannot open audio device hw:1,0 (Device or resource busy)\n'
<br>2018-12-06 10:25:20,506 DEBUG - mythuc.py:278 - loggy() Ffmpeg: b'hw:1,0: Input/output error\n'
<br>2018-12-06 10:25:20,728 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 48692 to 52640
<br>2018-12-06 10:25:20,929 INFO - mythuc.py:304 - adjust_chunksize() Stream read block size changed from 52640 to 57904<br></span></div><div><br></div><div>Scheduling a recording and not running Mythfrontend also has the same error opening the audio device, so it must be something with the backend. There is only the one Capture device (ExternalRecorder) configured so I'm not sure why Mythbackend is even messing with that device. I'm running 29.1 from deb-multimedia(mythbackend version:  [v29.1] <a href="http://www.mythtv.org" target="_blank">www.mythtv.org</a>)<br></div></div></div></blockquote><div><br></div><div>Can you post the complete ffmpeg command with arguments that you are using?   At least when I was playing around with mythexternrecorder configurations (<a href="https://www.mythtv.org/wiki/ExternalRecorder" target="_blank">https://www.mythtv.org/wiki/ExternalRecorder</a> and <a href="https://www.mythtv.org/wiki/Example_Configuration_files" target="_blank">https://www.mythtv.org/wiki/Example_Configuration_files</a>) I found that using cvlc was much more reliable than ffmpeg, so you may want to try that.</div><div><br></div><div>John<br></div></div></div></div></div>
_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org" target="_blank">mythtv-users@mythtv.org</a><br>
<a href="http://lists.mythtv.org/mailman/listinfo/mythtv-users" rel="noreferrer" target="_blank">http://lists.mythtv.org/mailman/listinfo/mythtv-users</a><br>
<a href="http://wiki.mythtv.org/Mailing_List_etiquette" rel="noreferrer" target="_blank">http://wiki.mythtv.org/Mailing_List_etiquette</a><br>
MythTV Forums: <a href="https://forum.mythtv.org" rel="noreferrer" target="_blank">https://forum.mythtv.org</a><br>
</blockquote></div>
</blockquote></div>