3

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?

Community
  • 1
  • 1
dascandy
  • 7,184
  • 1
  • 29
  • 50

1 Answers1

3

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.

Z.T.
  • 939
  • 8
  • 20
  • No, exactly. It returns a stream of H.264 frames (iirc). The Ogg/vorbis component returns a full-blown Ogg stream. How do I mux these? – dascandy Apr 14 '12 at 20:23
  • 1
    Mux into what kind of container? IFAIK Ogg container doesn't support H.264. MP4 container supports Vorbis audio. ffmpeg/libav should mux MP4 fine. The people who release copyrighted material on the internet and Google (webm) prefer the Matroska container. I would look at http://www.bunkus.org/videotools/mkvtoolnix/ for that, though maybe ffmpeg/libav do that too. – Z.T. Apr 14 '12 at 20:53
  • Well, ogg doesn't support H.264. Basically, I don't really care what container it is as long as VLC supports it. Any other supporting it is a nice bonus. AVI is terribly old but would be quite OK, but is wider supported than MKV. Those examples you listed seem to be very usable though, I'll look into it. Thanks! – dascandy Apr 15 '12 at 10:05