| 6032 | } |
| 6033 | |
| 6034 | static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) |
| 6035 | { |
| 6036 | AVFormatContext *ic = stream->ffmpeg_ic; |
| 6037 | |
| 6038 | // 'Barebones Title' |
| 6039 | title->type = HB_FF_STREAM_TYPE; |
| 6040 | |
| 6041 | // Copy part of the stream path to the title name |
| 6042 | char * name = stream->path; |
| 6043 | char * sep = hb_strr_dir_sep(stream->path); |
| 6044 | if (sep) |
| 6045 | name = sep + 1; |
| 6046 | title->name = strdup(name); |
| 6047 | char *dot_term = strrchr(title->name, '.'); |
| 6048 | if (dot_term) |
| 6049 | *dot_term = '\0'; |
| 6050 | |
| 6051 | if (ic->duration > 0) |
| 6052 | { |
| 6053 | uint64_t dur = ic->duration * 90000 / AV_TIME_BASE; |
| 6054 | title->duration = dur; |
| 6055 | dur /= 90000; |
| 6056 | title->hours = dur / 3600; |
| 6057 | title->minutes = ( dur % 3600 ) / 60; |
| 6058 | title->seconds = dur % 60; |
| 6059 | } |
| 6060 | |
| 6061 | // set the title to decode the first video stream in the file |
| 6062 | title->demuxer = HB_NULL_DEMUXER; |
| 6063 | title->video_codec = 0; |
| 6064 | int i; |
| 6065 | for (i = 0; i < ic->nb_streams; ++i ) |
| 6066 | { |
| 6067 | AVStream * st = ic->streams[i]; |
| 6068 | |
| 6069 | if ( st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
| 6070 | !(st->disposition & AV_DISPOSITION_ATTACHED_PIC) && |
| 6071 | avcodec_find_decoder( st->codecpar->codec_id ) && |
| 6072 | title->video_codec == 0 ) |
| 6073 | { |
| 6074 | AVCodecParameters *codecpar = st->codecpar; |
| 6075 | // Check for unsupported pixel formats. |
| 6076 | // Exclude 'NONE' from check since we may not know this |
| 6077 | // information yet. |
| 6078 | if ( codecpar->format != AV_PIX_FMT_NONE && |
| 6079 | !sws_isSupportedInput( codecpar->format ) ) |
| 6080 | { |
| 6081 | hb_log( "ffmpeg_title_scan: Unsupported pixel format (%d)", |
| 6082 | codecpar->format ); |
| 6083 | continue; |
| 6084 | } |
| 6085 | title->video_id = i; |
| 6086 | stream->ffmpeg_video_id = i; |
| 6087 | if ( st->sample_aspect_ratio.num && |
| 6088 | st->sample_aspect_ratio.den ) |
| 6089 | { |
| 6090 | title->geometry.par.num = st->sample_aspect_ratio.num; |
| 6091 | title->geometry.par.den = st->sample_aspect_ratio.den; |
no test coverage detected