Dan text

ffmpeg version N-69920-g8bc8001 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab le-zlib libavutil 54. 18.100 / 54. 18.100 libavcodec 56. 22.100 / 56. 22.100 libavformat 56. 22.100 / 56. 22.100 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 11.100 / 5. 11.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Downloads\1.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2015-09-27 17:21:17 Duration: 02:34:41.18, start: 0.000000, bitrate: 374 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 275 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default) Metadata: creation_time : 2015-09-27 17:21:37 handler_name : IsoMedia File Produced by Google, 5-11-2011 

You need to find the duration of the video file in this case, it is 02: 34: 41.18 and translate it into seconds.

  • According to community rules, questions should not be reduced to completing tasks for students. Give an example of your implementation describing specific problems. - Nicolas Chabanovsky

2 answers 2

Try this expression:

 Duration:\s(\d+):(\d+):(\d+).(\d+) 

    Learning materiel?

    ffmpeg -i is not correct. It is not intended for that.

    We use ffprobe. It is part of the ffmpeg package.

    Little magic

     # ffprobe -v quiet -print_format json -show_format -show_streams Doctor.Who.s03.e01.Smith.and.Jones.2007.x264.bluray.720p.mkv { "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": "1001/48000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "width": 1264, "height": 720, "has_b_frames": 2, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "79:45", "pix_fmt": "yuv420p", "level": 41, "r_frame_rate": "24000/1001", "avg_frame_rate": "24000/1001", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "bits_per_raw_sample": "8", "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": { "language": "eng" } }, { "index": 1, "codec_name": "ac3", "codec_long_name": "ATSC A/52A (AC-3)", "codec_type": "audio", "codec_time_base": "1/48000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "dmix_mode": "-1", "ltrt_cmixlev": "-1.000000", "ltrt_surmixlev": "-1.000000", "loro_cmixlev": "-1.000000", "loro_surmixlev": "-1.000000", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "bit_rate": "192000", "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": { "language": "rus" } }, { "index": 2, "codec_name": "dca", "codec_long_name": "DCA (DTS Coherent Acoustics)", "profile": "DTS", "codec_type": "audio", "codec_time_base": "1/48000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 6, "channel_layout": "5.1(side)", "bits_per_sample": 0, "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "bit_rate": "1536000", "disposition": { "default": 0, "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": { "language": "eng" } }, { "index": 3, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "codec_time_base": "1/1000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 2800757, "duration": "2800.757000", "disposition": { "default": 0, "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": { "language": "rus" } }, { "index": 4, "codec_name": "subrip", "codec_long_name": "SubRip subtitle", "codec_type": "subtitle", "codec_time_base": "1/1000", "codec_tag_string": "[0][0][0][0]", "codec_tag": "0x0000", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 2800757, "duration": "2800.757000", "disposition": { "default": 0, "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": { "language": "eng" } } ], "format": { "filename": "Doctor.Who.s03.e01.Smith.and.Jones.2007.x264.bluray.720p.mkv", "nb_streams": 5, "nb_programs": 0, "format_name": "matroska,webm", "format_long_name": "Matroska / WebM", "start_time": "0.000000", "duration": "2800.757000", "size": "2411666588", "bit_rate": "6888613", "probe_score": 100, "tags": { "encoder": "libebml v1.3.0 + libmatroska v1.4.1", "creation_time": "2014-03-12 11:41:12" } } }