My goal is to take a modern file (e.g., 1920x1080 H.264) and output a 720x480 DV NTSC MJPEG A YUVJ422P8 Interlaced file (TFF).
I would have assumed the following call to work,
However, it doesn't. FFMPEG errors stating MJPEG does not support interlacing, yet it does.Code:ffmpeg -y -i file.mkv -map 0:v:0 -pix_fmt yuvj422p -r 30000/1001 -vf "scale=720:480,setfield=tff" -c:v mjpeg -q:v 0 -flags +ilme+ildct mjpeg_interlaced.mov
It seems like MJPEG supports interlacing by simply attaching two JPEG files as one frame.
So e.g., Frame A will contain 2x JPEG headers, one being the upper field, the other being the lower field.
I urgently need to "age" my files for a specific reason. It must be interlaced.
An example interlaced MJPEG MOV has been attached.
+ Reply to Thread
Results 1 to 10 of 10
-
-
You need -top 0 to toggle BFF mjpeg encoding
If your input file.mkv was interlaced, you need interlaced scaling flags, or you'll get downscaling chroma errors (progressive downscale)
Code:-vf "scale=720:480:interl=1"
-
If your input file was interlaced (1920x1080i29.97) , it will usually be TFF by convention since 99.99% of HD will be TFF. So you'd likely use -top 1
But most SD NTSC was BFF (but it can be TFF too) . Bride Footage.mov is BFF. Not sure if it matters for your situation, but you'd have to swap field order -
-
-top 0 is for toggling the mjpeg interlaced encoding. ie. If your input to the mjpeg encoder is interlaced content
If you have progressive content, then you have to convert progressive content to interlaced content. You need to start with 59.94p. ie. 1920x1080p59.94 to 720x480i29.97 . With progressive FHD source, you can use progressive scaling to SD. Normally it would be lowpassed (essentially vertically blurred) in the preparation, because interlace doesn't handle fine details very well (intertwine twitter). Also, a colormatrix shift from 709 to 601 is standard procedure (HD to SD)
It would look similar to this
Code:ffmpeg -i input.ext -vf zscale=w=720:h=480:min=709:m=170m,format=yuv422p,tinterlace=5:flags=vlpf -top 0 -c:v mjpeg -q:v 2 -aspect 16/9 output.mov
-
Not sure if MJPEG (at least in ffmpeg) support interlace encoding - seem there is no '-alternate_scan' available in mjpeg so your encoding will suffer from field spectral leak, from same reason flag 'ildct' is also highly recommended - normally i would say split fields and encode them independently but not sure what is your goal - if artifacts are desired then it may work for you. Instead activating vertical low pass filter you may think on reducing bandwidth in vertical direction of your progressive source before interlacing. Interline flicker is annoying mostly for highly contrast and static/low motion content. For my taste ffmpeg implemented vertical lowpass filter is quite crude so i never use it.
-
Mjpeg is a loosely structured format so not all implementations are capable of the same features and there could be compatibility issues. I do remember that the mjpeg as generated in old QuickTime was capable of, and defaulted to, interlaced encoding, since that was standard in those days. However, my recollection is that they were also primarily 4:2:0 color, so I don't know if that helps you.
If you want to go that route, I suggest a suitable machine with QT 7pro on it (PC or Mac, depending on your workflow), not connected to the network (since QT was long ago revealed to have some vulnerability). QT mjpeg can do brute force interlacing, but my recommendation is that you do 2 steps: 1st to size to standard SD and interlaced, while still using /uncompressed lossless compression, and 2nd to specifically encode to mjpeg. Then you can have control over the sizing & interlacing methods using more tools.
Scott -
Sorry for the long delay between an update.
Assuming the source is already fully interlaced (TFF) and SD, I can do the following to seemingly get an interlaced MJPEG BFF stream:
Code:ffmpeg -y -i source.mpeg -pix_fmt yuvj422p -c:v mjpeg -top 0 -q:v 0 mjpeg_interlaced.mp4
Code:[swscaler @ 000001e631373e40] [swscaler @ 000001e631380e00] deprecated pixel format used, make sure you did set range correctly
It's incredibly picky about import format. It seems specifically `mpg` not even `mpeg` or such must be used (maybe only 3-char file extensions are supported) and mp4 is not supported.
I get the same warning above, as well as this one when outputting to `mpg`
Code:[mpeg @ 000001b8d13a54c0] VBV buffer size not set, using default size of 230KB If you want the mpeg file to be compliant to some specification Like DVD, VCD or others, make sure you set the correct buffer size
Code:$ mpv .\mjpeg_interlaced.mpg [ffmpeg/demuxer] mpeg: probed stream 0 failed [ffmpeg/demuxer] mpeg: Could not find codec parameters for stream 0 (Video: none, none): unknown codec [ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options (+) Video --vid=1 ( 25.000fps) Failed to initialize a decoder for codec ''. Video: no video No video or audio streams selected. Exiting... (Errors when loading file)
Code:General Complete name : ...\mjpeg_interlaced.mpg Format : MPEG-PS File size : 2.16 GiB
If I specify a -maxrate and -bufsize, I then get the following buffer underflow errors happening in the mpeg code:
[Attachment 70375 - Click to enlarge]Last edited by PRAGMA; 15th Apr 2023 at 03:58.
-
The sample is "MOV", not "MPG" . MJPEG in MPG is rare . If MOV does not work (you might need old quicktime installed) , then AVI container should work
The "depreciated pixel format" warning is there because they are eventually removing the "j" formats for denoting full range (yuvj422p) . It will be done differently in the future. You can ignore it for now -
IIRC the old Premiere had a bundled mjpeg decoder for VFW (AVI) in default install. But if it does not you can try old x86 version of ffdshow . The old VFW system codecs worked in old Premiere
I think cineform should work too, but you might need to find an old version of x86 cineform (Premiere 6 dates before gopro took over cineform)
Another option is to frameserve in, such as avfs . The vapoursynth version has fourcc emulation for UYVY and v210, and it works on just about every windows NLE and they also get treated as YUV
Similar Threads
-
[FFmpeg+SvtAv1] convert a H264 or H265 1080p file to Av1 720p
By ignace72 in forum Video ConversionReplies: 11Last Post: 29th Mar 2022, 16:16 -
how to force ffmpeg to encode mpeg2 interlaced ?
By hydra3333 in forum Video ConversionReplies: 19Last Post: 25th Jun 2021, 07:22 -
FFMPEG - Convert M2TS file to MP4 or M4V while retaining TrueHD + AC3
By DavidFVancouver in forum Newbie / General discussionsReplies: 1Last Post: 7th Feb 2021, 04:48 -
ffmpeg changes interlaced to progressive
By SF01 in forum Video ConversionReplies: 12Last Post: 30th Mar 2020, 09:51 -
FFmpeg does not convert file through command line
By Vidikon in forum Newbie / General discussionsReplies: 2Last Post: 5th Jun 2019, 02:13