Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingFieldError("codec_name") #23

Closed
mattkanwisher opened this issue Sep 10, 2017 · 2 comments
Closed

MissingFieldError("codec_name") #23

mattkanwisher opened this issue Sep 10, 2017 · 2 comments

Comments

@mattkanwisher
Copy link
Contributor

mattkanwisher commented Sep 10, 2017

Seems if you use a format (mp4) other then MKV you get this error "MissingFieldError("codec_name")". However a simple convert works in ffmpeg. I wasn't sure if there is another way to get around this. I may try my hand at a PR on this, but have never done Rust ;) Great program btw, much easier then sub2srs

ffmpeg -i ~/Downloads/file.mp4 -vcodec copy -acodec copy ~/Downloads/out_file.mkv

@emk
Copy link
Owner

emk commented Sep 12, 2017

OK, I think I have a good idea what's going on here. Could you please run the following for me and post the JSON it outputs?

ffprobe -v quiet -show_streams -of json ~/Downloads/file.mp4

I'll use that JSON to make sure I fix this problem correctly the first time. :-)

Basically, what I need to do is mark some more of the following fields with Option:

/// An individual content stream within a video.
#[derive(Debug, RustcDecodable)]
#[allow(missing_docs, dead_code)]
pub struct Stream {
    pub index: usize,
    pub codec_name: String,
    pub codec_long_name: Option<String>,
    pub codec_type: CodecType,
    pub codec_time_base: Fraction,
    pub codec_tag_string: String,
    pub codec_tag: String,
    pub profile: Option<String>,
    pub width: Option<usize>,
    pub height: Option<usize>,
    //has_b_frames
    //sample_aspect_ratio
    //display_aspect_ratio
    pub pix_fmt: Option<String>,
    pub level: Option<u32>,
    pub sample_rate: Option<f64>,
    pub channels: Option<usize>,
    pub bits_per_sample: Option<u32>,
    //avg_frame_rate
    pub time_base: Fraction,
    pub start_time: f64,
    //duration
    pub tags: Option<BTreeMap<String, String>>,
}

...so that pub codec_name: String becomes pub codec_name: Option<String>. But I'm not sure how many fields I'll need to mark until we can see the JSON. And if substudy is using some of the optional fields, I'll also need to make changes elsewhere.

@mattkanwisher
Copy link
Contributor Author

mattkanwisher commented Sep 12, 2017

fixed in #24 below is the json. I believe it may be because this mp4 file has some extra RTP streams that aren't used? maybe the upstream encoder put in some junk

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "1/50",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 640,
            "height": 360,
            "coded_width": 640,
            "coded_height": 360,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 30,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/12800",
            "start_pts": 1024,
            "start_time": "0.080000",
            "duration_ts": 30249984,
            "duration": "2363.280000",
            "bit_rate": "399846",
            "bits_per_raw_sample": "8",
            "nb_frames": "59082",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/48000",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 113443840,
            "duration": "2363.413333",
            "bit_rate": "64000",
            "max_bit_rate": "64000",
            "nb_frames": "110785",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "language": "eng",
                "handler_name": "SoundHandler"
            }
        },
        {
            "index": 2,
            "codec_type": "data",
            "codec_tag_string": "rtp ",
            "codec_tag": "0x20707472",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 212712930,
            "duration": "2363.477000",
            "bit_rate": "21787",
            "nb_frames": "59082",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "creation_time": "2014-11-12T10:56:23.000000Z",
                "language": "und",
                "handler_name": "GPAC ISO Hint Handler"
            }
        },
        {
            "index": 3,
            "codec_type": "data",
            "codec_tag_string": "rtp ",
            "codec_tag": "0x20707472",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 113446896,
            "duration": "2363.477000",
            "bit_rate": "8364",
            "nb_frames": "14027",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "creation_time": "2014-11-12T10:56:24.000000Z",
                "language": "und",
                "handler_name": "GPAC ISO Hint Handler"
            }
        }
    ]
}

emk added a commit that referenced this issue Sep 14, 2017
This tends to break more often than other parts of substudy, so let's
add some easy-to-use debug logging to help with problems like #23.
@emk emk closed this as completed in e6d50f5 Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants