- /*--------- Stream format
- * stream,index,codec-name,codec-name-long,PROFILE,
- * codec_time_base,codec_tag_string,codec_tag[hex],
- * VIDEO:
- * width,height,has_b_frames,sample_aspect_ratio,display_aspect_ratio
- * pix_fmt,level,
- * timecode
- * AUDIO:
- * sample_fmt,sample_rate,channels,bits_per_sample
- *
- * all cont'd;
- * r_frame_rate,avg_frame_rate,time_base,start_time,duration,
- * bit_rate,nb_frames,nb_read_frames,nb_read_packets
- *
- *---------- Example
- * stream,0,mpeg2video,MPEG-2 video,video,1/50,[0][0][0][0],0x0000,720,576,1,16:15,4:3,yuv420p,8,00:02:30:00,0x1e0,25/1,25/1,1/90000,0.360000,N/A,7000000,N/A,N/A,N/A
- * stream,1,ac3,ATSC A/52A (AC-3),audio,1/48000,[0][0][0][0],0x0000,s16,48000,6,0,-1,-1.000000,-1.000000,-1.000000,-1.000000,0x80,0/0,0/0,1/90000,0.280000,312.992000,448000,N/A,N/A,N/A
- * stream,2,ac3,ATSC A/52A (AC-3),audio,1/48000,[0][0][0][0],0x0000,s16,48000,2,0,-1,-1.000000,-1.000000,-1.000000,-1.000000,0x82,0/0,0/0,1/90000,0.280000,312.992000,384000,N/A,N/A,N/A
- * stream,3,ac3,ATSC A/52A (AC-3),audio,1/48000,[0][0][0][0],0x0000,s16,48000,2,0,-1,-1.000000,-1.000000,-1.000000,-1.000000,0x81,0/0,0/0,1/90000,0.280000,312.992000,192000,N/A,N/A,N/A
- */
- if (i->at(4) == X_("video") && m_width == 0) {
- std::string::size_type pos;
-
- m_width = atoi(i->at(8).c_str());
- m_height = atoi(i->at(9).c_str());
- m_codec = i->at(3) + " -- " + i->at(2);
- m_fps = atof(i->at(17).c_str());
-
- pos = i->at(17).find_first_of('/');
- if (pos != std::string::npos) {
- m_fps = atof(i->at(17).substr(0, pos).c_str()) / atof(i->at(17).substr(pos+1).c_str());
+ if (i->at(5) == X_("codec_type=video") && m_width == 0) {
+
+ for (std::vector<std::string>::iterator kv = i->begin(); kv != i->end(); ++kv) {
+ const size_t kvsep = kv->find('=');
+ if(kvsep == std::string::npos) continue;
+ std::string key = kv->substr(0, kvsep);
+ std::string value = kv->substr(kvsep + 1);
+
+ if (key == X_("index")) {
+ m_videoidx = atoi(value);
+ } else if (key == X_("width")) {
+ m_width = atoi(value);
+ } else if (key == X_("height")) {
+ m_height = atoi(value);
+ } else if (key == X_("codec_name")) {
+ if (!m_codec.empty()) m_codec += " ";
+ m_codec += value;
+ } else if (key == X_("codec_long_name")) {
+ if (!m_codec.empty()) m_codec += " ";
+ m_codec += "[" + value + "]";
+ } else if (key == X_("codec_tag_string")) {
+ if (!m_codec.empty()) m_codec += " ";
+ m_codec += "(" + value + ")";
+ } else if (key == X_("r_frame_rate")) {
+ PARSE_FRACTIONAL_FPS(m_fps)
+ } else if (key == X_("avg_frame_rate") && m_fps == 0) {
+ PARSE_FRACTIONAL_FPS(m_fps)
+ } else if (key == X_("time_base")) {
+ PARSE_FRACTIONAL_FPS(timebase)
+ } else if (key == X_("timecode") && m_duration == 0) {
+ int h,m,s; char f[7];
+ if (sscanf(i->at(16).c_str(), "%d:%d:%d:%s",&h,&m,&s,f) == 4) {
+ m_duration = (ARDOUR::framecnt_t) floor(m_fps * (
+ h * 3600.0
+ + m * 60.0
+ + s * 1.0
+ + atoi(f) / pow(10, strlen(f))
+ ));
+ }
+ } else if (key == X_("duration_ts") && m_fps == 0 && timebase !=0 ) {
+ m_duration = atof(value) * m_fps * timebase;
+ } else if (key == X_("duration") && m_fps != 0 && m_duration == 0) {
+ m_duration = atof(value) * m_fps;
+ } else if (key == X_("display_aspect_ratio")) {
+ std::string::size_type pos;
+ pos = value.find_first_of(':');
+ if (pos != std::string::npos && atof(value.substr(pos+1)) != 0) {
+ m_aspect = atof(value.substr(0, pos)) / atof(value.substr(pos+1));
+ }
+ }