Search code examples
ffmpegmp4vlch.264mpeg

Convert streaming MPEG-4 raw data to H.264


I've got a Sony network camera (SNC-RZ25N) that I am trying desperately to get data from in some meaningful format. The documentation says it sends MPEG-4 raw data, but is not more specific than than. I can capture a segment of the stream using curl ( http://techhead.biz/media/tsv.m4v ) and it will play using VLC and ffplay (though it plays too fast in ffplay).

After a day and a half of tinkering, I just discovered that I cannot use ffmpeg to convert this stream directly. For one, the only way ffmpeg accepts piped data as input (that I'm aware of) is in the 'yuv4mpegpipe' format.

I tried piping to ffmpeg using 'm4v' as the specified format, but it seems to want to read the entire stream before it begins processing.

Anyone know how I can do this? Using commandline tools? Open source libraries in ANY programming language? Simpler solutions are preferred, but any working solution would be great.


Solution

  • It appears mplayer can play your m4v file over HTTP, and at least with your sample file this works:

    mkfifo /tmp/fifo
    mplayer -benchmark -vo yuv4mpeg:file=/tmp/fifo http://techhead.biz/media/tsv.m4v
    ffmpeg -f yuv4mpegpipe -i /tmp/fifo -vcodec libx264 -vpre libx264-hq /tmp/foo.mp4
    

    (-benchmark tells mplayer to ignore frame duration, might or might not be needed)

    Alternatively, with just mencoder:

    mencoder -o /tmp/foo.avi -of avi -ovc x264 -x264encopts bitrate=250 http://techhead.biz/media/tsv.m4v
    

    Finally, if you don't actually need H.264, you could just put the existing MPEG-ES data in whatever container format you need; MP4Box might be able to do this, and ffmpeg and mencoder can if they support the output format.