avidump.c
资源名称:NETVIDEO.rar [点击查看]
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:5k
源码类别:
流媒体/Mpeg4/MP4
开发平台:
Visual C++
- /*
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is MPEG4IP.
- *
- * The Initial Developer of the Original Code is Cisco Systems Inc.
- * Portions created by Cisco Systems Inc. are
- * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
- *
- * Contributor(s):
- * Dave Mackie dmackie@cisco.com
- * Bill May wmay@cisco.com
- */
- #include <math.h>
- #include <mpeg4ip.h>
- #include <mpeg4ip_getopt.h>
- #include <avilib.h>
- /* globals */
- char* progName;
- static struct {
- const char *name;
- int value;
- } audio_names[] = {
- {"UNKNOWN", 0x0000},
- {"PCM", 0x0001},
- {"ADPCM", 0x0002},
- {"IBM_CVSD", 0x0005},
- {"ALAW", 0x0006},
- {"MULAW", 0x0007},
- {"OKI_ADPCM", 0x0010},
- {"DVI_ADPCM", 0x0011},
- {"DIGISTD", 0x0015},
- {"DIGIFIX", 0x0016},
- {"YAMAHA_ADPCM", 0x0020},
- {"DSP_TRUESPEECH", 0x0022},
- {"GSM610", 0x0031},
- {"IBMMULAW", 0x0101},
- {"IBMALAW", 0x0102},
- {"IBMADPCM", 0x0103},
- { NULL, 0},
- };
- /*
- *avidump
- * required arg1 should be file to check
- */
- int main(int argc, char** argv)
- {
- /* internal variables */
- char* aviFileName = NULL;
- avi_t* aviFile = NULL;
- FILE* rawFile = NULL;
- uint32_t numVideoFrames;
- int ix, format;
- const char *aname;
- /* begin process command line */
- progName = argv[0];
- while (1) {
- int c = -1;
- int option_index = 0;
- static struct option long_options[] = {
- { "version", 0, 0, 'V'},
- { "help", 0, 0, '?'},
- { NULL, 0, 0, 0 }
- };
- c = getopt_long_only(argc, argv, "Vh",
- long_options, &option_index);
- if (c == -1)
- break;
- switch (c) {
- case '?':
- fprintf(stderr, "%s <filename>", progName);
- return (0);
- case 'V':
- fprintf(stderr, "%s - %s version %sn", progName,
- PACKAGE, VERSION);
- return (0);
- default:
- fprintf(stderr, "%s: unknown option specified, ignoring: %cn",
- progName, c);
- }
- }
- /* check that we have at least two non-option arguments */
- if ((argc - optind) < 1) {
- fprintf(stderr,
- "usage: %s <avi-file> ...n",
- progName);
- exit(1);
- }
- fprintf(stderr, "%s - %s version %sn",
- progName, PACKAGE, VERSION);
- /* point to the specified file names */
- while (optind < argc) {
- aviFileName = argv[optind++];
- if (aviFileName == NULL) return (0);
- /* open the AVI file */
- aviFile = AVI_open_input_file(aviFileName, TRUE);
- if (aviFile == NULL) {
- fprintf(stderr,
- "%s: error %s: %sn",
- progName, aviFileName, AVI_strerror());
- exit(4);
- }
- fprintf(stdout, "%sn", aviFileName);
- numVideoFrames = AVI_video_frames(aviFile);
- if (numVideoFrames != 0) {
- fprintf(stdout, "Video Informationn");
- fprintf(stdout,
- " Video compressor: %sn",
- AVI_video_compressor(aviFile));
- fprintf(stdout,
- " Video frame rate: %gn",
- AVI_video_frame_rate(aviFile));
- fprintf(stdout, " Number of frames: %un", numVideoFrames);
- fprintf(stdout, " Video height : %dn", AVI_video_height(aviFile));
- fprintf(stdout, " Video width : %dn", AVI_video_width(aviFile));
- } else {
- fprintf(stdout, "No video framesn");
- }
- if (AVI_audio_bytes(aviFile) != 0) {
- fprintf(stdout, "Audio information:n");
- fprintf(stdout, " Audio channels: %dn", AVI_audio_channels(aviFile));
- fprintf(stdout, " Audio bits/sample: %dn", AVI_audio_bits(aviFile));
- format = AVI_audio_format(aviFile);
- for (ix = 0, aname = NULL;
- aname == NULL && audio_names[ix].name != NULL;
- ix++) {
- if (audio_names[ix].value == format) {
- aname = audio_names[ix].name;
- }
- }
- if (aname == NULL) aname = "Format not in list";
- fprintf(stdout, " Audio format: %d %sn", format, aname);
- fprintf(stdout, " Audio sample rate: %dn", AVI_audio_rate(aviFile));
- fprintf(stdout, " Audio bytes: %dn", AVI_audio_bytes(aviFile));
- } else {
- fprintf(stdout, "No audio bytesn");
- }
- /* cleanup */
- AVI_close(aviFile);
- }
- return(0);
- }