I am trying to save some camcorder footage as rawvideo.
The original footage is YUV 4:2:0 h.264. When I change the following code in “other” from
mlt_image_format=yuv422p
to
mlt_image_format=yuv420p
the video appears as scrambled eggs, i.e. not a usable image. The 4:2:2 export looks fine.
My thinking is to avoid as much resampling as possible and to have the encoder pass the 4:2:0 video without modification (and without using a “lossless” codec).
yuv420p is not a valid render target in MLT if any effects (filters, transitions, track compositing) are involved. As long as you do not use Filters or Timeline, you can do this. But depending on how you export you probably need to specify additional info to ffmpeg. For example, to save as AVI this works:
There shouldn’t be a need to change the internal processing mode of Shotcut with the mlt_image_format line. If implemented correctly end-to-end, doing nearest neighbor scaling from 4:2:0 sources to 4:2:2 internal processing then to 4:2:0 for export should be lossless. The options that need to be set are:
Export > Advanced > Video > Interpolation > Nearest neighbor
Export > Advanced > Other > pix_fmt=yuv420p
This assumes that the in and out resolutions are the same, meaning only the chroma plane is getting scaled. When the chroma plane is doubled then halved, we end up right back where we were. This is why bicubic or other scaling methods would break the lossless nature of chroma scaling and cannot be used for this purpose. They have spline extrapolation that will cause bleed across pixel borders instead of the mathematically-precise double-and-half approach to scaling that nearest neighbor does.
I tried my raw export again with “nearest neighbor” and the following in “other”. It still comes out as 4:2:2. This was using the current beta version.
It imports back into shotcut correctly and other programs, media players.
It might be that whatever program you are using cannot read fourcc I420. There are slightly different 8bit 4:2:0 configurations in terms of arrangements of how the data is stored. For example, “YV12”, “NV12”, “IYUV” are all 8bit 4:2:0 but just arranged slightly differently .
No scrambled eggs. Works ok here as expected, all players MPC,VLC,WMP. AVC 4:2:0 source, uncompressed 4:2:0 output in I420 configuration. No filters, just drop on timeline and export .
My export settings are the same as PDR except without the mlt_image_format specifier and with nearest neighbor interpolation. This lets me throw on titles, filters, etc and export a finished project with the least amount of loss possible within Shotcut (for full projects, not single-file transcoding that might be better served with CLI FFmpeg). The resulting file from Shotcut is showing 4:2:0 like PDR’s.
chris319, what happens if you bring your exported video back into Shotcut and look at the Properties tab there? Does it also say yuv422p like the media players?