[Cin] mpeg2hd422p.m2ts - groundwork for a high-end preset

Terje J. Hanssen terjejhanssen at gmail.com
Sun Jun 8 17:25:24 CEST 2025



Den 06.06.2025 14:17, skrev Terje J. Hanssen:
> While the newer h.264 and hevc are known for best compression, mpeg2 
> may have better quality at video bitrate > 30Mbps
>
> 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
> -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
>
> mpeg2video is difficult to get quit perfect with ffmpeg; muxing 
> overhead: 6.206455% is the minimum I have achieved as in this case.
>
> 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.
>
>
> 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
>
> Input #0, video4linux2,v4l2, from '/dev/video0':
>   Duration: N/A, start: 79.422429, bitrate: 1658880 kb/s
>   Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 
> 1920x1080, 1658880 kb/s, 50 fps, 50 tbr, 1000k tbn
> [aist#1:0/pcm_s16le @ 0x55e2664e95c0] Guessed Channel Layout: stereo
> Input #1, alsa, from 'hw:CARD=UHD,DEV=0':
>   Duration: N/A, start: 1749208971.359170, bitrate: 1536 kb/s
>   Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Stream mapping:
>   Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
>   Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_bluray (native))
> Press [q] to stop, [?] for help
> [mpeg2video @ 0x55e2664d0500] Warning vbv_delay will be set to 0xFFFF 
> (=VBR) as the specified vbv buffer is too large for the given bitrate!
>
> Output #0, mpegts, to 'mpeg2hd422p_35M.m2ts':
>   Metadata:
>     encoder         : Lavf61.7.100
>   Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, progressive), 
> 1920x1080, q=2-31, 35000 kb/s, 50 fps, 90k tbn
>       Metadata:
>         encoder         : Lavc61.19.101 mpeg2video
>       Side data:
>         cpb: bitrate max/min/avg: 35000000/35000000/35000000 buffer 
> size: 38000000 vbv_delay: N/A
>   Stream #0:1: Audio: pcm_bluray, 48000 Hz, stereo, s16, 128 kb/s
>       Metadata:
>         encoder         : Lavc61.19.101 pcm_bluray
> [out#0/mpegts @ 0x55e2664e9740] video:128445KiB audio:5648KiB 
> subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 
> 6.206455%
>
> frame= 1500 fps= 50 q=3.5 Lsize=  142416KiB time=00:00:29.98 
> bitrate=38915.0kbits/s speed=0.998x
>

I have been able to tune the ffmpeg specifications further:

  * '-profile:v 422p -level:v high' (for mpeg-2 profile 422P at HL)
  * '--ch_layout stereo' (as a replacement for  '-ac 2' that caused
    'Guessed Channel Layout: stereo')


And also verified the camera HDMI out 'raw video' and 'raw audio' (pcm) 
using just the ffmpeg input parts:

ffmpeg -hide_banner -f v4l2 -framerate 50 -i /dev/video0 -f alsa 
-ch_layout stereo -i hw:CARD=UHD,DEV=0

Input #0, video4linux2,v4l2, from '/dev/video0':
   Duration: N/A, start: 191.096360, bitrate: 1658880 kb/s
   Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 
1658880 kb/s, 50 fps, 50 tbr, 1000k tbn
Input #1, alsa, from 'hw:CARD=UHD,DEV=0':
   Duration: N/A, start: 1749375770.007003, bitrate: 1536 kb/s
   Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s


Attached here  is a full ffmpeg debug log file for verification (command 
below)

  * mpeg2hd422p_35M.log.gz


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

-----------

Among CinGG's existing m2ts presets

cd /Leap_root/usr/share/cin/ffmpeg/video

ls -1 *m2ts

  * avc422.m2ts
  * bluray_bff.m2ts
  * bluray_dv_ntsc.m2ts
  * bluray_dv_pal.m2ts
  * bluray_fakeinterlace.m2ts
  * bluray_lo.m2ts
  * bluray.m2ts
  * bluray_tff.m2ts
  * hevc422p10.m2ts
  * hevc422p8.m2ts
  * lossless.m2ts
  * visually_lossless.m2ts


grep mpeg2video *m2ts

  * That is none so far for mpeg2video HD and 422p


If this preset can be specified and supplemented (?) for use with 
pcm_bluray and segmented recording, I can test it next ;)











-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20250608/45509b0c/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpeg2hd422p_35M.log.gz
Type: application/gzip
Size: 119396 bytes
Desc: not available
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20250608/45509b0c/attachment-0001.bin>


More information about the Cin mailing list