[Ffmpeg-devel] [PATCH] ffmpeg.c: raw subtitles stream support; vhook crashed if -vcodec copy
Alexey Sidelnikov
avs99
Wed Oct 25 11:04:12 CEST 2006
sorry for raising the same issue again, but last time i failed to attach
a patch file: http://article.gmane.org/gmane.comp.video.ffmpeg.devel/38695
I will duplicate my old message here if you don't mind.
-----------------------------------------------------------
I'm sorry, there are two non-related patches in one diff, but both are
very simple, and both are for ffmpeg.c, so I hope that is okay.
1. First patch is to allow raw subtitle stream copying. It was proposed
originally here:
http://article.gmane.org/gmane.comp.video.ffmpeg.devel/38587
but the author missed that if there is no subtitles at all in the input
file, then ffmpeg will crash. So I just added one more check to
av_encode() function.
2. Following this topic:
http://article.gmane.org/gmane.comp.video.ffmpeg.devel/38483
if pre_process_video_frame() is called when video stream is copied, then
AVPicture is not valid in it, and ffmpeg will crash. I added 2 checks -
one in av_encode() during streams sanity check - that will notify a user
right now, and the other one just before pre_process_video_frame() call
- to make sure ffmpeg won't crash somewhere in the future, when a new
pre_process command will be added.
Alexey
Index: ffmpeg.c
===================================================================
--- ffmpeg.c (revision 6731)
+++ ffmpeg.c (working copy)
@@ -1150,8 +1150,12 @@
buffer_to_free = NULL;
if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
- pre_process_video_frame(ist, (AVPicture *)&picture,
- &buffer_to_free);
+ if (ist->decoding_needed) {
+ pre_process_video_frame(ist, (AVPicture *)&picture,
&buffer_to_free);
+ }
+ else {
+ fprintf(stderr, "video frame can not be
preprocessed if video stream is copied\n");
+ }
}
// preprocess audio (volume)
@@ -1427,6 +1431,12 @@
os = output_files[i];
nb_ostreams += os->nb_streams;
}
+
+ if (nb_ostreams == 0) {
+ fprintf(stderr, "No audio, video or subtitles streams
available\n");
+ exit(1);
+ }
+
if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) {
fprintf(stderr, "Number of stream maps must match number of
output streams\n");
exit(1);
@@ -1544,6 +1554,11 @@
codec->block_align= icodec->block_align;
break;
case CODEC_TYPE_VIDEO:
+ if (do_deinterlace || using_vhook) {
+ fprintf(stderr, "Neither deinterlace, nor vhook are
allowed during video stream copying!\nDecoding/encoding is required.\n");
+ exit(1);
+ }
+
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
More information about the ffmpeg-devel
mailing list