View Full Version : Is there a way to pipe video from quicktime into x264?
Electron.Rotoscope
22nd July 2011, 23:35
I've been having a problem, and I can't seem to find a specific solution for this anywhere.
I want to set up an encoder on a Mac OSX 10.6.7 machine to take command line input and encode quicktime files into H.264/AAC mp4 streams, but unfortunately the quicktime files are all unavoidably encoded using a proprietary codec. I have the decoder installed on the system, Quicktime opens them fine, but it's not a codec supported by libavcodec/ffmpeg, and it's not a codec I can get a library for.
Is there any way to configure ffmpeg to use the system quicktime to feed it frames, or to call an instance of the quicktime component to pipe frames into ffmpeg?
I... know this should go without saying, but no I'm afraid it's not possible to transcode everything in QuickTime Pro to Uncompressed or whatever just so ffmpeg can read them.
If this were a windows system, I'd build ffmpeg with avisynth and use an avs script with "QTSource", but avisynth doesn't build outside of windows I'm told, and I'm also told http://avisynth3.unite-video.com/ is not yet in a usable state and was largely abandoned (is this worth trying to compile to test with?)
If I just needed to make quicktime files, I'd use the x264 build-as-a-QuickTime-component thing from http://www003.upp.so-net.ne.jp/mycometg3/, but it doesn't have all the options I need or presets I'd prefer, and I don't think would work from the command line. And I can't make .mp4s from it.
If I were coming from ProRes, I'd be able to use MPlayer (at least, according to http://doom10.org/index.php?topic=1822.msg8476#msg8476) but as far as I can understand that solution won't work for anything other than ProRes. Though I will try it next.
(and I'm very hesitant to start messing around with Wine)
And I tried ffmbc from http://code.google.com/p/ffmbc/ but it doesn't include what I need
I know that ffmpeg is working, I made sure and built it with libraries for the latest x264 and faac, and I can encode from other sources etc etc. I'm just... at a loss.
Anyone have any ideas? Maybe another program that can decode with quicktime system codecs and send data to x264?
In case it matters:
- The codec I need to decode is called Cineform, though really it's more universally about calling system QT decoders
- The build of ffmpeg I'm using looks like:
ffmpeg version N-31617-g4095fa9, Copyright (c) 2000-2011 the FFmpeg developers
built on Jul 22 2011 18:35:30 with gcc 4.2.1 (Apple Inc. build 5646)
configuration: --enable-gpl --enable-nonfree --enable-libx264 --enable-libmp3lame --enable-libfaac --arch=x86_64 --enable-static --disable-shared
libavutil 51. 11. 0 / 51. 11. 0
libavcodec 53. 8. 0 / 53. 8. 0
libavformat 53. 6. 0 / 53. 6. 0
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 2. 27. 2 / 2. 27. 2
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
- The command line I just tested with was:
$ ffmpeg -i /Volumes/XXX/master.mov -f mp4 -vcodec libx264 -b 600k /Volumes/XXX/test.mp4
- And the error I got was (in pretty red colours in terminal!):
[buffer @ 0x100f05940] Invalid pixel format string '-1'
Error opening filters!
Electron.Rotoscope
22nd July 2011, 23:41
...maybe this is the wrong forum for this. Would this better fit in the ffmpeg or x264 or doom10 or something? My apologies and I'll remove it if so, I guess I'm just used to doom9 being my default for this kind of thing
kieranrk
23rd July 2011, 01:06
mplayer can probably output that video to a yuv4mpeg pipe.
Electron.Rotoscope
23rd July 2011, 03:05
So mplayer can call system QuickTime decoders? Ones it doesn't support natively? I'm not really familiar yet with mplayer options, and I'm pretty positive nothing open source can decode it
Dark Shikari
23rd July 2011, 03:15
So mplayer can call system QuickTime decoders? Ones it doesn't support natively? I'm not really familiar yet with mplayer options, and I'm pretty positive nothing open source can decode itw32codecs is a set of binary decoders mplayer can use, which includes Quicktime decoders.
Some Quicktime proprietary formats do have open source decoders, or will soon (Prores is a WIP).
Electron.Rotoscope
23rd July 2011, 04:08
w32codecs is a set of binary decoders mplayer can use, which includes Quicktime decoders.
Some Quicktime proprietary formats do have open source decoders, or will soon (Prores is a WIP).
Oh hmm does this allow me to build DirectShow decoders as a library? Or did they actually build a decoder? http://forums.fedoraforum.org/showthread.php?t=254448 gives me hope! I'll report back whether I have any success. Sadly this won't do what I ultimately will need (ie for ProRes, and whatever comes after it etc) but CineForm support is a huge plus!
Sadly this won't do what I ultimately will need (ie for ProRes, and whatever comes after it etc)
What do you ultimately need? ProRes does work in MPlayer with Apple's binary codecs and support for future decoders could be added in the same way.
ricardo.santos
23rd July 2011, 12:17
Altough you're using a Mac have you tried batch remuxing the files to mp4 or hdmov?
in the past whenever i had difficulties converting mov i renamed or remuxed it to mp4 and it solved the problem.
here's a link to a bach script (windows though maybe you can adapt it), if you do a bulk rename of the mov extension files to mp4 or hdmov it might work.
Electron.Rotoscope
23rd July 2011, 17:48
What do you ultimately need? ProRes does work in MPlayer with Apple's binary codecs and support for future decoders could be added in the same way.
I guess maybe that is what I will need! I'd been searching for a way to link it in ffmpeg, but I'll try to find more information on building .qtx or .ax files into mplayer and post here if I have any success :)
Electron.Rotoscope
23rd July 2011, 18:24
Altough you're using a Mac have you tried batch remuxing the files to mp4 or hdmov?
in the past whenever i had difficulties converting mov i renamed or remuxed it to mp4 and it solved the problem.
here's a link to a bach script (windows though maybe you can adapt it), if you do a bulk rename of the mov extension files to mp4 or hdmov it might work.
Ah sadly I think the problem is deeper than that, more to do with the codec itself not being supported, but I'll give that a shot!
ricardo.santos
23rd July 2011, 20:21
forgot to post the link for the script:
http://forum.videohelp.com/threads/330896-All-in-one-Batch-demux-FLV-mux-mp4
or use mpeg streamclip to remux mov to mp4
http://www.squared5.com/
its for flv and windows but it might work if you change flv to mov in the script
Electron.Rotoscope
27th July 2011, 21:29
So I'm trying to compile mplayer on Snow Leopard and it is being a horrible little beast... but for the time being I thought I would use the MacPorts version and at least try testing out some uncompressed files.
I'm having problems getting... some part of it to work though. I suspect I have the syntax wrong? I can't find any documentation for using the yuv4mpeg pipe with mplayer.
the input line I'm giving it is
$ mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o /Volumes/Temp_1/test.264) /Volumes/Asset_1/BARS_I420.avi
And what I get is
x264 [error]: No input file. Run x264 --help for a list of options.
MPlayer 1.0rc4-4.2.1 (C) 2000-2010 MPlayer Team
158 audio & 340 video codecs
Playing /Volumes/Dam_Asset_1/BARS_I420.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
AVI: ODML: Building ODML index (1 superindexchunks).
VIDEO: [YUY2] 1920x1080 16bpp 23.976 fps 795467.6 kbps (97103.0 kbyte/s)
Using (default) progressive frame mode.==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0x101870e00]using unscaled yuyv422 -> yuv420p special converter
VO: [yuv4mpeg] 1920x1080 => 1920x1080 Planar YV12
MPlayer interrupted by signal 13 in module: init_video_codec
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
Audio: no sound
Starting playback...
MPlayer interrupted by signal 13 in module: flip_page
Does this make sense to anyone? Did I write that down right? I'm working under the assumption that it's -vo yuv4mpeg:file=>(x264 --various-options) input.avi but if someone knows the link to the actual documentation for that it'd be amazing
I've also tried the mkfifo method described in http://forum.doom9.org/showthread.php?p=1234194#post1234194 but that didn't work either
$ mkfifo pip.y4m;x264 pipe.y4m --demuxer y4m --bitrate 2000 -o /Volumes/Temp_1/gLuce/test.264 & mplayer -benchmark -vo yuv4mpeg:file=pipe.y4m -ao null /Volumes/Dam_Asset_1/BARS_I420.avi
[1] 47342
MPlayer 1.0rc4-4.2.1 (C) 2000-2010 MPlayer Team
158 audio & 340 video codecs
Playing /Volumes/Dam_Asset_1/BARS_I420.avi.
x264 [error]: could not open input file `pipe.y4m'
(And then it just ran through the file and exited without outputting anything)
I've never worked with pipes or anything like them before so i could appreciate whatever help I can get.
Note: I'm afraid I need to use mplayer, not ffmpeg or whatever, because i will eventually need to be able to link to .ax binaries on a mac and it seems nothing but mplayer can do that?
Also Note: I'm pretty sure I need to run x264 as its own application, since I don't think ffmpeg or whatever supports all the flags (--bluray-compat from http://www.x264bluray.com/home/1080i-p) for instance
TheFluff
27th July 2011, 23:22
"mkfifo pip.y4m" should probably be "mkfifo pipe.y4m". Also, you cannot redirect the output to a file like you're trying to in the above examples. You either redirect the entire program's stdout or you redirect nothing. IIRC "-" is a special filename that makes the y4m output module write to stdout instead of to a file.
See also http://mplayerhq.hu/DOCS/man/en/mplayer.1.txt
Electron.Rotoscope
27th July 2011, 23:40
"mkfifo pip.y4m" should probably be "mkfifo pipe.y4m". Also, you cannot redirect the output to a file like you're trying to in the above examples. You either redirect the entire program's stdout or you redirect nothing. IIRC "-" is a special filename that makes the y4m output module write to stdout instead of to a file.
See also http://mplayerhq.hu/DOCS/man/en/mplayer.1.txt
Ah thank you I didn't see that! It actually seems to work now! I have to set a framerate and resolution still, or it goes haywire, but hurrah! Now all I have to do is figure out how to get it to simultaneously pipe out the audio! (uhhh...)
Sadly, the man page isn't quite enough information for me, I'm not familiar at all with pipes or mkfifo or anything like that, so the one little paragraph about how to set it for interlaced sources was unfortunately not enough information.
It also doesn't have anything about stdout... could you extrapolate a little? I guess I don't really know what you mean about that.
"mkfifo pip.y4m" should probably be "mkfifo pipe.y4m". Also, you cannot redirect the output to a file like you're trying to in the above examples.
The first command is missing a "-" to let x264 know that it should read standard input:
mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o p.264 -) dvd1.mkv
The second command (mkfifo ...) also works fine when using the correct filename, as you pointed out. As a minor adjustment, I'd swap x264 and mplayer the other way around so that mplayer is put to background and x264 to foreground. x264 terminates later than mplayer.
In both cases the data flows through a named pipe.
IIRC "-" is a special filename that makes the y4m output module write to stdout instead of to a file.
-vo yuv4mpeg doesn't have that functionality unless it's been recently added and I haven't noticed.
SeeMoreDigital
28th July 2011, 09:27
MediaPlayer Classic (MPC) offers the ability to call Quicktimes video and audio decoders.
I don't know if you can use MPC to serve to other applications though...
LoRd_MuldeR
28th July 2011, 12:42
What about QuickTime Alternative (http://www.free-codecs.com/download/quicktime_alternative.htm)? AFAIK it makes QuickTime decoders available to the DiretShow framework.
Can't it work with DirectShowSource() or DSS2() in Avisynth? Or maybe deliver the content directly to x264 with DirectShow-enabled builds of x264 (Direct264)?
Electron.Rotoscope
28th July 2011, 14:07
The first command is missing a "-" to let x264 know that it should read standard input:
mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o p.264 -) dvd1.mkv
The second command (mkfifo ...) also works fine when using the correct filename, as you pointed out. As a minor adjustment, I'd swap x264 and mplayer the other way around so that mplayer is put to background and x264 to foreground. x264 terminates later than mplayer.
In both cases the data flows through a named pipe.
Cool thanks, I'll try that out! Would you recommend one over the other? Or should I just do my own speed tests?
Oh hey, could I do something like
mplayer -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o vid.264 -) -ao pcm:fast:file=>(NeroAacEnc -ignorelength -cbr 96000 -if - -of aud.aac) source.avi
to feed to separate audio and video tracks at the same time?
Electron.Rotoscope
28th July 2011, 14:13
What about QuickTime Alternative (http://www.free-codecs.com/download/quicktime_alternative.htm)? AFAIK it makes QuickTime decoders available to the DiretShow framework.
Can't it work with DirectShowSource() or DSS2() in Avisynth? Or maybe deliver the content directly to x264 with DirectShow-enabled builds of x264 (Direct264)?
Ah if only! Unfortunately I need a solution that runs in Mac/OSX also, and I'm told that AviSynth is unusable on OSX due to a lack of VFW (not that I claim to know what that is). If I had avisynth, I could even just run QTSource and be done with it! It's frustrating actually, knowing that I only need this framework for this one "QTSource" command but that I can't even do that.
I haven't heard of Direct264, can it be compiled on a system that doesn't have directshow itself?
Unfortunately QuickTime Alternative does sort of the opposite of what I need, I'd like to be able to use proprietary .qtx style decoder binaries that can only come from the manufacturers (aka the ones for Cineform HD or RED3D or ProRes 4444) that the open source community has not yet reverse engineered. In a perfect world, all my sources would be uncompressed AVI, or at least something easy to decode, but alas such is life.
Also I think QT Alternative is Windows-Only
Edit:
Actually you know what, QT Alternative would be fantastically useful if I ever need to decode like ProRes4444 with something that only takes DirectShow, I'll definitely keep it in mind if that ever comes up!
Electron.Rotoscope
28th July 2011, 14:19
MediaPlayer Classic (MPC) offers the ability to call Quicktimes video and audio decoders.
I don't know if you can use MPC to serve to other applications though...
Ah sadly Windows-only again... sigh life is so hard. Forced cruelly to use this giant beast of a Final Cut Pro system *weep* *wail*
Cool thanks, I'll try that out! Would you recommend one over the other? Or should I just do my own speed tests?
Both commands do basically the same thing, so they will run equally fast.
Oh hey, could I do something like
mplayer -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o vid.264 -) -ao pcm:fast:file=>(NeroAacEnc -ignorelength -cbr 96000 -if - -of aud.aac) source.avi
to feed to separate audio and video tracks at the same time?
Yep, that should work.
Unfortunately I need a solution that runs in Mac/OSX also, and I'm told that AviSynth is unusable on OSX due to a lack of VFW (not that I claim to know what that is).
Well, AviSynth doesn't depend on VFW that much -- x264, ffmpeg, MPlayer and avs2yuv call it directly. Most of AviSynth could be ported to other operating systems if someone had the time and will.
But currently you need Wine to run AviSynth on OS X. It should work pretty well, except for DirectShow input. I haven't tried QTSource.
Electron.Rotoscope
28th July 2011, 15:44
Both commands do basically the same thing, so they will run equally fast.
Yep, that should work.
A-maaaa-zing
Well, AviSynth doesn't depend on VFW that much -- x264, ffmpeg, MPlayer and avs2yuv call it directly. Most of AviSynth could be ported to other operating systems if someone had the time and will.
But currently you need Wine to run AviSynth on OS X. It should work pretty well, except for DirectShow input. I haven't tried QTSource.
Is the version at http://avisynth3.unite-video.com/ worth trying to compile at all?
I've seen other people recommending Wine but... I dunno, it seems so icky. And I worry about performance, if I encode a feature length blu-ray it's already like 24 hours of rendering time or more. Plus it would make it less portable right? Like Wine would have to be installed on any box that tries to use it? My hope is that if I can put the right codecs into mplayer at build time and make it all static, I can just put the binaries into other Mac boxes and spread out where we do the encoding.
Plus I don't think the Chief Computer Person here would like me installing Wine at all, for fear it'll break other things.
LoRd_MuldeR
28th July 2011, 16:02
Is the version at http://avisynth3.unite-video.com/ worth trying to compile at all?
Probably not. AFAIK the Avisynth 3 project is pretty much dead :(
I've seen other people recommending Wine but... I dunno, it seems so icky. And I worry about performance
Wine, as the name implies, is not an emulator.
It basically is a loader for PE executable, which otherwise can't load under Linux/Unix, plus a collection of DLL's that provide a Win32-compatible API layer, which is necessary to make Win32 application work under Linux/Unix.
Thus the performance hit shouldn't be that big. That plus: You can run Avisynth+avs2yuv under Wine and from there pipe to a "native" encoder process...
Electron.Rotoscope
28th July 2011, 18:33
Wine, as the name implies, is not an emulator.
It basically is a loader for PE executable, which otherwise can't load under Linux/Unix, plus a collection of DLL's that provide a Win32-compatible API layer, which is necessary to make Win32 application work under Linux/Unix.
Thus the performance hit shouldn't be that big. That plus: You can run Avisynth+avs2yuv under Wine and from there pipe to a "native" encoder process...
Oy. I might just start doing that. I do wonder about scaling and deinterlacing using mplayer and whether it would be better to use avs instead. I know it'll hit resistance but maybe...
TheFluff
28th July 2011, 18:52
There's no point in trying to run Avisynth under Wine for you, since the part you want is DirectShowSource and that doesn't work under Wine anyway. AFAIK the only multipurpose source filter that works reliably in Avisynth under Wine is FFmpegSource, and since you said there's no FFmpeg decoder for your codec, that won't help you at all.
Avisynth 3 has been very dead for years and even when it was "alive" it was mostly vaporware.
Electron.Rotoscope
28th July 2011, 19:00
There's no point in trying to run Avisynth under Wine for you, since the part you want is DirectShowSource and that doesn't work under Wine anyway. AFAIK the only multipurpose source filter that works reliably in Avisynth under Wine is FFmpegSource, and since you said there's no FFmpeg decoder for your codec, that won't help you at all.
Avisynth 3 has been very dead for years and even when it was "alive" it was mostly vaporware.
Darnit! At least that saves me the trouble of trying. Do you happen to know about QTSource? Or something else that'll call system quicktime decoders at runtime? As I said I'm currently looking at just building whatever decoders I need into mplayer, if I can ever get mplayer to compile.
There's no point in trying to run Avisynth under Wine for you, since the part you want is DirectShowSource and that doesn't work under Wine anyway.
QTSource doesn't seem to use DirectShow for anything. It uses QuickTime though, and I don't know if it works well enough with Wine.
TheFluff
29th July 2011, 01:38
QTSource doesn't seem to use DirectShow for anything. It uses QuickTime though, and I don't know if it works well enough with Wine.
It might actually work, unless Apple decided to finally remove the old Carbon API's. I haven't tested it though.
Electron.Rotoscope
29th July 2011, 22:11
The first command is missing a "-" to let x264 know that it should read standard input:
mplayer -nosound -benchmark -vo yuv4mpeg:file=>(x264 --demuxer y4m --bitrate 2000 -o p.264 -) dvd1.mkv
The second command (mkfifo ...) also works fine when using the correct filename, as you pointed out. As a minor adjustment, I'd swap x264 and mplayer the other way around so that mplayer is put to background and x264 to foreground. x264 terminates later than mplayer.
Got the swap to work, it behaves much less annoyingly while it's running now, thanks!
The "-" thing doesn't seem to work though. Works fine in the command line, totally looks great, but I think OSX's bash script must not have the capability, because it freaks out as soon as I put #!/bin/bash in front of it and run it as a .sh script. I guess I'll just stick to the named pipes.
The "-" thing doesn't seem to work though. Works fine in the command line, totally looks great, but I think OSX's bash script must not have the capability, because it freaks out as soon as I put #!/bin/bash in front of it and run it as a .sh script.
Did you put #!/bin/bash on its own line before the mplayer command? I don't see why it wouldn't work then, and it does work within Bash script files on Linux.
Electron.Rotoscope
30th July 2011, 06:01
Did you put #!/bin/bash on its own line before the mplayer command? I don't see why it wouldn't work then, and it does work within Bash script files on Linux.
I know right? I swear it's just something the Mac version of bash weirdly just doesn't support.
Reimar
30th July 2011, 14:49
If I were coming from ProRes, I'd be able to use MPlayer (at least, according to http://doom10.org/index.php?topic=1822.msg8476#msg8476) but as far as I can understand that solution won't work for anything other than ProRes.
It also will work with cineform, the original discussion/patch was here: http://lists-archives.org/mplayer-dev-eng/29346-support-cineform-directshow-codec.html
and it has been integrated since.
From a technical standpoint it is nearly the same as using Wine, however it should be simpler from an end-user standpoint since you only need the mplayer/mencoder binary and the Cineform DIrectShow codec binary.
In addition MPlayer can use QuickTime codecs, too, but you need to set it up correctly in its codecs.conf and I have some doubts that's something you'll manage easily.
Electron.Rotoscope
30th July 2011, 19:24
It also will work with cineform, the original discussion/patch was here: http://lists-archives.org/mplayer-dev-eng/29346-support-cineform-directshow-codec.html
and it has been integrated since.
From a technical standpoint it is nearly the same as using Wine, however it should be simpler from an end-user standpoint since you only need the mplayer/mencoder binary and the Cineform DIrectShow codec binary.
In addition MPlayer can use QuickTime codecs, too, but you need to set it up correctly in its codecs.conf and I have some doubts that's something you'll manage easily.
Yeah I don't mind building the decoders in when I compile. I'm okay getting the GUIDs and the .ax files, still looking into details of how to make proper new codecs.conf entries, but at least mplayer is compiling now! I think it ultimately just is my solution, not ffmpeg, and I'll just use a separate mp4 muxer
Reimar
30th July 2011, 20:28
Yeah I don't mind building the decoders in when I compile. I'm okay getting the GUIDs and the .ax files, still looking into details of how to make proper new codecs.conf entries
There already is a codecs.conf entry for the .ax file. The problem is though that you need to find an older version, the current v5 version will only work on Windows (for now).
You might have better luck with the .qtx component, and codecs.conf entries for it should be easier to create (just look for existing ones with "driver qtvideo" as examples), but nobody has done that so far.
Electron.Rotoscope
30th July 2011, 20:57
There already is a codecs.conf entry for the .ax file. The problem is though that you need to find an older version, the current v5 version will only work on Windows (for now).
You might have better luck with the .qtx component, and codecs.conf entries for it should be easier to create (just look for existing ones with "driver qtvideo" as examples), but nobody has done that so far.
I was wondering about the version. So even if I find the latest .ax it won't work? Damnit. I'll see what I can do about bringing in the .qtx, I certainly have the filter...
Reimar
30th July 2011, 23:11
I was wondering about the version. So even if I find the latest .ax it won't work?
Previous versions will work. And if you update to latest MPlayer the version included in the current NeoPlayer (http://www.cineform.com/downloads/NeoPlayerV553b328-110628.zip) should work as well.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.