0

I have H264 data, coming from a frame grabber. Using this data, I have already written an RTP/H264 streaming server (using live555) and a RTP/H264 client (using ffmpeg and live555).

I want to add a new feature to my server : Directely save encoded H264 data to file (without transcoding) in any format (avi, mp4, mkv, etc.) which enables later to watch videos using VLC.

For the display client, basically, I have performed :

1) Build packets from H264 data using ffmpeg/av_new_packet()

2) Decode H264 data ffmpeg/avcodec_decode_video2()

3) Format decoded frame using ffmpeg/sws_scale()

4) Display

Could someone quickly advise me for the video file saving feature without decoding/transcoding data and using ffmpeg ? It is sufficient to

1) Choose an output context (format)

2) Build packets from H264 data using ffmpeg/av_new_packet()

3) Save the packet using ffmpeg/av_(interleaved)_write_frame() (and also av_write_trailer() and av_write_header()) ?

?

Thank you every one

2 Answers 2

1

I did similar one; used ffmpeg for encoding. I found ffmpeg remuxing example 1 and it worked for me. (It is too late to answer, but I hope it will help someone else. )

-1

Please view ffplay.c:

static int video_thread(void *arg)
{
...
ret = get_video_frame(is, frame, &pts_int, &pkt);
...
}

The pkt is raw h264 packet. save pkt.data to file is OK.

fwrite(pkt.data, 1, pkt.size, pf );

if this file cant play by mplayer,please first add :

unsigned char const start_code[4] = {0x00, 0x00, 0x00, 0x01};
fwrite(start_code, 4,1, pf );
1
  • 1
    This is hardly an answer, the question is about packetization and not about writing to a file. Oct 11, 2012 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.