2 2004/09/10 - Joseph Fenton, changed to support
3 playing audio-only streams. Removed code that
4 killed using audio in AROS. Put conditional
5 around gtk_init() for AROS.
10 #include <exec/types.h>
12 int audio_sample_rate
, audio_channels
= -1;
13 int frame_width
= 320, frame_height
= 240, use_audio
= 0;
15 int verbose
= 0, debugging
= 0;
16 int benchmark_mode
= 0;
17 double frame_rate
= 20.0;
19 LONG __stack
= 600000; /* Make it big!! */
21 void show_formats(void)
26 printf("Input audio/video file formats:");
27 for(ifmt
= first_iformat
; ifmt
!= NULL
; ifmt
= ifmt
->next
) {
28 printf(" %s", ifmt
->name
);
33 for(p
= first_avcodec
; p
!= NULL
; p
= p
->next
) {
35 printf(" %s", p
->name
);
43 #if defined(AMIGA) || defined(AROS)
44 #include <proto/dos.h>
45 BPTR lock
= NULL
, oldlock
;
56 int main(int argc
, char *argv
[])
61 AVInputFormat
*file_iformat
= NULL
;
62 AVFormatParameters params
;
67 while ((i
= getopt(argc
, argv
, "hbBndvif:")) != EOF
) {
70 printf("Usage: %s [options] [filename]\n"
72 "-n\tDisable audio.\n"
73 "-b\tBenchmark mode (no display, no audio)\n"
74 "-B\tBenchmark mode (no audio)\n"
76 "-i\tShow supported formats and exits\n"
77 "-d\tDelay initialization for debugging purposes\n"
78 "-f <value>\tForce frames per second to value\n"
95 force_fps
= atoi(optarg
);
104 printf("Unknown option %c\n", i
);
109 if((argc
-optind
) != 1) {
114 gtk_init(&argc
, &argv
);
118 f
.Title
= "Select a movie to play...";
120 f
.Filter
= "All supported files|*.mpg;*.avi;*.mov;*.qt;*.asf;*.mpeg|MPEG Files|*.mpg;*.mpeg|AVI Files|*.avi|Quicktime Files|*.qt;*.mov|All files|*.*\0\0";
124 // the following code is due to the fact avformat has a few problems with Amigalike paths...
125 #if defined(AMIGA) || defined(AROS)
126 filename
= FilePart(f
.File
);
127 if (strcmp(filename
, f
.File
)) {
128 lock
= Lock(PathPart(f
.File
), ACCESS_READ
);
131 oldlock
= CurrentDir(lock
);
143 filename
= argv
[optind
];
145 if((c
= strrchr(filename
, '.'))) {
146 file_iformat
= av_find_input_format(c
+ 1);
148 printf("First guess of fileformat: %s\n",
149 file_iformat
? file_iformat
->name
: "UNKNOWN");
152 memset(¶ms
, 0, sizeof(params
));
154 if(av_open_input_file(&ic
, filename
, NULL
/*file_iformat*/, 0, ¶ms
) < 0) {
155 fprintf(stderr
, "Unable to find format of %s\n", filename
);
159 if(av_find_stream_info(ic
) < 0) {
160 fprintf(stderr
, "%s: could not find codec parameters\n", filename
);
165 dump_format(ic
, 0, filename
, 0);
168 fprintf(stderr
, "Examining %d streams...\n", ic
->nb_streams
);
170 for(i
=0;i
<ic
->nb_streams
;i
++) {
171 AVCodecContext
*enc
= &ic
->streams
[i
]->codec
;
172 switch(enc
->codec_type
) {
173 case CODEC_TYPE_AUDIO
:
174 if(use_audio
!= -1) {
176 audio_channels
= enc
->channels
;
177 audio_sample_rate
= enc
->sample_rate
;
180 fprintf(stderr
, "audio: %d/%d\n",
181 enc
->sample_rate
, enc
->channels
);
185 case CODEC_TYPE_VIDEO
:
187 frame_height
= enc
->height
;
188 frame_width
= enc
->width
;
189 frame_rate
= (double)ic
->streams
[i
]->r_frame_rate
/ (double)ic
->streams
[i
]->r_frame_rate_base
;
191 enc
->workaround_bugs
= FF_BUG_AUTODETECT
;
192 enc
->error_resilience
= 2;
193 enc
->error_concealment
= 3;
197 fprintf(stderr
, "FPS forced from %f to %f.\n",
198 frame_rate
, (double) force_fps
);
199 frame_rate
= force_fps
;
203 fprintf(stderr
, "video: %dx%d %f fps\n",
204 frame_width
, frame_height
, frame_rate
);
210 if(!(c
= strrchr(filename
,
221 if(benchmark_mode
|| use_audio
== -1)
225 fprintf(stderr
, "Initializing the audio/video section...\n");
234 fprintf(stderr
, "Start decoding %s (%lx/%d)...\n", c
, ic
, ic
->nb_streams
);
239 play_decode_stream(ic
);