1 /*******************************************************************************
2 common.c
3
4 libquicktime - A library for reading and writing quicktime/avi/mp4 files.
5 http://libquicktime.sourceforge.net
6
7 Copyright (C) 2002 Heroine Virtual Ltd.
8 Copyright (C) 2002-2011 Members of the libquicktime project.
9
10 This library is free software; you can redistribute it and/or modify it under
11 the terms of the GNU Lesser General Public License as published by the Free
12 Software Foundation; either version 2.1 of the License, or (at your option)
13 any later version.
14
15 This library is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18 details.
19
20 You should have received a copy of the GNU Lesser General Public License along
21 with this library; if not, write to the Free Software Foundation, Inc., 51
22 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *******************************************************************************/
24
25 #include <stdio.h>
26 #include <libintl.h>
27
28 #include <config.h> // ONLY for the PACKAGE macro. Usually, applications never need
29 // to include config.h
30
31 #include <quicktime/lqt.h>
32 #include <quicktime/colormodels.h>
33
34 #include "common.h"
35
36 #define _(str) dgettext(PACKAGE, str)
37
quicktime_print_info(quicktime_t * qtfile)38 void quicktime_print_info(quicktime_t * qtfile)
39 {
40 char * str;
41 int n, i, j, channels;
42 const lqt_channel_t * channel_setup;
43 char language[4];
44 int frame_duration, framerate_constant;
45 int pixel_width, pixel_height;
46 int cmodel;
47 uint32_t timecode_flags;
48 int timecode_rate;
49
50 printf(_("Type: %s\n"), lqt_file_type_to_string(lqt_get_file_type(qtfile)));
51
52
53 str = quicktime_get_copyright(qtfile);
54 if (str)
55 printf(_(" copyright: %s\n"),str);
56
57 str = quicktime_get_name(qtfile);
58 if (str)
59 printf(_(" name: %s\n"),str);
60
61 str = quicktime_get_info(qtfile);
62 if (str)
63 printf(_(" info: %s\n"),str);
64
65 str = lqt_get_author(qtfile);
66 if (str)
67 printf(_(" author: %s\n"),str);
68
69 str = lqt_get_artist(qtfile);
70 if (str)
71 printf(_(" artist: %s\n"),str);
72
73 str = lqt_get_album(qtfile);
74 if (str)
75 printf(_(" album: %s\n"),str);
76
77 str = lqt_get_genre(qtfile);
78 if (str)
79 printf(_(" genre: %s\n"),str);
80
81 str = lqt_get_track(qtfile);
82 if (str)
83 printf(_(" track: %s\n"),str);
84
85 str = lqt_get_comment(qtfile);
86 if (str)
87 printf(_(" comment: %s\n"),str);
88
89
90 n = quicktime_audio_tracks(qtfile);
91 printf(_(" %d audio tracks.\n"), n);
92 for(i = 0; i < n; i++) {
93 channels = quicktime_track_channels(qtfile, i);
94 channel_setup = lqt_get_channel_setup(qtfile, i);
95 printf(_(" %d channels, %d bits, sample rate %ld, length %ld samples, "),
96 channels,
97 quicktime_audio_bits(qtfile, i),
98 quicktime_sample_rate(qtfile, i),
99 quicktime_audio_length(qtfile, i));
100 if(lqt_is_avi(qtfile))
101 {
102 printf(_("wav_id 0x%02x.\n"), lqt_get_wav_id(qtfile, i));
103 }
104 else
105 {
106 printf(_("compressor %s.\n"), quicktime_audio_compressor(qtfile, i));
107 }
108 printf(_(" Sample format: %s.\n"),
109 lqt_sample_format_to_string(lqt_get_sample_format(qtfile, i)));
110 printf(_(" Channel setup: "));
111 if(channel_setup)
112 {
113 for(j = 0; j < channels; j++)
114 {
115 printf("%s", lqt_channel_to_string(channel_setup[j]));
116 if(j < channels-1)
117 printf(_(", "));
118 }
119 printf(_("\n"));
120 }
121 else
122 printf(_("Not available\n"));
123 printf(_(" Language: "));
124 if(lqt_get_audio_language(qtfile, i, language))
125 printf("%c%c%c\n", language[0], language[1], language[2]);
126 else
127 printf(_("Not available\n"));
128 if(quicktime_supported_audio(qtfile, i))
129 printf(_(" supported.\n"));
130 else
131 printf(_(" not supported.\n"));
132 }
133
134 n = quicktime_video_tracks(qtfile);
135 printf(_(" %d video tracks.\n"), n);
136 for(i = 0; i < n; i++)
137 {
138 frame_duration = lqt_frame_duration(qtfile, i, &framerate_constant);
139 lqt_get_pixel_aspect(qtfile, i, &pixel_width, &pixel_height);
140 printf(_(" %dx%d, depth %d\n rate %f [%d:%d] %s\n length %ld frames\n compressor %s.\n"),
141 quicktime_video_width(qtfile, i),
142 quicktime_video_height(qtfile, i),
143 quicktime_video_depth(qtfile, i),
144 quicktime_frame_rate(qtfile, i),
145 lqt_video_time_scale(qtfile, i),
146 frame_duration, (framerate_constant ? _("constant") : _("not constant")),
147 quicktime_video_length(qtfile, i),
148 quicktime_video_compressor(qtfile, i));
149 cmodel = lqt_get_cmodel(qtfile, i);
150 printf(_(" Native colormodel: %s\n"),
151 lqt_colormodel_to_string(cmodel));
152 printf(_(" Interlace mode: %s\n"),
153 lqt_interlace_mode_to_string(lqt_get_interlace_mode(qtfile, i)));
154 if(cmodel == BC_YUV420P)
155 printf(_(" Chroma placement: %s\n"), lqt_chroma_placement_to_string(lqt_get_chroma_placement(qtfile, i)));
156 if((pixel_width > 1) || (pixel_height > 1))
157 printf(_(" Pixel aspect ratio: %d:%d\n"), pixel_width, pixel_height);
158
159 if(lqt_has_timecode_track(qtfile, i, &timecode_flags, &timecode_rate))
160 printf(_(" Timecodes available (flags: %08x, rate: %d)\n"), timecode_flags,
161 timecode_rate);
162 else
163 printf(_(" No timecodes available\n"));
164
165
166 if(quicktime_supported_video(qtfile, i))
167 printf(_(" supported.\n"));
168 else
169 printf(_(" not supported.\n"));
170 }
171
172 n = lqt_text_tracks(qtfile);
173 printf(_(" %d text tracks.\n"), n);
174 for(i = 0; i < n; i++)
175 {
176 printf(_(" timescale: %d, length: %"PRId64", language: "),
177 lqt_text_time_scale(qtfile, i), lqt_text_samples(qtfile, i));
178 if(lqt_get_text_language(qtfile, i, language))
179 printf("%c%c%c, ", language[0], language[1], language[2]);
180 else
181 printf(_("Not available, "));
182 printf(_("type: %s\n"), lqt_is_chapter_track(qtfile, i) ? _("Chapters") : _("Subtitles") );
183 }
184 }
185