linux 入門(七)-ffmpeg使用

来源:https://www.cnblogs.com/zhjing/p/18059280
-Advertisement-
Play Games

linux 入門(七) 1: 安裝ffmpeg ubuntu下安裝ffmpeg: sudo apt-get install ffmpeg 2: ffmpeg --help ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmp ...


linux 入門(七)

1: 安裝ffmpeg

ubuntu下安裝ffmpeg:

sudo apt-get install ffmpeg

2: ffmpeg --help

ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-buildconf          show build configuration
-formats            show available formats
-muxers             show available muxers
-demuxers           show available demuxers
-devices            show available devices
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
-sources device     list sources of the input device
-sinks device       list sinks of the output device
-hwaccels           show available HW acceleration methods

Global options (affect whole program instead of just one file:
-loglevel loglevel  set logging level
-v loglevel         set logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  never overwrite output files
-ignore_unknown     Ignore unknown stream types
-filter_threads     number of non-complex filter threads
-filter_complex_threads  number of threads for -filter_complex
-stats              print progress report during encoding
-max_error_rate maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-to time_stop       record or transcode stop time
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-sseof time_off     set the start time offset relative to EOF
-seek_timestamp     enable/disable seeking by timestamp with -ss
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-program title=string:st=number...  add program with specified streams
-target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad               audio pad
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-filter_script filename  read stream filtergraph description from a file
-reinit_filter      reinit filtergraph on input parameter changes
-discard            discard
-disposition        disposition

Video options:
-vframes number     set the number of video frames to output
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to output
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter_graph    set audio filters

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-canvas_size size   set canvas size (WxH or abbreviation)
-spre preset        set the subtitle options to the indicated preset

3: 轉碼

轉碼視頻格式只需要執行下麵的命令即可:

ffmpeg -i share_5eb7ba669e87b5ab48d50107a249a1c1.mp4 test1.avi

輸出如下:

ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'share_5eb7ba669e87b5ab48d50107a249a1c1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    comment         : vid:v0300fg10000cl7lp5bc77ubt3j4km1g
    encoder         : Lavf58.76.100
  Duration: 00:00:15.30, start: 0.000000, bitrate: 1676 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 1543 kb/s, 54.28 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
  Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, avi, to 'test1.avi':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    ICMT            : vid:v0300fg10000cl7lp5bc77ubt3j4km1g
    ISFT            : Lavf58.29.100
    Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.54.100 libmp3lame
frame=  826 fps=514 q=31.0 Lsize=    3354kB time=00:00:15.30 bitrate=1795.0kbits/s speed=9.53x    
video:3069kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.374900%

3: 視頻壓縮

  1. 指定尺寸

    ffmpeg -i share_5eb7ba669e87b5ab48d50107a249a1c1.mp4 -s 720x360 test1.mp4
    

    原視頻1280x720, 大小3.3m, 修改後720x360 ,大小1.5M.

  2. 修改幀率

    ffmpeg -i share_5eb7ba669e87b5ab48d50107a249a1c1.mp4 -r 20  test5.mp4
    

    原視頻幀率60, 大小3.3M. 修改幀率為20後, 大小為2.9M

  3. 限定視頻大小

    ffmpeg -i share_5eb7ba669e87b5ab48d50107a249a1c1.mp4 -fs 1MB  test6.mp4
    

    該命令會限制輸出文件的大小為1MB.

    但是-fs參數並不會保證輸出的文件在1MB. 它只是告訴ffmpeg在輸出文件到達1MB後停止輸出.

    並且, 如果該命令會導致輸出視頻的長度發生變化,比如之前是16s的視頻, 輸出只有3s.

4: 視頻裁剪

ffmpeg -i share_5eb7ba669e87b5ab48d50107a249a1c1.mp4 -ss 00:00:10 -to 00:00:13 -c copy test7.mp4
  1. "-ss" 參數表示開始裁剪的時間,
  2. "-to" 參數表示裁剪到的時間
  3. "-c copy" 表示覆制原始視頻的編碼格式。

5: 合併視頻

將兩個視頻直接拼接:

創建mp4.txt文件 ,寫入需要拼接的視頻的路徑.如:

file 'share_5eb7ba669e87b5ab48d50107a249a1c1.mp4'file 'test1.mp4'

執行命令:

ffmpeg -f concat -i mp4.txt -c copy test8.mp4

如果某一個視頻有問題,如:無法播放或者文件不存在. 則輸出如下:

ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared  libavutil      56. 31.100 / 56. 31.100  libavcodec     58. 54.100 / 58. 54.100  libavformat    58. 29.100 / 58. 29.100  libavdevice    58.  8.100 / 58.  8.100  libavfilter     7. 57.100 /  7. 57.100  libavresample   4.  0.  0 /  4.  0.  0  libswscale      5.  5.100 /  5.  5.100  libswresample   3.  5.100 /  3.  5.100  libpostproc    55.  5.100 / 55.  5.100[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55964a0ff340] Auto-inserting h264_mp4toannexb bitstream filterInput #0, concat, from 'mp4.txt':  Duration: N/A, start: -0.046440, bitrate: 1671 kb/s    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 1543 kb/s, 54.28 fps, 60 tbr, 15360 tbn, 120 tbc    Metadata:      handler_name    : VideoHandler    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s    Metadata:      handler_name    : SoundHandlerOutput #0, mp4, to 'test8.mp4':  Metadata:    encoder         : Lavf58.29.100    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], q=2-31, 1543 kb/s, 54.28 fps, 60 tbr, 15360 tbn, 15360 tbc    Metadata:      handler_name    : VideoHandler    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s    Metadata:      handler_name    : SoundHandlerStream mapping:  Stream #0:0 -> #0:0 (copy)  Stream #0:1 -> #0:1 (copy)Press [q] to stop, [?] for help[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55964a118200] moov atom not found[concat @ 0x55964a0f56c0] Impossible to open 'test1.mp4'mp4.txt: Invalid data found when processing inputframe=  826 fps=0.0 q=-1.0 Lsize=    3131kB time=00:00:15.32 bitrate=1673.6kbits/s speed=1.23e+03x    video:2867kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.780092%

此時仍然可以生成視頻,只是只有第一個視頻, 第二個未拼接成功.

第二種情況:

兩個視頻的幀率,解析度, 編解碼器不同.

雖然可以成功拼接,但是效果卻差強人意:

ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared  libavutil      56. 31.100 / 56. 31.100  libavcodec     58. 54.100 / 58. 54.100  libavformat    58. 29.100 / 58. 29.100  libavdevice    58.  8.100 / 58.  8.100  libavfilter     7. 57.100 /  7. 57.100  libavresample   4.  0.  0 /  4.  0.  0  libswscale      5.  5.100 /  5.  5.100  libswresample   3.  5.100 /  3.  5.100  libpostproc    55.  5.100 / 55.  5.100[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55acf6064340] Auto-inserting h264_mp4toannexb bitstream filterInput #0, concat, from 'mp4.txt':  Duration: N/A, start: -0.046440, bitrate: 1671 kb/s    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], 1543 kb/s, 54.28 fps, 60 tbr, 15360 tbn, 120 tbc    Metadata:      handler_name    : VideoHandler    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s    Metadata:      handler_name    : SoundHandlerOutput #0, mp4, to 'test8.mp4':  Metadata:    encoder         : Lavf58.29.100    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x1280 [SAR 1:1 DAR 9:16], q=2-31, 1543 kb/s, 54.28 fps, 60 tbr, 15360 tbn, 15360 tbc    Metadata:      handler_name    : VideoHandler    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s    Metadata:      handler_name    : SoundHandlerStream mapping:  Stream #0:0 -> #0:0 (copy)  Stream #0:1 -> #0:1 (copy)Press [q] to stop, [?] for help[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55acf607d200] Auto-inserting h264_mp4toannexb bitstream filter[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675840, current: 124565; changing to 675841. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675841, current: 125589; changing to 675842. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675842, current: 126613; changing to 675843. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675843, current: 127637; changing to 675844. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675844, current: 128661; changing to 675845. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675845, current: 129685; changing to 675846. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675846, current: 130709; changing to 675847. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675847, current: 131733; changing to 675848. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675848, current: 132757; changing to 675849. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675849, current: 133781; changing to 675850. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675850, current: 134805; changing to 675851. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675851, current: 135829; changing to 675852. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675852, current: 136853; changing to 675853. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675853, current: 137877; changing to 675854. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675854, current: 138901; changing to 675855. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675855, current: 139925; changing to 675856. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675856, current: 140949; changing to 675857. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675857, current: 141973; changing to 675858. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675858, current: 142997; changing to 675859. This may result in incorrect timestamps in the output file.[mp4 @ 0x55acf609df40] Non-monotonous DTS in output stream 0:1; previous: 675859, current: 144021; changing to 675860. This may result in incorrect timestamps in the output file.frame=  903 fps=0.0 q=-1.0 Lsize=    3219kB time=00:01:44.78 bitrate= 251.7kbits/s speed=4.89e+03x    video:2951kB audio:244kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.774971%

生成的視頻時長與 兩個視頻拼接的長度不一致.

我們直接將相同的兩個視頻拼接,此時:

file 'share_5eb7ba669e87b5ab48d50107a249a1c1.mp4'file 'share_5eb7ba669e87b5ab48d50107a249a1c1.mp4'

最終可以拼接成功.

如果需要解決這個問題,則需要我們使用ffmpeg的其他選項進行轉碼和調整,保證兩個視頻的格式統一後,進行拼接.

本文由博客一文多發平臺 OpenWrite 發佈!


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 掌握這幾種SQL進階用法,你將能夠更高效地處理各種複雜的數據操作,並少走很多彎路。這些技巧能夠提高你的SQL查詢能力,使得你在日常的數據處理工作中更得心應手。 ...
  • 什麼是MySQL的頁? 頁是指存儲引擎使用的最小的數據存儲單位。 當 MySQL 執行讀取或寫入操作時,是以頁為基本單位來進行操作的。即使讀寫一條數據,MySQL 也會按頁操作。 MySQL 的存儲引擎會將數據分成多個頁,並根據需要將這些頁載入到記憶體中進行處理。 通過使用頁來組織數據,MySQL 能 ...
  • 搭建Redis三主三從集群的詳細步驟如下: 準備環境: 確保你有六台伺服器或虛擬機,每台伺服器上都已經安裝了Redis。這些伺服器將用於搭建三主三從的Redis集群。 確保所有伺服器之間的網路連接正常,並且防火牆設置允許Redis通信。 安裝Redis: 在每台伺服器上下載並安裝Redis。你可以從 ...
  • 結論:當一個事務要對錶進行鎖定時,首先會獲取相應的意向鎖。其他事務可以通過檢查意向鎖來判斷是否有其他事務在更細粒度的級別上對錶進行了鎖定。這有助於避免衝突和提高併發性能 在討論此問題之前我們應當明確兩個前提: Innodb存儲引擎支持行鎖和表鎖共存 行鎖與表鎖之間互不衝突 意向鎖是表級別的鎖,意向鎖 ...
  • 原文: Android 獲取設備的CPU型號和設備型號-Stars-One的雜貨小窩 之前整的項目的總結信息,可能不太全,湊合著用吧,代碼在最下麵一節 CPU型號數據 華為: ro.mediatek.platform vivo: ro.vivo.product.platform oppo: ro.b ...
  • ​ 1:使用Protocol Buffers 首先根目錄gradle中添加依賴: classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.3" 然後項目文件中添加plugin,添加依賴包: apply plugin: 'com.google ...
  • Android 二維碼相關(二) 本篇文章繼續講述下如何使用zxing解析二維碼圖片,獲取內容. 1: 創建RGBLuminanceSource對象. 首先獲取二維碼圖片的bitmap對象. Bitmap bitmap = BitmapFactory.decodeResource(getResour ...
  • Android 二維碼相關(一) 本篇文章主要記錄下android下使用zxing來創建二維碼. 1: 導入依賴 api "com.google.zxing:core:3.5.1" 2: 創建二維碼 創建QRCodeWriter對象 QRCodeWriter qrCodeWriter = new Q ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...