Changeset 10030

Show
Ignore:
Timestamp:
04/11/09 08:16:37 (5 years ago)
Author:
robert
Message:

From Jean Sebastien Guay, added error reporting handling of wider range of video formats.

Location:
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoder.cpp

    r9990 r10030  
    33 
    44#include <osg/Notify> 
     5#include <osgDB/FileNameUtils> 
    56 
    67#include <cassert> 
     
    89#include <stdexcept> 
    910#include <string.h> 
    10  
     11#include <iostream> 
    1112 
    1213 
     
    6566            formatParams.time_base.den = 30; 
    6667 
    67             iformat = av_find_input_format("video4linux2"); 
     68            std::string format = "video4linux2"; 
     69            iformat = av_find_input_format(format.c_str()); 
    6870             
    6971            if (iformat) 
    7072            { 
    71                 osg::notify(osg::NOTICE)<<"Found input format"<<std::endl; 
     73                osg::notify(osg::NOTICE)<<"Found input format: "<<format<<std::endl; 
    7274            } 
    7375            else 
    7476            { 
    75                 osg::notify(osg::NOTICE)<<"Failed to find input_format"<<std::endl; 
    76             } 
    77  
    78             if (av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams) != 0) 
    79                 throw std::runtime_error("av_open_input_file() failed"); 
     77                osg::notify(osg::NOTICE)<<"Failed to find input format: "<<format<<std::endl; 
     78            } 
     79 
     80            int error = av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams); 
     81            if (error != 0) 
     82            { 
     83                std::string error_str; 
     84                switch (error) 
     85                { 
     86                    //case AVERROR_UNKNOWN: error_str = "AVERROR_UNKNOWN"; break;   // same value as AVERROR_INVALIDDATA 
     87                    case AVERROR_IO: error_str = "AVERROR_IO"; break; 
     88                    case AVERROR_NUMEXPECTED: error_str = "AVERROR_NUMEXPECTED"; break; 
     89                    case AVERROR_INVALIDDATA: error_str = "AVERROR_INVALIDDATA"; break; 
     90                    case AVERROR_NOMEM: error_str = "AVERROR_NOMEM"; break; 
     91                    case AVERROR_NOFMT: error_str = "AVERROR_NOFMT"; break; 
     92                    case AVERROR_NOTSUPP: error_str = "AVERROR_NOTSUPP"; break; 
     93                    case AVERROR_NOENT: error_str = "AVERROR_NOENT"; break; 
     94                    case AVERROR_PATCHWELCOME: error_str = "AVERROR_PATCHWELCOME"; break; 
     95                    default: error_str = "Unknown error"; break; 
     96                } 
     97 
     98                throw std::runtime_error("av_open_input_file() failed : " + error_str); 
     99            } 
    80100        } 
    81101        else 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegHeaders.hpp

    r9865 r10030  
    77{ 
    88#define __STDC_CONSTANT_MACROS 
     9#ifdef WIN32 
     10#include <errno.h>    // for error codes defined in avformat.h 
     11#endif 
    912#include <stdint.h> 
    1013#include <avcodec.h> 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/ReaderWriterFFmpeg.cpp

    r9968 r10030  
    3030    { 
    3131        supportsProtocol("http","Read video/audio from http using ffmpeg."); 
     32        supportsProtocol("rtsp","Read video/audio from rtsp using ffmpeg."); 
    3233 
    3334        supportsExtension("ffmpeg", ""); 
    34         supportsExtension("avi", ""); 
    35         supportsExtension("flv", ""); 
    36         supportsExtension("mov", ""); 
    37         supportsExtension("ogg", "Theora movie format"); 
    38         supportsExtension("mpg", "Mpeg movie format"); 
    39         supportsExtension("mpv", "Mpeg movie format"); 
    40         supportsExtension("wmv", "Windows Media Video format"); 
    41         supportsExtension("mkv", "Matroska"); 
     35        supportsExtension("avi",    ""); 
     36        supportsExtension("flv",    "Flash video"); 
     37        supportsExtension("mov",    "Quicktime"); 
     38        supportsExtension("ogg",    "Theora movie format"); 
     39        supportsExtension("mpg",    "Mpeg movie format"); 
     40        supportsExtension("mpv",    "Mpeg movie format"); 
     41        supportsExtension("wmv",    "Windows Media Video format"); 
     42        supportsExtension("mkv",    "Matroska"); 
     43        supportsExtension("mjpeg",  "Motion JPEG"); 
     44        supportsExtension("mp4",    "MPEG-4"); 
     45        supportsExtension("sav",    "MPEG-4"); 
     46        supportsExtension("3gp",    "MPEG-4"); 
     47        supportsExtension("sdp",    "MPEG-4"); 
    4248 
    4349        // Register all FFmpeg formats/codecs