Encoding interlaced content: what am I doing wrong?
Good afternoon, Currently I'm busy transcoding Hi8 video to DVDs. I've already done 2 tapes, using pp=fd as deinterlacer, but very recently I discovered what interlacing is exactly, and I'm convinced I should try keep the interlacing, so I'm adjusting my toolchain. First I capture the video with mencoder piped to x264 (just for --preset and --tune setting convenience) and arecord to capture sound in 24-bit format, then amplify it, turn it to 16-bit and merge it into a .mkv file. So far so good, this is quite easy to keep interlaced, just pass --interlaced to x264. I'm looking which settings to use to encode interlaced material, but some of my tests seem to fail. I used this command to generate a file test.mpg mencoder -edl tape3.edl -hr-edl-seek tape3.mkv -vf crop=686:560:16:4,scale,expand=720:576:16:0 -nosound -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:turbo:vpass=1:ilme:ildct:vstrict=0:threads=2:vbitrate=5800:keyint=15 -of mpeg -mpegopts format=dvd:tsaf -o test.mpg So, as you can see, I'm messing around getting the first pass right. (Second pass shouldn't be a problem) The resulting video is clearly interlaced, it works when played with mplayer with -vf pp=fd, but when using -vf tfields=0:0,scale the framerate doesn't double (or, when played at 0.25x, motion isn't that smooth) while it does when I try at tape3.mkv, the original capture. What am I doing wrong? I suspect there's something wrong with the container, the video not being marked as deinterlaced or something...? Or is my test method wrong and is this encode fine? Thanks in advance! Kind regards, Martijn van Beurden
Good afternoon, I don't know whether or not this is the right way to reply on my own message, so I hope it works well :) I just muxed the file into an mkv file with mkvmerge test.mpg -o test.mkv, now -vf tfields=0:0,scale works again, while mkvinfo returns Interlaced: 0. (how do I set that to 1 anyway? My original capture is interlaced: 0 too, I can't find an option to set this right) So, what's going on, or is this a bug (or a missing feature?) in MPlayer, tfields working with mkv but not with mpg? Martijn van Beurden schreef:
Good afternoon,
Currently I'm busy transcoding Hi8 video to DVDs. I've already done 2 tapes, using pp=fd as deinterlacer, but very recently I discovered what interlacing is exactly, and I'm convinced I should try keep the interlacing, so I'm adjusting my toolchain.
First I capture the video with mencoder piped to x264 (just for --preset and --tune setting convenience) and arecord to capture sound in 24-bit format, then amplify it, turn it to 16-bit and merge it into a .mkv file. So far so good, this is quite easy to keep interlaced, just pass --interlaced to x264.
I'm looking which settings to use to encode interlaced material, but some of my tests seem to fail. I used this command to generate a file test.mpg mencoder -edl tape3.edl -hr-edl-seek tape3.mkv -vf crop=686:560:16:4,scale,expand=720:576:16:0 -nosound -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:turbo:vpass=1:ilme:ildct:vstrict=0:threads=2:vbitrate=5800:keyint=15
-of mpeg -mpegopts format=dvd:tsaf -o test.mpg
So, as you can see, I'm messing around getting the first pass right. (Second pass shouldn't be a problem) The resulting video is clearly interlaced, it works when played with mplayer with -vf pp=fd, but when using -vf tfields=0:0,scale the framerate doesn't double (or, when played at 0.25x, motion isn't that smooth) while it does when I try at tape3.mkv, the original capture. What am I doing wrong? I suspect there's something wrong with the container, the video not being marked as deinterlaced or something...? Or is my test method wrong and is this encode fine?
Thanks in advance!
Kind regards, Martijn van Beurden
Martijn van Beurden wrote:
Good afternoon,
Currently I'm busy transcoding Hi8 video to DVDs. I've already done 2 tapes, using pp=fd as deinterlacer, but very recently I discovered what interlacing is exactly, and I'm convinced I should try keep the interlacing, so I'm adjusting my toolchain.
First I capture the video with mencoder piped to x264 (just for --preset and --tune setting convenience) and arecord to capture sound in 24-bit format, then amplify it, turn it to 16-bit and merge it into a .mkv file. So far so good, this is quite easy to keep interlaced, just pass --interlaced to x264.
I'm looking which settings to use to encode interlaced material, but some of my tests seem to fail. I used this command to generate a file test.mpg mencoder -edl tape3.edl -hr-edl-seek tape3.mkv -vf crop=686:560:16:4,scale,expand=720:576:16:0 -nosound -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:turbo:vpass=1:ilme:ildct:vstrict=0:threads=2:vbitrate=5800:keyint=15
-of mpeg -mpegopts format=dvd:tsaf -o test.mpg
So, as you can see, I'm messing around getting the first pass right. (Second pass shouldn't be a problem) The resulting video is clearly interlaced, it works when played with mplayer with -vf pp=fd, but when using -vf tfields=0:0,scale the framerate doesn't double (or, when played at 0.25x, motion isn't that smooth) while it does when I try at tape3.mkv, the original capture. What am I doing wrong? I suspect there's something wrong with the container, the video not being marked as deinterlaced or something...? Or is my test method wrong and is this encode fine? I'm a little confused as to why your material is in an .mkv container to begin with. Why wouldn't you directly capture the Hi8 video into an MPEG2 file?
Because I try to keep as much quality as I can get, and as x264 is far superior to MPEG2, I capture to x264. Then I write an EDL file to cut out snow and bad scenes and the like, and then convert it to MPEG-2 in 2 passes. x264 had something called constant rate factor which encodes based on scene complexity instead of just targeting a bitrate. So, first encode to x264, then to MPEG-2 in slower-then-realtime and 2 passes. James Hastings-Trew schreef:
Martijn van Beurden wrote:
Good afternoon,
Currently I'm busy transcoding Hi8 video to DVDs. I've already done 2 tapes, using pp=fd as deinterlacer, but very recently I discovered what interlacing is exactly, and I'm convinced I should try keep the interlacing, so I'm adjusting my toolchain.
First I capture the video with mencoder piped to x264 (just for --preset and --tune setting convenience) and arecord to capture sound in 24-bit format, then amplify it, turn it to 16-bit and merge it into a .mkv file. So far so good, this is quite easy to keep interlaced, just pass --interlaced to x264.
I'm looking which settings to use to encode interlaced material, but some of my tests seem to fail. I used this command to generate a file test.mpg mencoder -edl tape3.edl -hr-edl-seek tape3.mkv -vf crop=686:560:16:4,scale,expand=720:576:16:0 -nosound -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:turbo:vpass=1:ilme:ildct:vstrict=0:threads=2:vbitrate=5800:keyint=15
-of mpeg -mpegopts format=dvd:tsaf -o test.mpg
So, as you can see, I'm messing around getting the first pass right. (Second pass shouldn't be a problem) The resulting video is clearly interlaced, it works when played with mplayer with -vf pp=fd, but when using -vf tfields=0:0,scale the framerate doesn't double (or, when played at 0.25x, motion isn't that smooth) while it does when I try at tape3.mkv, the original capture. What am I doing wrong? I suspect there's something wrong with the container, the video not being marked as deinterlaced or something...? Or is my test method wrong and is this encode fine? I'm a little confused as to why your material is in an .mkv container to begin with. Why wouldn't you directly capture the Hi8 video into an MPEG2 file?
MEncoder-users mailing list MEncoder-users@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/mencoder-users
On Wed, 27 Jan 2010 15:29:49 +0100 Martijn van Beurden <mvanb1@gmail.com> wrote:
Because I try to keep as much quality as I can get, and as x264 is far superior to MPEG2, I capture to x264. Then I write an EDL file to cut out snow and bad scenes and the like, and then convert it to MPEG-2 in 2 passes.
This demonstrates a complete misunderstanding of video encoding. In short, going from one codec to another will lose more quality than not, and the only benefit to newer codecs like x264 is in squeezing slightly higher quality out of slightly smaller files, at the expense of lots of CPU time. At high bitrates, H.264 has nothing special to offer. -- Ha. I'm the idiot.
In short, going from one codec to another will lose more quality than not, and the only benefit to newer codecs like x264 is in squeezing slightly higher quality out of slightly smaller files, at the expense of lots of CPU time. At high bitrates, H.264 has nothing special to offer.
But going from MPEG-2 to MPEG-2 is losing quality too, not? Going in two steps is AFAIK the only way to use an EDL. And I thought because x.264 has the possibility to encode on quality instead of bitrate (I'm using --crf 15) that would result in big but quite good files.
In short, going from one codec to another will lose more quality than not, and the only benefit to newer codecs like x264 is in squeezing slightly higher quality out of slightly smaller files, at the expense of lots of CPU time. At high bitrates, H.264 has nothing special to offer.
But going from MPEG-2 to MPEG-2 is losing quality too, not? Going in two steps is AFAIK the only way to use an EDL. And I thought because x.264 has the possibility to encode on quality instead of bitrate (I'm using --crf 15) that would result in big but quite good files.
Re-encoding video will always lose quality, but if you're encoding from a
high quality source, then the result will look better than if you encoded from a low quality source - obviously. Going from a high quality x264 to a high quality mpeg-2 will probably visually look fine. Technically though, quality loss occurs. But just understand that choosing a codec isn't about quality, it should be about whether a certain codec is required (i.e. mpeg-2 for DVD, h.264 for blu-ray), getting the most bang (quality) for the buck (bitrate), decoding requirements (i.e. cpu), and encoding requirements (cpu, time, etc.). My point is, you can have an mpeg-2 file be just as high of quality as a "-crf 15" x264 file...it will just be a larger bitrate generally. So your codec choice should be based on what you want/need to do given everything you know about your codec candidates. If you need an mpeg-2 file in the end, then just capture an mpeg-2 file from the get go :-)
Hi, On Thu, Jan 28, 2010 at 02:16:02 -0500, Jarred Nicholls wrote:
Re-encoding video will always lose quality, but if you're encoding from a high quality source, then the result will look better than if you encoded from a low quality source - obviously. [...] generally. So your codec choice should be based on what you want/need to do given everything you know about your codec candidates. If you need an mpeg-2 file in the end, then just capture an mpeg-2 file from the get go :-)
While that's true, I must pitch in and agree with Martijn's use model: He wants to capture an intermediate file for editing. Optimally, that format would be lossless or a format which allows (mostly) lossless editing in terms of cutting. I have yet to find a lossless format which doesn't consume much space ;-) and/or which is understood well by editing apps. So, that said, I agree (from what I have read and what I have tried) that that intermediate format doesn't need to be H.264. Actually, low CPU cost and high (intermediate) quality are desired. I had actually asked for "close to lossless" MPEG settings here once, for my intermediate captures. You don't want to treak the hell out of a codec, you just want to give it sufficient bandwidth I guess. You could probably even tickle more bandwidth out of MPEG2 that the DVD profiles allow for, if the apps can handle it. By the way, can something like ProjectX (?) not edit MPEG2 without reencoding anything except the cut points? Then the "intermediate" file could ideally be the final format. Moritz
2010. 01. 28, csütörtök keltezéssel 21.19-kor Moritz Barsnick ezt írta:
By the way, can something like ProjectX (?) not edit MPEG2 without reencoding anything except the cut points? Then the "intermediate" file could ideally be the final format.
Yes, dvbcut (I would recommend the svn version, not the outdated "stable" release, even if this latter works well also). I use it routinely for all of my ivtv (MPEG-PS) captures. It only reencodes the frames which are inbetween the cutpoint and an I-frame. If you cut only on I-frames, nothing will be reencoded. Additionally if you capture without P and B frames (I-frames only), you can cut where you want without being forced to reencode. Levente
On Thu, Jan 28, 2010 at 09:19:49PM +0100, you wrote:
By the way, can something like ProjectX (?) not edit MPEG2 without reencoding anything except the cut points? Then the "intermediate" file could ideally be the final format.
ProjectX will only cut at I-frames (but you're right, it doesn't re-encode). imc
On Thu, Jan 28, 2010 at 09:19:49PM +0100, Moritz Barsnick wrote:
By the way, can something like ProjectX (?) not edit MPEG2 without reencoding anything except the cut points? Then the "intermediate" file could ideally be the final format.
You can try avidemux, with the "smartcopy" mode. This is far from perfect, but will allow you to cut a file frame-accurately, reencoding only the needed part.
On Thu, Jan 28, 2010 at 07:52:24AM +0100, Martijn van Beurden wrote:
In short, going from one codec to another will lose more quality than not, and the only benefit to newer codecs like x264 is in squeezing slightly higher quality out of slightly smaller files, at the expense of lots of CPU time. At high bitrates, H.264 has nothing special to offer.
But going from MPEG-2 to MPEG-2 is losing quality too, not? Going in two steps is AFAIK the only way to use an EDL. And I thought because x.264 has the possibility to encode on quality instead of bitrate (I'm using --crf 15) that would result in big but quite good files.
If you want good quality but size does not matter (much), you can use any other codec with vqscale=2 just as well. CRF is only an advantage over (v)qscale if you are going for a final encode.
On Thu, 28 Jan 2010 07:52:24 +0100 Martijn van Beurden <mvanb1@gmail.com> wrote:
But going from MPEG-2 to MPEG-2 is losing quality too, not?
Not as much, certainly, because x264 is going to throw away different amounts of different bits of information than lavc MPEG-2 would/does (different quantizer). There would be similar issues if you switched back and forth between, say, Xvid and lavc MPEG-4 for no good reason...
(I'm using --crf 15) that would result in big but quite good files.
If you can live with slightly larger intermediate files, you can get equally good, if not better quality from MPEG-2. -- Ha. I'm the idiot.
participants (9)
-
Etienne Buira -
Ian Collier -
James Hastings-Trew -
Jarred Nicholls -
Levente Novák -
Martijn van Beurden -
Moritz Barsnick -
RC -
Reimar Döffinger