[FFmpeg-devel] ffserver jpg patch
ill
illumilore at gmail.com
Tue May 5 02:35:36 CEST 2015
I changed it to git and add the .write header to the last part. The first part compiled after I changed ffserver.c, so it is no longer corrupted. Muxer detection seems to work when I tried it for the middle part. It should be good to fix ffserver now?
diff -Nrup ffmpeg-git--orig/ffserver.c ffmpeg-git/ffserver.c
--- ffmpeg-git--orig/ffserver.c 2015-03-16 20:25:48.000000000 +0100
+++ ffmpeg-git/ffserver.c 2015-04-05 02:33:53.000000000 +0200
@@ -967,6 +967,10 @@ static int handle_connection(HTTPContext
/* close connection if trailer sent */
if (c->state == HTTPSTATE_SEND_DATA_TRAILER)
return -1;
+ /* Check if it is a single jpeg frame 123 */
+ if (c->stream->single_frame && c->data_count > c->cur_frame_bytes && c->cur_frame_bytes > 0) {
+ close_connection(c);
+ }
break;
case HTTPSTATE_RECEIVE_DATA:
/* no need to read if no events */
diff -Nrup ffmpeg-git--orig/ffserver_config.c
ffmpeg-git/ffserver_config.c
--- ffmpeg-git--orig/ffserver_config.c 2015-03-16
20:25:48.000000000 +0100
+++ ffmpeg-git/ffserver_config.c 2015-04-05 02:33:53.000000000 +0200
@@ -862,8 +862,10 @@ static int ffserver_parse_config_stream(
} else {
stream->stream_type = STREAM_TYPE_LIVE;
/* JPEG cannot be used here, so use single frame MJPEG */
- if (!strcmp(arg, "jpeg"))
- strcpy(arg, "mjpeg");
+ if (!strcmp(arg, "jpeg")) {
+ strcpy(arg, "singlejpeg");
+ stream->single_frame=1;
+ }
stream->fmt = ffserver_guess_format(arg, NULL, NULL);
if (!stream->fmt)
ERROR("Unknown Format: '%s'\n", arg);
diff -Nrup ffmpeg-git--orig/ffserver_config.h
ffmpeg-git/ffserver_config.h
--- ffmpeg-git--orig/ffserver_config.h 2015-03-16
20:25:48.000000000 +0100
+++ ffmpeg-git/ffserver_config.h 2015-04-05 02:33:53.000000000 +0200
@@ -79,6 +79,7 @@ typedef struct FFServerStream {
int multicast_port; /* first port used for multicast */
int multicast_ttl;
int loop; /* if true, send the stream in loops
(only meaningful if file) */
+ char single_frame; /* only single frame */
/* feed specific */
int feed_opened; /* true if someone is writing to the
feed */
diff -Nrup ffmpeg-git--orig/libavformat/allformats.c
ffmpeg-git/libavformat/allformats.c
--- ffmpeg-git--orig/libavformat/allformats.c 2015-03-16
20:25:52.000000000 +0100
+++ ffmpeg-git/libavformat/allformats.c 2015-04-05
02:33:53.000000000 +0200
@@ -273,6 +273,7 @@ void av_register_all(void)
REGISTER_MUXER (SEGMENT, stream_segment);
REGISTER_DEMUXER (SHORTEN, shorten);
REGISTER_DEMUXER (SIFF, siff);
+ REGISTER_MUXER (SINGLEJPEG, singlejpeg);
REGISTER_DEMUXER (SLN, sln);
REGISTER_DEMUXER (SMACKER, smacker);
REGISTER_MUXDEMUX(SMJPEG, smjpeg);
diff -Nrup ffmpeg-git--orig/libavformat/rawenc.c
ffmpeg-git/libavformat/rawenc.c
--- ffmpeg-git--orig/libavformat/rawenc.c 2015-03-16
20:25:54.000000000 +0100
+++ ffmpeg-git/libavformat/rawenc.c 2015-04-05 02:33:53.000000000
+0200
@@ -250,6 +250,17 @@ AVOutputFormat ff_mjpeg_muxer = {
.write_packet = ff_raw_write_packet,
.flags = AVFMT_NOTIMESTAMPS,
};
+
+AVOutputFormat ff_singlejpeg_muxer = {
+ .name = "singlejpeg",
+ .long_name = NULL_IF_CONFIG_SMALL("JPEG single image"),
+ .mime_type = "image/jpeg",
+ .extensions = "jpg,jpeg",
+ .audio_codec = AV_CODEC_ID_NONE,
+ .video_codec = AV_CODEC_ID_MJPEG,
+ .write_packet = ff_raw_write_packet,
+ .flags = AVFMT_NOTIMESTAMPS,
+ .write_header = force_one_stream,
+};
#endif
#if CONFIG_MLP_MUXER
More information about the ffmpeg-devel
mailing list