<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 5/11/2015 12:46 PM, Michael Stucky
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMN+uBU4_MAT+ONisue--pjthimvsf38EDdkDN1HjkJiqJc22g@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Mon, May 4, 2015 at 5:30 PM, Dave
            MythTV <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:dave.mythtv@gmail.com" target="_blank">dave.mythtv@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <div dir="ltr"><br>
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">On Sun, May 3, 2015 at 6:22
                    PM, Michael Stucky <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:mike@stucky.us" target="_blank">mike@stucky.us</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                      <div dir="ltr">
                        <div class="gmail_extra">
                          <div class="gmail_quote">
                            <div>
                              <div>On Sun, May 3, 2015 at 5:46 PM, Dave
                                MythTV <span dir="ltr"><<a
                                    moz-do-not-send="true"
                                    href="mailto:dave.mythtv@gmail.com"
                                    target="_blank">dave.mythtv@gmail.com</a>></span>
                                wrote:<br>
                                <blockquote class="gmail_quote"
                                  style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
                                  <div dir="ltr">
                                    <div>
                                      <div>
                                        <div>
                                          <div>
                                            <div>Hello everyone.<br>
                                            </div>
                                            <br>
                                          </div>
                                          I'm running some tests,
                                          preparing to reconfigure my
                                          backend to transcode certain
                                          shows from US-broadcast ATSC
                                          MPEG2 to H264 for hardware
                                          accelerated playback on our
                                          various portable devices.  In
                                          doing this, I've been
                                          experimenting with Mike
                                          Stucky's user job script:<br>
                                        </div>
                                        <a moz-do-not-send="true"
                                          href="https://www.mythtv.org/wiki/Transcode_Mpeg2_to_H264"
                                          target="_blank">https://www.mythtv.org/wiki/Transcode_Mpeg2_to_H264</a><br>
                                        <br>
                                        <br>
                                      </div>
                                      However, I've hit a snag...  If I
                                      run this script on an MPEG2 file
                                      with interlaced SD content, MythTV
                                      no longer recognizes the resulting
                                      H264 file as being interlaced, and
                                      playback in the MythTV frontend
                                      shows interlacing artifacts.<br>
                                      <br>
                                    </div>
                                    I know I could modify Mike's script
                                    to specifically deinterlace the
                                    content before or during the H264
                                    conversion... but I didn't think
                                    this would have been necessary?  
                                    Shouldn't it be possible to convert
                                    interlaced MPEG2 to interlaced H264,
                                    and continue using the frontend's
                                    deinterlacer?<br>
                                    <div>
                                      <div><br>
                                        <br>
                                      </div>
                                      <div>Additional information:<br>
                                      </div>
                                      <div>'mediainfo' detects the input
                                        MPEG2 file as being interlaced,
                                        but shows the output H264 file
                                        as being progressive scan.  So I
                                        think this might be an issue
                                        with the ffmpeg conversion
                                        flagging (or encoding) the
                                        non-deinterlaced output as
                                        progressive... and not an issue
                                        with MythTV's player?<br>
                                        <br>
                                        <br>
                                      </div>
                                      <div>Thanks for the help.<span><font
                                            color="#888888"><br>
                                          </font></span></div>
                                      <span><font color="#888888">
                                          <div>- Dave<br>
                                          </div>
                                          <div><br>
                                          </div>
                                        </font></span></div>
                                  </div>
                                </blockquote>
                                <div><br>
                                </div>
                              </div>
                            </div>
                            <div>I have recently discovered this same
                              behavior and I think you are right about
                              it being an ffmpeg issue. It looks like
                              ffmpeg automatically deinterlaces SD
                              content, so I have modified the
                              "transcode" section to do a better job of
                              deinterlacing (this has the added benefit
                              of allowing ffmpeg to do a better job of
                              compressing), this appears to be working
                              for me, at least for SD content:</div>
                            <div><br>
                            </div>
                            <div>     task = System(path=transcoder,
                              db=db)</div>
                            <div>     try:<br>
                            </div>
                            <div>            output = task('-i "%s"' %
                              tmpfile,</div>
                            <div>                          '-filter:v
                              yadif=1',</div>
                            <div>                          '-sws_flags
                              spline',<br>
                            </div>
                            <div>                          '-r
                              60000/1001',</div>
                            <div>                          '-c:v
                              libx264',</div>
                            <div>                          '-preset:v
                              slow',</div>
                            <div>                          '-crf:v 18',</div>
                            <div>                          '-threads 0',<br>
                            </div>
                            <div>                          '-c:a copy',</div>
                            <div>                         
                              '-metadata:s:a:0',</div>
                            <div>                         
                              'language="eng"',</div>
                            <div>                          '"%s"' %
                              outfile,</div>
                            <div>                          '2>
                              /dev/null')</div>
                            <div><br>
                            </div>
                            <div>If you find that this helps let me know
                              and I will update the script on the wiki.</div>
                            <div><br>
                            </div>
                            <div>Mike</div>
                          </div>
                        </div>
                      </div>
                      <br>
                    </blockquote>
                    <div><br>
                      <br>
                    </div>
                    <div>Thanks Mike!  I'll do some experimenting with
                      your changes this evening.  <br>
                      <br>
                      A couple questions:<br>
                    </div>
                    <div>* What made you select 'spline' as the scaler
                      method?  (just curious)<br>
                    </div>
                    <div>* Did you have a frame rate issue that required
                      forcing the output frame rate explicitly?<br>
                      <br>
                    </div>
                    <div>Also, I think there may be an issue with the
                      yadif filter...<br>
                    </div>
                    <div>The FFmpeg docs state that the third yadif
                      parameter (deint) controls which frames to
                      deinterlace.  The default is "all", but I've been
                      reading that applying yadif on **progressive**
                      source content will negatively impact the quality.<br>
                      (example: <a moz-do-not-send="true"
                        href="https://ffmpeg.org/pipermail/ffmpeg-user/2014-May/021412.html"
                        target="_blank">https://ffmpeg.org/pipermail/ffmpeg-user/2014-May/021412.html</a>)<br>
                      <br>
                    </div>
                    <div>So I think to make your script flexible for
                      both interlaced and progressive source content, we
                      would need to either call yadif as yadif=1:-1:1 
                      (and hope that the frames are properly flagged?),
                      or do some sort of other method (idet filter?) to
                      detect the interlacing and convert as necessary?  
                      There is a solution in the message linked above
                      using idet, but the author (Nick) reports "mixed
                      success"...  not sure what to make of that.<br>
                      <br>
                    </div>
                    <div>(Other links for reference...)<br>
                    </div>
                    <div><a moz-do-not-send="true"
                        href="https://ffmpeg.org/ffmpeg-filters.html#yadif-1"
                        target="_blank">https://ffmpeg.org/ffmpeg-filters.html#yadif-1</a>  
                      <br>
                    </div>
                    <div><a moz-do-not-send="true"
                        href="https://ffmpeg.org/ffmpeg-filters.html#idet"
                        target="_blank">https://ffmpeg.org/ffmpeg-filters.html#idet</a><br>
                      <br>
                    </div>
                    <div><br>
                    </div>
                    <div>Thanks again<span class=""><font
                          color="#888888"><br>
                        </font></span></div>
                    <span class=""><font color="#888888">
                        <div>- Dave<br>
                        </div>
                        <div><br>
                        </div>
                      </font></span></div>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Sorry for the delay, it was a busy weekend+... I am not
              an ffmpeg expert so all the syntax came either from the
              original shell script or searches for a better way to
              deinterlace. But I have done some additional searching and
              testing have updated my script on the wiki accordingly. </div>
            <div><br>
            </div>
            <div>"yadif=1" has become "yadif=0:-1:1" (mode 0 = one frame
              out for one frame in, parity -1 = autodetect, and deint 1
              = only deinterlace frames marked as interlaced).
              "sws_flags spline" is removed (only applies when scaling
              content?). "-r 60000/1001" is removed (this actually
              caused every frame to be duplicated for interlaced
              content). "threads 0" is removed (the h264 encoder uses
              all available threads by default). "-c:a copy" replaced
              with "-strict -2" to use the internal AAC encoder.</div>
            <div><br>
            </div>
            <div>This works and produces good quality output for all my
              content, 1080i, 720p, and 480i all OTA to HDHomerun
              tuners. </div>
            <div><br>
            </div>
            <div>Mike</div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
mythtv-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a>
<a class="moz-txt-link-freetext" href="http://lists.mythtv.org/mailman/listinfo/mythtv-users">http://lists.mythtv.org/mailman/listinfo/mythtv-users</a>
<a class="moz-txt-link-freetext" href="http://wiki.mythtv.org/Mailing_List_etiquette">http://wiki.mythtv.org/Mailing_List_etiquette</a>
MythTV Forums: <a class="moz-txt-link-freetext" href="https://forum.mythtv.org">https://forum.mythtv.org</a>
</pre>
    </blockquote>
    I took a look at the script on the wiki and had a question.  Does
    this break commercial skipping?  The script does not appear to
    reschedule a commflag job after the transcoding.<br>
    Jay<br>
  </body>
</html>