Given an x264 stream and an ogg vorbis stream, how do I make a muxed stream that mplayer/VLC can read?

StackOverflow https://stackoverflow.com/questions/10131591

Question

I'm confused and a bit stuck with this question. All I can find on Google is basic usage of transcoding software, which is not related to the question.

I'm making a game and I'd like to include native capture ability to stream video. I would much like to stream this to a standard-ish client, such as VLC. It needs to be both in a format it recognizes and it needs to be multiplexed in order for this to work.

My question therefore is, I know how to encode stuff from raw video frames to x264 (see also How does one encode a series of images into H264 using the x264 C API? ). I know how to encode raw audio samples into ogg/vorbis. Now, how do I put one and one together for VLC?

Was it helpful?

Solution

x264 is not a stream format. It is a piece of software. This software encodes video to the H.264 video format. AFAIK, it does not mux video+audio into MP4 or AVI container files. Look into ffmpeg/libav for a full suite. There are other programs to mux video and audio streams.

Here's an experiment I performed:

youtube-dl "http://www.youtube.com/watch?v=0Bmhjf0rKe8"
avconv -i 0Bmhjf0rKe8.flv -vn -c:a libvorbis -b:a 64k 0Bmhjf0rKe8.ogg
avconv -i 0Bmhjf0rKe8.flv -c:v copy -bsf:v h264_mp4toannexb -an 0Bmhjf0rKe8.h264
avconv -i 0Bmhjf0rKe8.h264 -i 0Bmhjf0rKe8.ogg -c copy 0Bmhjf0rKe8.mkv
mplayer 0Bmhjf0rKe8.mkv
avconv -i 0Bmhjf0rKe8.flv -i 0Bmhjf0rKe8.ogg -c copy -map 0:0 -map 1:0 0Bmhjf0rKe8.mp4
mplayer 0Bmhjf0rKe8.mp4

You should be able to do that programmatically using libav.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top