Lines 1-157
Link Here
|
1 |
--- ffmpeg.c.orig 2010-06-01 15:48:23.000000000 +0900 |
|
|
2 |
+++ ffmpeg.c 2012-06-08 23:21:55.000000000 +0900 |
3 |
@@ -36,6 +36,11 @@ |
4 |
# endif /* __GNUC__ */ |
5 |
#endif /* LIBAVCODEC_BUILD > 4680 */ |
6 |
|
7 |
+#if defined LIBAVFORMAT_VERSION_MAJOR && defined LIBAVFORMAT_VERSION_MINOR |
8 |
+#if LIBAVFORMAT_VERSION_MAJOR < 53 && LIBAVFORMAT_VERSION_MINOR < 45 |
9 |
+ #define GUESS_NO_DEPRECATED |
10 |
+#endif |
11 |
+#endif |
12 |
|
13 |
#if LIBAVFORMAT_BUILD >= 4616 |
14 |
/* The API for av_write_frame changed with FFmpeg version 0.4.9pre1. |
15 |
@@ -227,11 +232,13 @@ |
16 |
mpeg1_file_protocol.url_seek = file_protocol.url_seek; |
17 |
mpeg1_file_protocol.url_close = file_protocol.url_close; |
18 |
|
19 |
- /* Register the append file protocol. */ |
20 |
-#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8) |
21 |
+/* Register the append file protocol. */ |
22 |
+#ifdef have_av_register_protocol2 |
23 |
+ av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol)); |
24 |
+#elif defined have_av_register_protocol |
25 |
av_register_protocol(&mpeg1_file_protocol); |
26 |
#else |
27 |
- register_protocol(&mpeg1_file_protocol); |
28 |
+# warning av_register_protocolXXX missing |
29 |
#endif |
30 |
} |
31 |
|
32 |
@@ -258,7 +265,11 @@ |
33 |
/* We use "mpeg1video" for raw mpeg1 format. Using "mpeg" would |
34 |
* result in a muxed output file, which isn't appropriate here. |
35 |
*/ |
36 |
- of = guess_format("mpeg1video", NULL, NULL); |
37 |
+#ifdef GUESS_NO_DEPRECATED |
38 |
+ of = guess_format("mpeg1video", NULL, NULL); |
39 |
+#else |
40 |
+ of = av_guess_format("mpeg1video", NULL, NULL); |
41 |
+#endif |
42 |
if (of) { |
43 |
/* But we want the trailer to be correctly written. */ |
44 |
of->write_trailer = mpeg1_write_trailer; |
45 |
@@ -270,24 +281,44 @@ |
46 |
#endif |
47 |
} else if (strcmp(codec, "mpeg4") == 0) { |
48 |
ext = ".avi"; |
49 |
- of = guess_format("avi", NULL, NULL); |
50 |
+#ifdef GUESS_NO_DEPRECATED |
51 |
+ of = guess_format("mpeg1video", NULL, NULL); |
52 |
+#else |
53 |
+ of = av_guess_format("avi", NULL, NULL); |
54 |
+#endif |
55 |
} else if (strcmp(codec, "msmpeg4") == 0) { |
56 |
ext = ".avi"; |
57 |
- of = guess_format("avi", NULL, NULL); |
58 |
+#ifdef GUESS_NO_DEPRECATED |
59 |
+ of = guess_format("mpeg1video", NULL, NULL); |
60 |
+#else |
61 |
+ of = av_guess_format("avi", NULL, NULL); |
62 |
+#endif |
63 |
if (of) { |
64 |
/* Manually override the codec id. */ |
65 |
of->video_codec = CODEC_ID_MSMPEG4V2; |
66 |
} |
67 |
} else if (strcmp(codec, "swf") == 0) { |
68 |
ext = ".swf"; |
69 |
- of = guess_format("swf", NULL, NULL); |
70 |
+#ifdef GUESS_NO_DEPRECATED |
71 |
+ of = guess_format("mpeg1video", NULL, NULL); |
72 |
+#else |
73 |
+ of = av_guess_format("swf", NULL, NULL); |
74 |
+#endif |
75 |
} else if (strcmp(codec, "flv") == 0) { |
76 |
ext = ".flv"; |
77 |
- of = guess_format("flv", NULL, NULL); |
78 |
+#ifdef GUESS_NO_DEPRECATED |
79 |
+ of = guess_format("mpeg1video", NULL, NULL); |
80 |
+#else |
81 |
+ of = av_guess_format("flv", NULL, NULL); |
82 |
+#endif |
83 |
of->video_codec = CODEC_ID_FLV1; |
84 |
} else if (strcmp(codec, "ffv1") == 0) { |
85 |
ext = ".avi"; |
86 |
- of = guess_format("avi", NULL, NULL); |
87 |
+#ifdef GUESS_NO_DEPRECATED |
88 |
+ of = guess_format("mpeg1video", NULL, NULL); |
89 |
+#else |
90 |
+ of = av_guess_format("avi", NULL, NULL); |
91 |
+#endif |
92 |
if (of) { |
93 |
/* Use the FFMPEG Lossless Video codec (experimental!). |
94 |
Requires strict_std_compliance to be <= -2 */ |
95 |
@@ -295,7 +326,11 @@ |
96 |
} |
97 |
} else if (strcmp(codec, "mov") == 0) { |
98 |
ext = ".mov"; |
99 |
- of = guess_format("mov", NULL, NULL); |
100 |
+#ifdef GUESS_NO_DEPRECATED |
101 |
+ of = guess_format("mpeg1video", NULL, NULL); |
102 |
+#else |
103 |
+ of = av_guess_format("mov", NULL, NULL); |
104 |
+#endif |
105 |
} else { |
106 |
motion_log(LOG_ERR, 0, "ffmpeg_video_codec option value %s is not supported", codec); |
107 |
return NULL; |
108 |
@@ -340,7 +375,13 @@ |
109 |
snprintf(ffmpeg->codec, sizeof(ffmpeg->codec), "%s", ffmpeg_video_codec); |
110 |
|
111 |
/* allocation the output media context */ |
112 |
+#ifdef have_avformat_alloc_context |
113 |
+ ffmpeg->oc = avformat_alloc_context(); |
114 |
+#elif defined have_av_avformat_alloc_context |
115 |
+ ffmpeg->oc = av_alloc_format_context(); |
116 |
+#else |
117 |
ffmpeg->oc = av_mallocz(sizeof(AVFormatContext)); |
118 |
+#endif |
119 |
|
120 |
if (!ffmpeg->oc) { |
121 |
motion_log(LOG_ERR, 1, "Memory error while allocating output media context"); |
122 |
@@ -377,7 +418,11 @@ |
123 |
|
124 |
ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st); |
125 |
c->codec_id = ffmpeg->oc->oformat->video_codec; |
126 |
+#if LIBAVCODEC_VERSION_MAJOR < 53 |
127 |
c->codec_type = CODEC_TYPE_VIDEO; |
128 |
+#else |
129 |
+ c->codec_type = AVMEDIA_TYPE_VIDEO; |
130 |
+#endif |
131 |
is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO; |
132 |
|
133 |
if (strcmp(ffmpeg_video_codec, "ffv1") == 0) |
134 |
@@ -646,7 +691,11 @@ |
135 |
if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) { |
136 |
/* raw video case. The API will change slightly in the near future for that */ |
137 |
#ifdef FFMPEG_AVWRITEFRAME_NEWAPI |
138 |
+#if LIBAVCODEC_VERSION_MAJOR < 53 |
139 |
pkt.flags |= PKT_FLAG_KEY; |
140 |
+#else |
141 |
+ pkt.flags |= AV_PKT_FLAG_KEY; |
142 |
+#endif |
143 |
pkt.data = (uint8_t *)pic; |
144 |
pkt.size = sizeof(AVPicture); |
145 |
ret = av_write_frame(ffmpeg->oc, &pkt); |
146 |
@@ -667,7 +716,11 @@ |
147 |
#ifdef FFMPEG_AVWRITEFRAME_NEWAPI |
148 |
pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts; |
149 |
if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame) { |
150 |
+#if LIBAVCODEC_VERSION_MAJOR < 53 |
151 |
pkt.flags |= PKT_FLAG_KEY; |
152 |
+#else |
153 |
+ pkt.flags |= AV_PKT_FLAG_KEY; |
154 |
+#endif |
155 |
} |
156 |
pkt.data = ffmpeg->video_outbuf; |
157 |
pkt.size = out_size; |