[FFmpeg-devel] FFMPEG : Redirecting Matroska muxed data to socket

Calvin Walton calvin.walton at kepstin.ca
Wed Oct 29 16:44:53 CET 2014


On Wed, 2014-10-29 at 11:26 +0530, Parth Shah wrote:
> Hi all,
> 
> I am using FFMPEG library to mux H.264 and AAC frames to Matroska 
> (.mkv)
> file. I can do that both using command line and C program.
> 
> Now, instead of writing the muxed matroska data into file I want to
> write these muxed data directly on to socket or pipe. My actual goal 
> is
> to write a C program that send muxed data to socket and server will
> receive this muxed data.
> 
> I tried using protocol tcp. They are working with the matroska 
> format.
> So, My C program is able to send muxed data successfully over socket 
> and
> server is able to receive this muxed data.
> 
> But when I apply ffprobe command over the received file, I am getting
> duration and bitrate field N/A. and when I tried to play this file 
> with
> vlc i am unable to seek the file and getting garbage duration.

When ffmpeg writes matroska directly to a file, it writes all of the 
data for the media streams out, then seeks back to the start of the 
file to fill in the duration field.

But you're sending the matroska over a tcp stream - effectively a live 
stream. As a result, ffmpeg can't go back and update these fields once 
the file is completely written; so they're left unset.

This isn't normally a problem - it means that players will not show 
the correct duration while playing the file, but seeking should still 
work (and does in e.g. mplayer - it sounds like you might be hitting a 
vlc bug if seeking doesn't work there).

To fix the received file, you'll just have to remux the mkv, e.g. by 
doing
ffmpeg -i received.mkv -c copy remuxed.mkv


-- 
Calvin Walton <calvin.walton at kepstin.ca>


More information about the ffmpeg-devel mailing list