{"id":114,"date":"2006-08-02T20:47:24","date_gmt":"2006-08-03T04:47:24","guid":{"rendered":"http:\/\/outflux.net\/blog\/archives\/2006\/08\/02\/mythtv-cutlist-to-mplayer-edl-file\/"},"modified":"2006-08-02T21:08:20","modified_gmt":"2006-08-03T05:08:20","slug":"mythtv-cutlist-to-mplayer-edl-file","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2006\/08\/02\/mythtv-cutlist-to-mplayer-edl-file\/","title":{"rendered":"mythtv cutlist to mplayer EDL file"},"content":{"rendered":"<p>I was too lazy to walk over to my TV, so I decided to watch my <a href=\"http:\/\/mythtv.org\/\">MythTV<\/a> recordings on my desktop without having installed a MythTV frontend.  Via the magic of <a href=\"http:\/\/outflux.net\/software\/pkgs\/mythtvfs-fuse\/\">MythTVfs<\/a>, I started watching a recent Stargate <a href=\"http:\/\/www.tv.com\/stargate-sg1\/the-pegasus-project\/episode\/667194\/summary.html\">episode<\/a>.<\/p>\n<p>Before the opening credits had finished, I knew I was already going to miss MythTV&#8217;s commercial flagging.  So started the investigation into where in the world MythTV stores that information.  I was imagining adding &#8220;.edl&#8221; files to MythTVfs automatically, etc.<\/p>\n<p>In MythTV 0.19, using &#8220;mythcommflag&#8221;, you can get the &#8220;Cut&#8221; list, but not the &#8220;Commercial Skip&#8221; list.  (Think of the latter as a &#8220;Cut Hint&#8221; list.)  The command for this is:<\/p>\n<blockquote><p>mythcommflag &#8211;getcutlist -c 1059 -s 20060728210000<\/p><\/blockquote>\n<p>In MythTV 0.20, you&#8217;ll be able to use &#8220;&#8211;getskiplist&#8221;.  Since I&#8217;m still using 0.19, I had to go directly to the &#8220;mythconverg&#8221; database to get the details.  The marks are stored in the &#8220;recordedmarkup&#8221; table.  The <a href=\"http:\/\/svn.mythtv.org\/trac\/browser\/trunk\/mythtv\/libs\/libmythtv\/programinfo.h#L18\">mark types<\/a> I care about are: 4: Commercial Start, 5: Commercial End.  This SQL query gets me somewhere:<\/p>\n<blockquote><p>SELECT mark, type FROM recordedmarkup WHERE chanid = &#8220;1059&#8221; AND starttime = &#8220;20060728210000&#8221; AND (type = 4 OR type = 5) ORDER BY mark;<\/p><\/blockquote>\n<p>However, mplayer&#8217;s <a href=\"http:\/\/www.mplayerhq.hu\/DOCS\/HTML\/en\/edl.html\">EDL<\/a> file format expects time, not frame number.  MythTV stores frame number.  Luck for us, it&#8217;s all NTSC MPEG2, so we&#8217;re at 29.97 frame per second, and I can modify the SQL:<\/p>\n<blockquote><p>SELECT mark<strong>\/29.97<\/strong>, type FROM recordedmarkup WHERE chanid = &#8220;1059&#8221; AND starttime = &#8220;20060728210000&#8221; AND (type = 4 OR type = 5) ORDER BY mark;<\/p><\/blockquote>\n<p>Now I just have to get the pairs on a single line with a trailing &#8220;0&#8221; for mplayer to know to skip that time frame:<\/p>\n<blockquote><p>echo &#8216;SELECT mark\/29.97 FROM recordedmarkup WHERE chanid = &#8220;1059&#8221; AND starttime = &#8220;20060728210000&#8221; AND (type = 4 OR type = 5) ORDER BY mark;&#8217; | mysql -B &#8211;skip-column-names | xargs -l2 | awk &#8216;{print $0 &#8221; 0&#8243; }&#8217;<\/p><\/blockquote>\n<p>Combined with some logic to extract the channel and starttime for a given recording, I&#8217;ve now got a really crazy <a href=\"http:\/\/outflux.net\/software\/shorts\/shell\/mythwatch.txt\">wrapper script<\/a> that&#8217;ll let me mplayer a recording after generating an EDL cutlist.<\/p>\n<p>(With thanks to Ken&#8217;s excellent <a href=\"http:\/\/www.cgi101.com\/~ken\/code\/cat2.txt\">collection<\/a> of &#8220;merge pairs of lines into single lines&#8221; short cuts.)<\/p>\n<p style='text-align:left'>&copy; 2006, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was too lazy to walk over to my TV, so I decided to watch my MythTV recordings on my desktop without having installed a MythTV frontend. Via the magic of MythTVfs, I started watching a recent Stargate episode. Before the opening credits had finished, I knew I was already going to miss MythTV&#8217;s commercial [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/114"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":0,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}