<div dir="ltr"><div class="gmail_default" style="font-size:small">This high end / high quality preset as developed and tested by Terje (with Andrew input) has been checked into the source GIT base.<br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Jun 8, 2025 at 3:40 PM Terje J. Hanssen via Cin <<a href="mailto:cin@lists.cinelerra-gg.org">cin@lists.cinelerra-gg.org</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"><u></u>

  
    
  
  <div>
    <br>
    <br>
    <div>Den 08.06.2025 17:49, skrev Andrew
      Randrianasulu:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="auto">
        <div><br>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">вс, 8 июн. 2025 г., 18:26
              Terje J. Hanssen via Cin <<a href="mailto:cin@lists.cinelerra-gg.org" target="_blank">cin@lists.cinelerra-gg.org</a>>:<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> <br>
                <br>
                <div>Den 06.06.2025 14:17, skrev Terje J. Hanssen:<br>
                </div>
                <blockquote type="cite">While the newer h.264 and hevc
                  are known for best compression, mpeg2 may have better
                  quality at video bitrate > 30Mbps <br>
                  <br>
                  This example capture a raw video stream (optional tape
                  playback) from the camera sensor over HDMI out and
                  transcode audio to PCM into a high-end
                  mpeg2hd422p.m2ts <br>
                  -input_format yuyv422 -video_size hd1080 possibly may
                  be commented out, as the encoder default uses the
                  maximum capability it get from the capture card ms2130
                  and driver v4l2 <br>
                  <br>
                  mpeg2video is difficult to get quit perfect with
                  ffmpeg; muxing overhead: 6.206455% is the minimum I
                  have achieved as in this case. <br>
                  <br>
                  At this high bitrate, 39Mbps here, a combination with
                  segmented recording is suggested and preferred to
                  control the file sizes (segments) and eventually
                  corrupted parts better. <br>
                  <br>
                  <br>
                  ffmpeg -hide_banner -f v4l2 -framerate 50 -i
                  /dev/video0 -f alsa -ac 2 -i hw:CARD=UHD,DEV=0 -c:v
                  mpeg2video -refs 1 -bf 2 -b:v 35M -maxrate 35M
                  -minrate 35M -bufsize 38M -muxrate 38M -dc 10 -c:a
                  pcm_bluray -mpegts_m2ts_mode 1 -t 30 -f mpegts
                  mpeg2hd422p_35M.m2ts <br>
                  <br>
                  Input #0, video4linux2,v4l2, from '/dev/video0': <br>
                    Duration: N/A, start: 79.422429, bitrate: 1658880
                  kb/s <br>
                    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559),
                  yuyv422, 1920x1080, 1658880 kb/s, 50 fps, 50 tbr,
                  1000k tbn <br>
                  [aist#1:0/pcm_s16le @ 0x55e2664e95c0] Guessed Channel
                  Layout: stereo <br>
                  Input #1, alsa, from 'hw:CARD=UHD,DEV=0': <br>
                    Duration: N/A, start: 1749208971.359170, bitrate:
                  1536 kb/s <br>
                    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo,
                  s16, 1536 kb/s <br>
                  Stream mapping: <br>
                    Stream #0:0 -> #0:0 (rawvideo (native) ->
                  mpeg2video (native)) <br>
                    Stream #1:0 -> #0:1 (pcm_s16le (native) ->
                  pcm_bluray (native)) <br>
                  Press [q] to stop, [?] for help <br>
                  [mpeg2video @ 0x55e2664d0500] Warning vbv_delay will
                  be set to 0xFFFF (=VBR) as the specified vbv buffer is
                  too large for the given bitrate! <br>
                  <br>
                  Output #0, mpegts, to 'mpeg2hd422p_35M.m2ts': <br>
                    Metadata: <br>
                      encoder         : Lavf61.7.100 <br>
                    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv,
                  progressive), 1920x1080, q=2-31, 35000 kb/s, 50 fps,
                  90k tbn <br>
                        Metadata: <br>
                          encoder         : Lavc61.19.101 mpeg2video <br>
                        Side data: <br>
                          cpb: bitrate max/min/avg:
                  35000000/35000000/35000000 buffer size: 38000000
                  vbv_delay: N/A <br>
                    Stream #0:1: Audio: pcm_bluray, 48000 Hz, stereo,
                  s16, 128 kb/s <br>
                        Metadata: <br>
                          encoder         : Lavc61.19.101 pcm_bluray <br>
                  [out#0/mpegts @ 0x55e2664e9740] video:128445KiB
                  audio:5648KiB subtitle:0KiB other streams:0KiB global
                  headers:0KiB muxing overhead: 6.206455% <br>
                  <br>
                  frame= 1500 fps= 50 q=3.5 Lsize=  142416KiB
                  time=00:00:29.98 bitrate=38915.0kbits/s speed=0.998x <br>
                  <br>
                </blockquote>
                <br>
                I have been able to tune the ffmpeg specifications
                further:<br>
                <ul>
                  <li>'-profile:v 422p -level:v high' (for mpeg-2
                    profile 422P@HL)</li>
                  <li>'--ch_layout stereo' (as a replacement for  '-ac
                    2' that caused 'Guessed Channel Layout: stereo')</li>
                </ul>
                <br>
                And also verified the camera HDMI out 'raw video' and
                'raw audio' (pcm) using just the ffmpeg input parts:<br>
                <br>
                ffmpeg -hide_banner -f v4l2 -framerate 50 -i /dev/video0
                -f alsa -ch_layout stereo -i hw:CARD=UHD,DEV=0<br>
                <br>
                Input #0, video4linux2,v4l2, from '/dev/video0':<br>
                  Duration: N/A, start: 191.096360, bitrate: 1658880
                kb/s<br>
                  Stream #0:0: Video: rawvideo (YUY2 / 0x32595559),
                yuyv422, 1920x1080, 1658880 kb/s, 50 fps, 50 tbr, 1000k
                tbn<br>
                Input #1, alsa, from 'hw:CARD=UHD,DEV=0':<br>
                  Duration: N/A, start: 1749375770.007003, bitrate: 1536
                kb/s<br>
                  Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16,
                1536 kb/s<br>
                <br>
                <br>
                Attached here  is a full ffmpeg debug log file for
                verification (command below)<br>
                <ul>
                  <li>mpeg2hd422p_35M.log.gz</li>
                </ul>
                <br>
                ffmpeg -loglevel debug -f v4l2 -framerate 50 -i
                /dev/video0 -f alsa -ch_layout stereo -i
                hw:CARD=UHD,DEV=0 -c:v mpeg2video -profile:v 422p
                -level:v high -refs 1 -bf 2 -b:v 35M -maxrate 35M
                -minrate 35M -bufsize 38M -muxrate 38M -dc 10 -c:a
                pcm_bluray -mpegts_m2ts_mode 1 -t 30 -f mpegts
                mpeg2hd422p_35M.m2ts > mpeg2hd422p_35M.log
                2>&1<br>
                <br>
                -----------<br>
                <br>
                Among CinGG's existing m2ts presets<br>
                <br>
                cd /Leap_root/usr/share/cin/ffmpeg/video<br>
                <br>
                ls -1 *m2ts<br>
                <ul>
                  <li>avc422.m2ts</li>
                  <li>bluray_bff.m2ts</li>
                  <li>bluray_dv_ntsc.m2ts</li>
                  <li>bluray_dv_pal.m2ts</li>
                  <li>bluray_fakeinterlace.m2ts</li>
                  <li>bluray_lo.m2ts</li>
                  <li>bluray.m2ts</li>
                  <li>bluray_tff.m2ts</li>
                  <li>hevc422p10.m2ts</li>
                  <li>hevc422p8.m2ts</li>
                  <li>lossless.m2ts</li>
                  <li>visually_lossless.m2ts</li>
                </ul>
                <br>
                grep mpeg2video *m2ts<br>
                <ul>
                  <li>That is none so far for mpeg2video HD and 422p</li>
                </ul>
                <br>
                If this preset can be specified and supplemented (?) for
                use with pcm_bluray and segmented recording, I can test
                it next ;)<br>
              </div>
            </blockquote>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">I think you can copy existing mpeg2 m2ts  preset
          with different, desired name  (in same folder where other
          presets reside)</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">and just add you parameters there?</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">or try to put text below in new profile ....</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">mpegts mpeg2video</div>
        <div dir="auto">cin_pix_fmt=yuv422p</div>
        <div dir="auto">b=35M</div>
        <div dir="auto">dc=10</div>
        <div dir="auto">muxrate=38M</div>
        <div dir="auto">minrate=35M</div>
        <div dir="auto">maxrate=35M</div>
        <div dir="auto">bufsize=38M</div>
        <div dir="auto">bf=2</div>
        <div dir="auto">profile=high</div>
        <div dir="auto">refs=1</div>
      </div>
    </blockquote>
    <br>
    Yeah, thank you. Attach the new preset as suggested:<br>
    <br>
    cat mpeg2hd422p.m2ts<br>
    <br>
        mpegts mpeg2video<br>
        cin_pix_fmt=yuv422p<br>
        b=35M<br>
        dc=10<br>
        muxrate=38M<br>
        minrate=35M<br>
        maxrate=35M<br>
        bufsize=38M<br>
        bf=2<br>
        profile=high<br>
        refs=1<br>
    <br>
    Recorded a test clip mpeg2hd422p.m2ts Start/Stop as below, using the
    new video preset mpeg2hd422p.m2ts and existing audio preset
    bluray_lpcm.m2ts, and yes, they seemingly work ok:<br>
    <br>
    cin<br>
    Cinelerra Infinity - built: May 18 2025 05:16:5<br>
    ...........<br>
    Shift-P preferences as previously<br>
    r(ecord)<br>
    <br>
    DeviceV4L2Base::v4l2_open pixels="YUYV"; res="1920x1080 1600x1200
    1360x768 1280x1024 1280x960 1280x720 1024x768 800x600 720x576
    720x480 640x480"<br>
    v4l2 s_fmt 1920x1080 YUYV<br>
    DeviceV4L2Base::v4l2_open VIDIOC_S_STD: Inappropriate ioctl for
    device<br>
    audio0 pad 16 0 (16)<br>
    ----------<br>
    <br>
    ffprobe -hide_banner mpeg2hd422p.m2ts<br>
    Input #0, mpegts, from 'mpeg2hd422p.m2ts':<br>
      Duration: 00:01:14.84, start: 0.020000, bitrate: 39006 kb/s<br>
      Program 1<br>
      Stream #0:0[0x1011]: Video: mpeg2video (High) ([2][0][0][0] /
    0x0002), yuv422p(tv, bt709/unknown/unknown, progressive), 1920x1080
    [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn<br>
          Side data:<br>
            cpb: bitrate max/min/avg: 35000000/0/0 buffer size: 38010880
    vbv_delay: N/A<br>
      Stream #0:1[0x1100](eng): Audio: pcm_bluray ([128][0][0][0] /
    0x0080), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s<br>
    <br>
    Playback ok with vlc and ffplay<br>
    ----------<br>
    <br>
    The next question;<br>
    Is segmented recording ready to use here, possibly how?<br>
    <br>
    <br>
    <br>
     <br>
  </div>

-- <br>
Cin mailing list<br>
<a href="mailto:Cin@lists.cinelerra-gg.org" target="_blank">Cin@lists.cinelerra-gg.org</a><br>
<a href="https://lists.cinelerra-gg.org/mailman/listinfo/cin" rel="noreferrer" target="_blank">https://lists.cinelerra-gg.org/mailman/listinfo/cin</a><br>
</blockquote></div>