Mercurial > mplayer.hg
annotate libmpdemux/muxer_lavf.c @ 17026:3c4b93bc0db3
10l
author | lorenm |
---|---|
date | Tue, 22 Nov 2005 05:32:28 +0000 |
parents | dd5be8f8d16d |
children | cf6bfdf41143 |
rev | line source |
---|---|
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
1 #include <stdio.h> |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
2 #include <stdlib.h> |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
3 #include <string.h> |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
4 #include <sys/types.h> |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
5 #include <inttypes.h> |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
6 #include "config.h" |
17012 | 7 #include "version.h" |
8 #include "mp_msg.h" | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
9 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
10 #include "bswap.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
11 #include "aviheader.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
12 #include "ms_hdr.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
13 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
14 #include "muxer.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
15 #include "stream.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
16 #include "demuxer.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
17 #include "stheader.h" |
17012 | 18 #include "m_option.h" |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
19 #include "avformat.h" |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
20 |
15058 | 21 extern unsigned int codec_get_wav_tag(int id); |
22 extern enum CodecID codec_get_bmp_id(unsigned int tag); | |
23 extern enum CodecID codec_get_wav_id(unsigned int tag); | |
24 | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
25 typedef struct { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
26 //AVInputFormat *avif; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
27 AVFormatContext *oc; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
28 ByteIOContext pb; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
29 int audio_streams; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
30 int video_streams; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
31 int64_t last_pts; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
32 } muxer_priv_t; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
33 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
34 typedef struct { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
35 int64_t last_pts; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
36 AVStream *avstream; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
37 } muxer_stream_priv_t; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
38 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
39 static char *conf_format = NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
40 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
41 m_option_t lavfopts_conf[] = { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
42 {"format", &(conf_format), CONF_TYPE_STRING, 0, 0, 0, NULL}, |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
43 {NULL, NULL, 0, 0, 0, 0, NULL} |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
44 }; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
45 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
46 static int mp_open(URLContext *h, const char *filename, int flags) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
47 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
48 return 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
49 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
50 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
51 static int mp_close(URLContext *h) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
52 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
53 return 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
54 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
55 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
56 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
57 static int mp_read(URLContext *h, unsigned char *buf, int size) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
58 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
59 fprintf(stderr, "READ %d\n", size); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
60 return -1; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
61 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
62 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
63 static int mp_write(URLContext *h, unsigned char *buf, int size) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
64 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
65 muxer_t *muxer = (muxer_t*)h->priv_data; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
66 return fwrite(buf, 1, size, muxer->file); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
67 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
68 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
69 static offset_t mp_seek(URLContext *h, offset_t pos, int whence) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
70 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
71 muxer_t *muxer = (muxer_t*)h->priv_data; |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16200
diff
changeset
|
72 fprintf(stderr, "SEEK %"PRIu64"\n", (int64_t)pos); |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
73 return fseeko(muxer->file, pos, whence); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
74 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
75 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
76 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
77 static URLProtocol mp_protocol = { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
78 "menc", |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
79 mp_open, |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
80 mp_read, |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
81 mp_write, |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
82 mp_seek, |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
83 mp_close, |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
84 NULL |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
85 }; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
86 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
87 static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
88 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
89 muxer_priv_t *priv = (muxer_priv_t*) muxer->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
90 muxer_stream_t *stream; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
91 muxer_stream_priv_t *spriv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
92 AVCodecContext *ctx; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
93 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
94 if(!muxer || (type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO)) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
95 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
96 mp_msg(MSGT_MUXER, MSGL_ERR, "UNKNOW TYPE %d\n", type); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
97 return NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
98 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
99 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
100 stream = (muxer_stream_t*) calloc(1, sizeof(muxer_stream_t)); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
101 if(!stream) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
102 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
103 mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc muxer_stream, EXIT\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
104 return NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
105 } |
17023
dd5be8f8d16d
buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents:
17012
diff
changeset
|
106 muxer->streams[muxer->avih.dwStreams] = stream; |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
107 stream->b_buffer = (unsigned char *)malloc(2048); |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
108 if(!stream->b_buffer) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
109 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
110 mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc b_buffer, EXIT\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
111 free(stream); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
112 return NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
113 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
114 stream->b_buffer_size = 2048; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
115 stream->b_buffer_ptr = 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
116 stream->b_buffer_len = 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
117 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
118 spriv = (muxer_stream_priv_t*) calloc(1, sizeof(muxer_stream_priv_t)); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
119 if(!spriv) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
120 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
121 free(stream); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
122 return NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
123 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
124 stream->priv = spriv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
125 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
126 spriv->avstream = av_new_stream(priv->oc, 1); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
127 if(!spriv->avstream) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
128 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
129 mp_msg(MSGT_MUXER, MSGL_ERR, "Could not alloc avstream, EXIT\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
130 return NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
131 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
132 spriv->avstream->stream_copy = 1; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
133 |
16001 | 134 #if LIBAVFORMAT_BUILD >= 4629 |
135 ctx = spriv->avstream->codec; | |
136 #else | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
137 ctx = &(spriv->avstream->codec); |
16001 | 138 #endif |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
139 ctx->codec_id = muxer->avih.dwStreams; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
140 switch(type) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
141 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
142 case MUXER_TYPE_VIDEO: |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
143 ctx->codec_type = CODEC_TYPE_VIDEO; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
144 break; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
145 case MUXER_TYPE_AUDIO: |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
146 ctx->codec_type = CODEC_TYPE_AUDIO; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
147 break; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
148 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
149 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
150 muxer->avih.dwStreams++; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
151 stream->muxer = muxer; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
152 stream->type = type; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
153 mp_msg(MSGT_MUXER, MSGL_V, "ALLOCATED STREAM N. %d, type=%d\n", muxer->avih.dwStreams, type); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
154 return stream; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
155 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
156 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
157 |
15058 | 158 static void fix_parameters(muxer_stream_t *stream) |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
159 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
160 muxer_stream_priv_t *spriv = (muxer_stream_priv_t *) stream->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
161 AVCodecContext *ctx; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
162 |
16001 | 163 #if LIBAVFORMAT_BUILD >= 4629 |
164 ctx = spriv->avstream->codec; | |
165 #else | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
166 ctx = &(spriv->avstream->codec); |
16001 | 167 #endif |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
168 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
169 if(stream->type == MUXER_TYPE_AUDIO) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
170 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
171 ctx->codec_id = codec_get_wav_id(stream->wf->wFormatTag); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
172 ctx->codec_tag = codec_get_wav_tag(ctx->codec_id); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
173 mp_msg(MSGT_MUXER, MSGL_INFO, "AUDIO CODEC ID: %x, TAG: %x\n", ctx->codec_id, (uint32_t) ctx->codec_tag); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
174 ctx->bit_rate = stream->wf->nAvgBytesPerSec * 8; |
15005 | 175 ctx->sample_rate = stream->wf->nSamplesPerSec; |
176 // mp_msg(MSGT_MUXER, MSGL_INFO, "stream->h.dwSampleSize: %d\n", stream->h.dwSampleSize); | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
177 ctx->channels = stream->wf->nChannels; |
15011 | 178 if(stream->h.dwRate && (stream->h.dwScale * (int64_t)ctx->sample_rate) % stream->h.dwRate == 0) |
179 ctx->frame_size= (stream->h.dwScale * (int64_t)ctx->sample_rate) / stream->h.dwRate; | |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
180 mp_msg(MSGT_MUXER, MSGL_V, "MUXER_LAVF(audio stream) frame_size: %d, scale: %u, sps: %u, rate: %u, ctx->block_align = stream->wf->nBlockAlign; %d=%d stream->wf->nAvgBytesPerSec:%d\n", |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
181 ctx->frame_size, stream->h.dwScale, ctx->sample_rate, stream->h.dwRate, |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
182 ctx->block_align, stream->wf->nBlockAlign, stream->wf->nAvgBytesPerSec); |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
183 ctx->block_align = stream->wf->nBlockAlign; |
15500 | 184 if(stream->wf+1 && stream->wf->cbSize) |
185 { | |
186 ctx->extradata = av_malloc(stream->wf->cbSize); | |
187 if(ctx->extradata != NULL) | |
188 { | |
189 ctx->extradata_size = stream->wf->cbSize; | |
190 memcpy(ctx->extradata, stream->wf+1, ctx->extradata_size); | |
191 } | |
192 else | |
193 mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(audio stream) error! couldn't allocate %d bytes for extradata\n", | |
194 stream->wf->cbSize); | |
195 } | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
196 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
197 else if(stream->type == MUXER_TYPE_VIDEO) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
198 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
199 ctx->codec_id = codec_get_bmp_id(stream->bih->biCompression); |
16200 | 200 ctx->codec_tag= stream->bih->biCompression; |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
201 mp_msg(MSGT_MUXER, MSGL_INFO, "VIDEO CODEC ID: %d\n", ctx->codec_id); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
202 ctx->width = stream->bih->biWidth; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
203 ctx->height = stream->bih->biHeight; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
204 ctx->bit_rate = 800000; |
15309
cfbd8e4b3ede
at lest this fixes build.. there's no way muxer_lavf is working right yet tho with mencoder's broken timestamps
rfelker
parents:
15198
diff
changeset
|
205 #if (LIBAVFORMAT_BUILD >= 4624) |
cfbd8e4b3ede
at lest this fixes build.. there's no way muxer_lavf is working right yet tho with mencoder's broken timestamps
rfelker
parents:
15198
diff
changeset
|
206 ctx->time_base.den = stream->h.dwRate; |
cfbd8e4b3ede
at lest this fixes build.. there's no way muxer_lavf is working right yet tho with mencoder's broken timestamps
rfelker
parents:
15198
diff
changeset
|
207 ctx->time_base.num = stream->h.dwScale; |
cfbd8e4b3ede
at lest this fixes build.. there's no way muxer_lavf is working right yet tho with mencoder's broken timestamps
rfelker
parents:
15198
diff
changeset
|
208 #else |
15011 | 209 ctx->frame_rate = stream->h.dwRate; |
210 ctx->frame_rate_base = stream->h.dwScale; | |
15309
cfbd8e4b3ede
at lest this fixes build.. there's no way muxer_lavf is working right yet tho with mencoder's broken timestamps
rfelker
parents:
15198
diff
changeset
|
211 #endif |
15500 | 212 if(stream->bih+1 && (stream->bih->biSize > sizeof(BITMAPINFOHEADER))) |
213 { | |
214 ctx->extradata = av_malloc(stream->bih->biSize - sizeof(BITMAPINFOHEADER)); | |
215 if(ctx->extradata != NULL) | |
216 { | |
217 ctx->extradata_size = stream->bih->biSize - sizeof(BITMAPINFOHEADER); | |
218 memcpy(ctx->extradata, stream->bih+1, ctx->extradata_size); | |
219 } | |
220 else | |
221 mp_msg(MSGT_MUXER, MSGL_ERR, "MUXER_LAVF(video stream) error! couldn't allocate %d bytes for extradata\n", | |
222 stream->bih->biSize - sizeof(BITMAPINFOHEADER)); | |
223 } | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
224 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
225 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
226 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
227 static void write_chunk(muxer_stream_t *stream, size_t len, unsigned int flags) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
228 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
229 muxer_t *muxer = (muxer_t*) stream->muxer; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
230 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
231 muxer_stream_priv_t *spriv = (muxer_stream_priv_t *) stream->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
232 AVPacket pkt; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
233 |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
234 if(len) |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
235 { |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
236 av_init_packet(&pkt); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
237 pkt.size = len; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
238 pkt.stream_index= spriv->avstream->index; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
239 pkt.data = stream->buffer; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
240 |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
241 if(flags & AVIIF_KEYFRAME) |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
242 pkt.flags |= PKT_FLAG_KEY; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
243 else |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
244 pkt.flags = 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
245 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
246 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
247 //pkt.pts = AV_NOPTS_VALUE; |
15314 | 248 #if LIBAVFORMAT_BUILD >= 4624 |
249 pkt.pts = (stream->timer / av_q2d(priv->oc->streams[pkt.stream_index]->time_base) + 0.5); | |
250 #else | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
251 pkt.pts = AV_TIME_BASE * stream->timer; |
15314 | 252 #endif |
253 //fprintf(stderr, "%Ld %Ld id:%d tb:%f %f\n", pkt.dts, pkt.pts, pkt.stream_index, av_q2d(priv->oc->streams[pkt.stream_index]->time_base), stream->timer); | |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
254 |
15198
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
255 if(av_interleaved_write_frame(priv->oc, &pkt) != 0) //av_write_frame(priv->oc, &pkt) |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
256 { |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
257 mp_msg(MSGT_MUXER, MSGL_ERR, "Error while writing frame\n"); |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
258 } |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
259 } |
847a9a75baa0
added missing initializer in URLProtocolo; mux packets only if len > 0; second mencoder's a/v sync model
nicodvb
parents:
15058
diff
changeset
|
260 |
14757
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
261 return; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
262 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
263 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
264 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
265 static void write_header(muxer_t *muxer) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
266 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
267 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
268 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
269 av_write_header(priv->oc); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
270 muxer->cont_write_header = NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
271 mp_msg(MSGT_MUXER, MSGL_INFO, "WRITTEN HEADER\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
272 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
273 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
274 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
275 static void write_trailer(muxer_t *muxer) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
276 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
277 int i; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
278 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
279 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
280 av_write_trailer(priv->oc); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
281 mp_msg(MSGT_MUXER, MSGL_INFO, "WRITTEN TRAILER\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
282 for(i = 0; i < priv->oc->nb_streams; i++) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
283 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
284 av_freep(&(priv->oc->streams[i])); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
285 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
286 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
287 url_fclose(&(priv->oc->pb)); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
288 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
289 av_free(priv->oc); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
290 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
291 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
292 extern char *out_filename; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
293 int muxer_init_muxer_lavf(muxer_t *muxer) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
294 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
295 muxer_priv_t *priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
296 AVOutputFormat *fmt = NULL; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
297 char mp_filename[256] = "menc://stream.dummy"; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
298 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
299 priv = (muxer_priv_t *) calloc(1, sizeof(muxer_priv_t)); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
300 if(priv == NULL) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
301 return 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
302 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
303 av_register_all(); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
304 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
305 priv->oc = av_alloc_format_context(); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
306 if(!priv->oc) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
307 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
308 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't get format context\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
309 goto fail; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
310 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
311 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
312 if(conf_format) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
313 fmt = guess_format(conf_format, NULL, NULL); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
314 if(! fmt) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
315 fmt = guess_format(NULL, out_filename, NULL); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
316 if(! fmt) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
317 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
318 mp_msg(MSGT_MUXER, MSGL_FATAL, "CAN'T GET SPECIFIED FORMAT\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
319 goto fail; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
320 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
321 priv->oc->oformat = fmt; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
322 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
323 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
324 if(av_set_parameters(priv->oc, NULL) < 0) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
325 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
326 mp_msg(MSGT_MUXER, MSGL_FATAL, "Invalid output format parameters\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
327 goto fail; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
328 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
329 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
330 register_protocol(&mp_protocol); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
331 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
332 if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY)) |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
333 { |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
334 mp_msg(MSGT_MUXER, MSGL_FATAL, "Coulnd't open outfile\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
335 goto fail; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
336 } |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
337 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
338 ((URLContext*)(priv->oc->pb.opaque))->priv_data= muxer; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
339 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
340 muxer->priv = (void *) priv; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
341 muxer->cont_new_stream = &lavf_new_stream; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
342 muxer->cont_write_chunk = &write_chunk; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
343 muxer->cont_write_header = &write_header; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
344 muxer->cont_write_index = &write_trailer; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
345 muxer->fix_stream_parameters = &fix_parameters; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
346 mp_msg(MSGT_MUXER, MSGL_INFO, "OK, exit\n"); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
347 return 1; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
348 |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
349 fail: |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
350 free(priv); |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
351 return 0; |
7a2adc5e8928
initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents:
diff
changeset
|
352 } |