Hi,
I'm currently working on a segmenting remuxer kind of like the
adaptive HTTP Live Streaming segmenter, and in fact I'm used that one
as a starting point.
So what's the idea: I have an incoming stream that shall be segmented
into single files, each being long about N frames or T seconds, the cut
shall be made at keyframes. Once a segment is finished it's trailer is
written and closed, a new file is opened global headers written and
then the whole process starts anew. In principle it works, however I
encounter two problems:
1. The framerate and timestamp information are not carried over to the
segmented files.
I guess, I forgot something very simple.
2. Depending on the output file format either av_write_frame or
av_interlaced_write_frame must be used, otherwise it fails.
I suspect that I'm doing something fundamentally wrong.
So far my frame processing loop looks like this (omitting error checking
and processing, duration calculation doesn't work yet, part of my
problem):
AVPacket packet;
av_init_packet(&packet);
for(;;) {
if( av_read_frame( ic, &packet ) > 0)
break;
frameno++;
if( ic->streams[packet.stream_index]->codec->codec_type==CODEC_TYPE_VIDEO
&& ( packet.flags & PKT_FLAG_KEY )
&& frameno > N ) {
frameno = -1;
}
if( frameno < 0 ) {
frameno = 0;
put_flush_packet( oc->pb );
av_write_trailer(oc);
url_fclose( oc->pb );
snprintf(
output_filename,
MAX_OUTPUT_FILENAME_LENGTH, "%s-%u.%s",
output_prefix,
output_index++,
output_format );
url_fopen( &oc->pb, output_filename, URL_WRONLY );
av_write_header(oc);
prev_segment_time = segment_time;
#ifdef USE_INTERLACED_WRITE
av_interlaced_write_frame( oc, &packet );
#else
av_write_frame( oc, &packet );
#endif
}
I put the whole mess^W source code at
http://pastebin.org/454898
So what do I have to change?
Thanks
Wolfgang
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user