VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. 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,
    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
    However, it doesn't. FFMPEG errors stating MJPEG does not support interlacing, yet it does.
    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.
    Image Attached Files
    Quote Quote  
  2. 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"
    Don't forget to add -aspect 4/3 or 16/9 (probably 16/9 if you're starting with 1920x1080)
    Quote Quote  
  3. 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
    Quote Quote  
  4. Originally Posted by poisondeathray View Post
    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"
    Don't forget to add -aspect 4/3 or 16/9 (probably 16/9 if you're starting with 1920x1080)
    The source is progressive, but using -top 0 doesn't seem to do anything at all. The output is just progressive.
    Quote Quote  
  5. Originally Posted by PRAGMA View Post
    Originally Posted by poisondeathray View Post
    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"
    Don't forget to add -aspect 4/3 or 16/9 (probably 16/9 if you're starting with 1920x1080)
    The source is progressive, but using -top 0 doesn't seem to do anything at all. The output is just progressive.

    -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
    Quote Quote  
  6. 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.
    Quote Quote  
  7. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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
    Quote Quote  
  8. 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
    However, the following warnings are produced by ffmpeg like 50 times prior to the output progress:

    Code:
    [swscaler @ 000001e631373e40] [swscaler @ 000001e631380e00] deprecated pixel format used, make sure you did set range correctly
    And I'm unable to output to `mpg` container to match the sample BFF I provided. I intend to use these explicitly on Adobe Premiere 6 (yes, the old one from like 2000).
    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
    The output file crashes in MPV:

    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)
    And MediaInfo results in no information read:

    Code:
    General
    Complete name                            : ...\mjpeg_interlaced.mpg
    Format                                   : MPEG-PS
    File size                                : 2.16 GiB
    The output mp4 works fine, but cannot be used in Premiere 6 which is my goal from the beginning.

    If I specify a -maxrate and -bufsize, I then get the following buffer underflow errors happening in the mpeg code:

    Image
    [Attachment 70375 - Click to enlarge]
    Last edited by PRAGMA; 15th Apr 2023 at 04:58.
    Quote Quote  
  9. 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
    Quote Quote  
  10. 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
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!