View Full Version : x264, ffmpeg and yuv4mpegpipe...
alec_robertson
31st October 2006, 16:44
I'm trying to convert some dvd's to mp4 and would like to use ffmpeg, mjpegtools and x264. Everything is fine when I use mkfifo pipes:
mkfifo -m 660 dvd.y4m
ffmpeg -i vts_01_0.vob -f yuv4mpegpipe - | y4mscaler -v0 -O size=360x240 > dvd.y4m &
x264 -o dvd1.264 dvd.y4m
However, when I try to tack the x264 on the end of the pipe chain, the resultant dvd2.264 video scrolls horizontally and displays weird color shifts:
ffmpeg -i vts_01_0.vob -f yuv4mpegpipe - | y4mscaler -v0 -O size=360x240 | x264 -o dvd2.264 - 360x240
If I use -f rawvideo, things work fine with x264...
ffmpeg -i vts_01_0.vob -f rawvideo - | x264 -o dvd3.264 - 720x480
...but I can no longer use the mjpegtools (y4mscaler, yuvdeinterlace...) in the pipe chain as they report "Failed to read YUV4MPEG2 header!":
ffmpeg -i vts_01_0.vob -f rawvideo - | y4mscaler -v0 -O size=360x240 | x264 -o dvd4.264 - 360x240
All of the videos are here: http://web.mit.edu/alecr/www/x264/
Any ideas?
DarkZell666
31st October 2006, 16:57
Simply by reading what you've written (I don't know anything about ffmpeg and y4m pipes), I'd suppose that y4mscaler doesn't output to a format x264 expects (ie: YV12).
I believe some switch is missing in the y4mscaler part of the chain (if one indeed exists for that purpose) :)
Edit: it's obvious here that the mkfifo pipe does something what y4mscaler fails to do correctly.
alec_robertson
31st October 2006, 17:22
OK, let's make it even simpler:
This works:
mkfifo -m 660 dvd.y4m
ffmpeg -i vts_01_0.vob -f yuv4mpegpipe - > dvd.y4m &
x264 -o dvd1.264 dvd.y4m
This doesn't:
ffmpeg -i vts_01_0.vob -f yuv4mpegpipe - | x264 -o dvd2.264 - 720x480
Is there a way to get yuv4mpegpipe output from ffmpeg directly into x264 via pipes?
bond
31st October 2006, 19:35
why dont you simply encode in ffmpeg with x264?
alec_robertson
31st October 2006, 20:29
Yeah, I tried doing the last pipe with ffmpeg instead of x264 but ended up with some h264 errors (I don't quite recall the details, but I'll look into it some more).
I'd like to use the yuv4mpegpipe because I quite like yuvdeinterlace and y4mscaler... I use these to encode my own y4m videos to mp4 with x264 and have found yuvdeinterlace in particular to be excellent in terms of speed vs quality.
But if there's a better/easier solution...
giandrea
1st November 2006, 16:38
Yeah, I tried doing the last pipe with ffmpeg instead of x264 but ended up with some h264 errors (I don't quite recall the details, but I'll look into it some more).
I'd like to use the yuv4mpegpipe because I quite like yuvdeinterlace and y4mscaler... I use these to encode my own y4m videos to mp4 with x264 and have found yuvdeinterlace in particular to be excellent in terms of speed vs quality.
But if there's a better/easier solution...
Can't you use two fifo pipe?
alec_robertson
2nd November 2006, 00:53
Yes... but I want to do everything in a single pipe chain. Is this possible or is it a bug with x264's stdin input of yuv420 (it works fine when the same data is read in from a fifo file with a y4m extension)?
akupenguin
2nd November 2006, 01:22
not a bug, just a lack of a feature. x264 detects filetype by filename, and the default is rawyuv not yuv4mpeg.
alec_robertson
2nd November 2006, 22:39
To follow up on my own post, this patch (http://gawker-image-fetch.googlecode.com/svn/trunk/x264.c.diff, applies cleanly to rev598) from Andy Carrell adds "--y4m-input" to enable a single pipe workflow:
ffmpeg -t 30 -i mymoofie.vob -f yuv4mpegpipe - | \
yuvdeinterlace -s0 | \
y4mscaler -v0 -I active=704x352+8+64 -O size=704x384 -O sar=1:1 | \
x264p --y4m-input -o mymoofie.264 -
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.