Maccara
3rd May 2008, 15:19
Hi,
I'm having slight difficulties achieving a compatible interlaced encoding which would play back correctly using CoreAVC, so I would appreciate any help (especially if you've managed to successfully do this).
I have tried to read threads regarding interlaced encoding, but they didn't give me an answer.
I know I can "mcbob" the videos too, but I don't like the increase in bitrate requirements for encoding and it is a bit slow, and deint to 25fps is not an option, as this is high motion video and screws up the results completely (yes, I tried, and didn't like the loss of temporal resolution).
So, please, don't waste time trying to suggest solutions how to deint/bob before encoding (I already know how to do that) - I'm only interested in getting interlaced encoding to work and only resort to those other options if interlaced encoding is not possible for some reason.
Now, first things first, I have a DV AVI (VHS captures), which is true interlaced bottom field first video (PAL 25i) for which I do some intermediate filtering / processing (yes, I know the caveats for interlaced filtering/processing) and store as ffdshow-huffyuv (YV12) intermediate file.
I have tested, that I can encode this intermediate file for example with HCEnc to MPEG2 stream (just specified "interlaced" & "bff") which plays back perfectly.
I have also tested, that true interlaced stream (in .TS) plays back as it should with CoreAVC 1.7 (HW deinterlacing) + Haali Renderer as 50fps and looks good, so the decoding itself is not a problem either in itself.
The problem is, that I'm unsuccessful in creating an interlaced x264 encoded, muxed to mp4 container, video which would play back ok. I'm suspecting I'm doing something "bad" either encoding or muxing.
The issues with playback are: CoreAVC does not seem to recognize the video as interlaced and does not enable deinterlacing (tried all options), FFDShow recognizes as interlaced, but gets the field order wrong.
I can "fix" FFDShow by switching the fieldorder in avisynth, but I do not want to use ffdshow at all, so not interested in this solution, even though it "works". The reason is, that I do not want to change codec each time I play a different file (ffdshow is not able to play HD material on my hardware but coreacv does it "just", thanks to frame based threading). AND even though I can fix this this way, I suspect the stream isn't really compliant, so I can't be sure if it will continue to work in ffdshow either down the road.
It seems as if x264 does not set the fieldorder, so when ffdshow gets just mbaff=1, it assumes TFF, and coreavc doesn't want to recognize as interlaced without proper fieldorder information.
Avinaptic also shows mbaff=1 in the stream, but I don't see any options regarding fieldorder.
Now, I mainly use megui for encoding, but frequently change the commandline options to suite the needs, so this is one (unsuccessfull) example cmdline (from megui config):
--crf 24.0 --ref 5 --mixed-refs --bframes 16 --b-pyramid --b-rdo --bime --weightb --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4
--8x8dct --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input" --sar 12:11 --bff
I also tried to enable "interlaced" encoding in mgeui UI, in case something different happens (but it just used --interlaced cmdline, which is TFF) and also manually --interlaced, --tff, --bff.
All options seem to set mbaff=1 ok, so they're recognized options.
x264 versions I tried:
x264.826.modified.exe (x264 core:59 r826M 138601d)
x264.exe (x264 core:59 r808M ff5059a)
x264.839.modified.experimental.2.exe (x264 core:59)
(the last one I tested specifically, because it said it includes "nalhrd patches + interlaced patch", and that patch should enable the SEI info for fieldorder, but I couldn't see it in the resulting stream still)
It seems I got carried away while explaining the background (I was composing my thoughts "on-the-fly"), so sorry about that one, and thanks if you had time to read all that. :)
To summarize:
What are stream requirements to get CoreACV to recognize the stream as interlaced, and is x264 able to produce such a stream?
Furthermore, am I doing something incorrectly, or is there a bug in CoreAVC or x264? (inclined to point the finger at this point to x264, as ffdshow couldn't do correct playback either and I don't see fieldorder mentioned in avinaptic - although I'm not sure if it should)
How can I debug this further to find the cause & solution?
I'm having slight difficulties achieving a compatible interlaced encoding which would play back correctly using CoreAVC, so I would appreciate any help (especially if you've managed to successfully do this).
I have tried to read threads regarding interlaced encoding, but they didn't give me an answer.
I know I can "mcbob" the videos too, but I don't like the increase in bitrate requirements for encoding and it is a bit slow, and deint to 25fps is not an option, as this is high motion video and screws up the results completely (yes, I tried, and didn't like the loss of temporal resolution).
So, please, don't waste time trying to suggest solutions how to deint/bob before encoding (I already know how to do that) - I'm only interested in getting interlaced encoding to work and only resort to those other options if interlaced encoding is not possible for some reason.
Now, first things first, I have a DV AVI (VHS captures), which is true interlaced bottom field first video (PAL 25i) for which I do some intermediate filtering / processing (yes, I know the caveats for interlaced filtering/processing) and store as ffdshow-huffyuv (YV12) intermediate file.
I have tested, that I can encode this intermediate file for example with HCEnc to MPEG2 stream (just specified "interlaced" & "bff") which plays back perfectly.
I have also tested, that true interlaced stream (in .TS) plays back as it should with CoreAVC 1.7 (HW deinterlacing) + Haali Renderer as 50fps and looks good, so the decoding itself is not a problem either in itself.
The problem is, that I'm unsuccessful in creating an interlaced x264 encoded, muxed to mp4 container, video which would play back ok. I'm suspecting I'm doing something "bad" either encoding or muxing.
The issues with playback are: CoreAVC does not seem to recognize the video as interlaced and does not enable deinterlacing (tried all options), FFDShow recognizes as interlaced, but gets the field order wrong.
I can "fix" FFDShow by switching the fieldorder in avisynth, but I do not want to use ffdshow at all, so not interested in this solution, even though it "works". The reason is, that I do not want to change codec each time I play a different file (ffdshow is not able to play HD material on my hardware but coreacv does it "just", thanks to frame based threading). AND even though I can fix this this way, I suspect the stream isn't really compliant, so I can't be sure if it will continue to work in ffdshow either down the road.
It seems as if x264 does not set the fieldorder, so when ffdshow gets just mbaff=1, it assumes TFF, and coreavc doesn't want to recognize as interlaced without proper fieldorder information.
Avinaptic also shows mbaff=1 in the stream, but I don't see any options regarding fieldorder.
Now, I mainly use megui for encoding, but frequently change the commandline options to suite the needs, so this is one (unsuccessfull) example cmdline (from megui config):
--crf 24.0 --ref 5 --mixed-refs --bframes 16 --b-pyramid --b-rdo --bime --weightb --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4
--8x8dct --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input" --sar 12:11 --bff
I also tried to enable "interlaced" encoding in mgeui UI, in case something different happens (but it just used --interlaced cmdline, which is TFF) and also manually --interlaced, --tff, --bff.
All options seem to set mbaff=1 ok, so they're recognized options.
x264 versions I tried:
x264.826.modified.exe (x264 core:59 r826M 138601d)
x264.exe (x264 core:59 r808M ff5059a)
x264.839.modified.experimental.2.exe (x264 core:59)
(the last one I tested specifically, because it said it includes "nalhrd patches + interlaced patch", and that patch should enable the SEI info for fieldorder, but I couldn't see it in the resulting stream still)
It seems I got carried away while explaining the background (I was composing my thoughts "on-the-fly"), so sorry about that one, and thanks if you had time to read all that. :)
To summarize:
What are stream requirements to get CoreACV to recognize the stream as interlaced, and is x264 able to produce such a stream?
Furthermore, am I doing something incorrectly, or is there a bug in CoreAVC or x264? (inclined to point the finger at this point to x264, as ffdshow couldn't do correct playback either and I don't see fieldorder mentioned in avinaptic - although I'm not sure if it should)
How can I debug this further to find the cause & solution?