Log in

View Full Version : How to create interlaced output when decoding with mencoder/ffmpeg and piping to x264


Selur
8th May 2009, 12:50
I'd like to read progressive input through mencoder (and ffmpeg), filter it and pipe it as raw to x264.

Does someone know how to do this?

Decoding interlaced material, filter it, send it to x264 and create interlaced output works.

Here's how I do it:
Input:
> Format: MPEG Video
> Bitrate: 2 426 kBit/s
> Frame rate: 25.000
> Width: 544
> Height: 576
> Interlace mode: TFF
> PAR: 1.411
> Frame count: 499
> Duration: 00:00:20.040


FFmpeg:
ffmpeg -r 25 -i "test.mpg" -v 0 -vcodec rawvideo -s 704x576 -padleft 8 -padright 8 -vsync 0 -an -r 25 -pix_fmt yuv420p -f rawvideo - | x264 --crf 18 --level 4 --ref 1 --keyint 50 --min-keyint 25 --interlaced --partitions i4x4,p8x8,b8x8 --me hex --merange 16 --subme 5 --8x8dct --no-fast-pskip --aq-mode 0 --vbv-maxrate 25000 --vbv-bufsize 30000 --aud --nal-hrd --threads auto --sar 12:11 --no-psnr --no-ssim --progress --fps 25 --output "test.mp4" - 720x576Mencoder:
mencoder "test.mpg" -really-quiet -ovc raw -noskip -lavcopts threads=1 -lavdopts threads=1 -mc 0 -nosound -vf scale=704:576,expand=720:576,scale,format=i420 -sws 10 -fps 25 -of rawvideo -o - | x264 --crf 18 --level 4 --ref 1 --keyint 50 --min-keyint 25 --interlaced --partitions i4x4,p8x8,b8x8 --me hex --merange 16 --subme 5 --8x8dct --no-fast-pskip --aq-mode 0 --vbv-maxrate 25000 --vbv-bufsize 30000 --aud --nal-hrd --threads auto --sar 12:11 --no-psnr --no-ssim --progress --fps 25 --output "test.mp4" - 720x576

My problem is, I don't know how to change the mencoder/ffmpeg calls such that I get interlaced output for progressive input.

I looked at the man page of mplayer and ffmpeg but couldn't figure out how to do it, so any hints how to do it with mencoder and ffmpeg is appreciated.

Cu Selur

Ps.: I know the x264 call isn't tweaked at all, it's just for testing. I don't want to use avisynth or another tool.

nm
8th May 2009, 13:08
I'd like to read progressive input through mencoder (and ffmpeg), filter it and pipe it as raw to x264.
What is the type of your progressive input exactly, 576p25 or something else? For 25p, you don't need to change anything in your current pipeline.

Decoding interlaced material, filter it, send it to x264 and create interlaced output works.
Are your interlaced sources always PAL (576i), or do you change the target resolution of the scale filters for sources that have different vertical resolutions?

Selur
8th May 2009, 13:13
What is the type of your progressive input exactly, 576p25 or something else?
would be 576p.
For 25p, you don't need to change anything in your current pipeline.
but when I process 576p material the way I did above I end up with progressive output,...
(playback with mplayer, which doesn't do any deinterlacing doesn't show any interlacing lines)

Are your interlaced sources always PAL (576i), or do you change the target resolution of the scale filters for sources that have different vertical resolutions?
not sure, will cross that bridge when I come to it, atm. I would be happy if 576p (mpeg2) to 576i (avc) would work. :)

Cu Selur

nm
8th May 2009, 13:22
would be 576p.

but when I process 576p material the way I did above I end up with progressive output,...
(playback with mplayer, which doesn't do any deinterlacing doesn't show any interlacing lines)
Sure, that's what you get when encoding 25p as 25i. That's what is done in many PAL DVDs and DVB broadcasts too. You won't see combing because both fields come from the same progressive frame.

You might want to read this thread: http://lists.mplayerhq.hu/pipermail/mencoder-users/2007-August/006677.html

To see combing, you would need to convert 25p to 12.5i, and that would be a very bad idea since there is no such standard. Now, if your source was 50p (with all frames captured at different time positions), you could turn it to 25i and see combing

Selur
8th May 2009, 13:26
doh,.. thanks for clearing that up.