[FFmpeg-devel] make ffmpeg transcode a growing file
Michael Brennan
michael.brennan.qazxsw
Sun Mar 8 02:50:04 CET 2009
Hello,
I would like to be able to transcode an mpeg2 file at the same time it is
being recorded to disk. I would like to start the recording of the mpeg2 to
disk, and then about 30 seconds later begin transcoding the mpeg2 to mp4
file output. I see that ffmpeg currently will transcode a growing file, but
will often catch up to the end of the file before the recording is finished.
Ffmpeg will then quit normally and the resulting output file will be fine,
although it will not be as long as the mpeg2 that is still recording.
I have set up my building environment and have verified that I can compile
successfully my own versions of ffmpeg. I do it with MSYS under Windows and
I am using latest ffmpeg version r16573 . But I am not a very experienced C
programmer and I am having trouble locating exactly where I would put code
that would make ffmpeg wait a little longer for more data when it thinks it
has reached the end of the file. I suspect it might be in utils.c inside "
static <ffmpeg-devel at mplayerhq.hu> int
av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)" or "int
av_read_frame(AVFormatContext *s, AVPacket *pkt)" but I am not sure.
I tried putting a delay in ffmpeg.c around line 2108 but there must be other
code that overides my usleep() statements as it does not seem to honor them
when the program is running:
/* original code section: */
/* read a frame from it and output it in the fifo */
/*
is = input_files[file_index];
ret= av_read_frame(is, &pkt);
if(ret == AVERROR(EAGAIN) && strcmp(is->iformat->name, "ffm")){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
*/
/* my version */
/* read a frame from it and output it in the fifo */
is = input_files[file_index];
ret= av_read_frame(is, &pkt);
if (ret < 0){
printf("Inside frame grabber routine, line 2131");
usleep(10000);
ret= av_read_frame(is, &pkt);
}
if (ret < 0){
printf("Inside frame grabber routine, line 2136");
usleep(10000);
ret= av_read_frame(is, &pkt);
}
if (ret < 0){
printf("Inside frame grabber routine, line 2141");
usleep(10000);
ret= av_read_frame(is, &pkt);
}
if(ret == AVERROR(EAGAIN) && strcmp(is->iformat->name, "ffm")){
no_packet[file_index]=1;
no_packet_count++;
continue;
}
if (ret < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest)
break;
else
continue;
}
If anyone has figured out how to do this already, or has some idea of how to
do it I would very much appreciate your input.
Thank you,
Michael
More information about the ffmpeg-devel
mailing list