{"id":2914,"date":"2022-07-09T21:07:03","date_gmt":"2022-07-09T21:07:03","guid":{"rendered":"https:\/\/liljenfeldt.ch\/?p=2914"},"modified":"2022-07-09T21:15:05","modified_gmt":"2022-07-09T21:15:05","slug":"%ef%bf%bc","status":"publish","type":"post","link":"https:\/\/webbservern.se\/~jonas\/wordpress\/?p=2914","title":{"rendered":"Streaming and recording IP TV &#8211; follow up"},"content":{"rendered":"\n<p>I noticed that the recording jobs sometimes got interrrupted, since the streams were not completely reliable. If ffmpeg does not get any data delivered it gives up after some time and I do not see any parameter to configure that timeout. (Please let me know if you know about it&#8230;).<\/p>\n\n\n\n<p>I came up with a fairly crude and simple, but working, let&#8217;s call it pragmatic solution, which is generic enough to share in a post like this.<\/p>\n\n\n\n<p>The script that registers the recording at jobs does:<\/p>\n\n\n\n<p><code>...<br>at -m ${FORMATTED_STARTTIME} &lt;&lt;!<br>bash \/home\/xxx\/scripts\/recordIptvRobust.sh ${SEC_LENGTH} ${CHANNEL_NO} ${START_TIME}<br>!<br>...<\/code><\/p>\n\n\n\n<p>and the recordIptvRobust.sh bash  (5.0 and later since it uses the convenient epochseconds variable) script does:<\/p>\n\n\n\n<p><code>...<br>START_EPOCH=$EPOCHSECONDS<br>STOP_EPOCH=$(( \"${START_EPOCH} + ${SEC_LENGTH}\" ))<br>while ((\"${EPOCHSECONDS} &lt; ${STOP_EPOCH}\")); do<br>  \/usr\/bin\/ffmpeg -i \"http:\/\/stream-url-here\/${CHANNEL_NO}\" -y -err_detect ignore_err -c:v copy -c:a copy -t $SEC_LENGTH \/home\/xxx\/public_html\/record\/record_${STARTTIME\/\/:}${CHANNEL_NO}${EPOCHSECONDS}.mkv<br>  # Give the stream some time to restore order<br>  sleep 10<br>done<br># Merge segments with mkvmerge<br>\/usr\/bin\/mkvmerge -o \/home\/xxx\/public_html\/record\/record_${STARTTIME\/\/:}${CHANNEL_NO}.mkv $(ls -1 \/home\/xxx\/public_html\/record\/record${STARTTIME\/\/:}${CHANNEL_NO}.mkv | paste -sd\" \" | sed 's\/ \/ + \/g') <br>...<\/code><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I noticed that the recording jobs sometimes got interrrupted, since the streams were not completely reliable. If ffmpeg does not get any data delivered it gives up after some time and I do not see any parameter to configure that &hellip; <a href=\"https:\/\/webbservern.se\/~jonas\/wordpress\/?p=2914\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,32,35],"tags":[83,811],"class_list":["post-2914","post","type-post","status-publish","format-standard","hentry","category-datorer","category-tv","category-webben","tag-bash","tag-ffmepg"],"_links":{"self":[{"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2914"}],"version-history":[{"count":4,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2914\/revisions"}],"predecessor-version":[{"id":2919,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2914\/revisions\/2919"}],"wp:attachment":[{"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webbservern.se\/~jonas\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}