jbavari / cordova-plugin-video-editor

A cordova plugin to edit videos.
Other
289 stars 235 forks source link

Feature suggestion: add ffprobe #14

Open razwasserstein opened 9 years ago

razwasserstein commented 9 years ago

It would be nice to be able to get the length of the movie file, resolution etc.. before calling transcode.

Thanks, Doron

rossmartin commented 8 years ago

This is now possible on android using execFFMPEG (I added it in 1.0.1).

bertho-zero commented 8 years ago

:+1:

How can i use ffmpeg for return a ffprobe json result ?

rossmartin commented 8 years ago

Thanks I see the issue here @razwasserstein @bertho-zero

I plan on making a method for both platforms that lets you get information on a video (duration, size, width, height, codec, etc.)

I should probably return the result provided from the execFFMPEG call, I'll look into this.

bertho-zero commented 8 years ago

ffprobe is an other binary file.

bertho-zero commented 8 years ago

The below code :

var cmd = ['-i', inputFilePath, '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams'];

VideoEditor.execFFPROBE(
    ffmpegSuccess,
    ffmpegError,
    {
        cmd: cmd,
        progress: function(info) {
            console.log(info);
        }
    }
);

function ffmpegSuccess(result) {
    console.log('execFFMPEG success');
}

function ffmpegError(err) {
    console.log('ffmpegError, err: ' + err);
}

echo

{
    "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/180000",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1088,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 40,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "30000/1001",
            "avg_frame_rate": "900000/30019",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 180114,
            "duration": "2.001267",
            "bit_rate": "16077085",
            "bits_per_raw_sample": "8",
            "nb_frames": "60",
            "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
            },
            "tags": {
                "creation_time": "2016-02-08 03:14:19",
                "language": "eng",
                "handler_name": "VideoHandle"
            }
        },
        {
            "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": 97930,
            "duration": "2.040208",
            "bit_rate": "156364",
            "max_bit_rate": "96000",
            "nb_frames": "95",
            "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
            },
            "tags": {
                "creation_time": "2016-02-08 03:14:19",
                "language": "eng",
                "handler_name": "SoundHandle"
            }
        }
    ],
    "format": {
        "filename": "/storage/emulated/0/DCIM/100ANDRO/MOV_0591.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "2.027000",
        "size": "4095746",
        "bit_rate": "16164759",
        "probe_score": 100,
        "tags": {
            "major_brand": "mp42",
            "minor_version": "0",
            "compatible_brands": "isommp42",
            "creation_time": "2016-02-08 03:14:19",
            "location": "+48.8160+002.3633/",
            "location-eng": "+48.8160+002.3633/"
        }
    }
}