从中间分割 mpg 时丢失视频

从中间分割 mpg 时丢失视频

我对 ffmpeg 还很陌生,所以请耐心等待。

我正在尝试将 mpg 分成两部分。这是一段 4 分 36 秒的视频。我希望第一部分为 170 秒,第二部分为剩余部分。我尝试了很多不同的方法。

ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:00:00 -t 00:2:50 output1.mpg
ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:02:50 output2.mpg

ffmpeg -i input.mpg -t 170 -c copy output1.mpg -ss 170 -c copy output2.mpg

还有很多其他的。我尝试过的所有方法都让我获得了很好的第一个 output1.mpg,但 output2.mpg 总是缺少视频。文件保存为 .mpg,但只有音频。

我发现了一个选项,上面说可以尝试一下第二件。

ffmpeg -ss 170 -i input.mpg -t 176 -c copy output2.mpg

有时会出现错误,因此请尝试:

ffmpeg -ss 170 -i input.mpg -t 176 output2.mpg

省略“-c copy”可能会产生良好的输出。因此,上面第一个带有“-c copy”的选项给出了相同的结果,没有视频。第二个选项产生了视频和音频,但视频质量严重下降。

有人能帮帮我吗?为什么我总是丢失第二段的视频。我是新手,但这似乎很简单。

以下是

ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:00:00 -t 00:2:50 output1.mpg

>ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:00:00 -t 00:2:50 output1.m
pg
ffmpeg version N-62340-g1de8a4f Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 10 2014 22:08:28 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-zlib
  libavutil      52. 75.100 / 52. 75.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 36.103 / 55. 36.103
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'input.mpg':
  Duration: 00:04:36.48, start: 0.458744, bitrate: 3062 kb/s
    Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3
], 4000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16p, 320 kb/s
Output #0, mpeg, to 'output1.mpg':
  Metadata:
    encoder         : Lavf55.36.103
    Stream #0:0: Video: mpeg1video, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31,
4000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: mp2, 44100 Hz, stereo, 320 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpeg @ 00000000041fd4a0] Non-monotonous DTS in output stream 0:0; previous: 0,
current: 0; changing to 1. This may result in incorrect timestamps in the output
 file.
frame= 5096 fps=0.0 q=-1.0 Lsize=   61544kB time=00:02:50.00 bitrate=2965.6kbits
/s
video:54566kB audio:6641kB subtitle:0kB other streams:0kB global headers:0kB mux
ing overhead: 0.550940%

下面是输出

ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:02:50 output2.mpg

>ffmpeg -i input.mpg -vcodec copy -acodec copy -ss 00:02:50 output2.mpg
ffmpeg version N-62340-g1de8a4f Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 10 2014 22:08:28 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-zlib
  libavutil      52. 75.100 / 52. 75.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 36.103 / 55. 36.103
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpeg, from 'input.mpg':
  Duration: 00:04:36.48, start: 0.458744, bitrate: 3062 kb/s
    Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3
], 4000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16p, 320 kb/s
Output #0, mpeg, to 'output2.mpg':
  Metadata:
    encoder         : Lavf55.36.103
    Stream #0:0: Video: mpeg1video, yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31,
4000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: mp2, 44100 Hz, stereo, 320 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 2364 fps=0.0 q=-1.0 size=   31728kB time=00:01:19.07 bitrate=3286.8kbits/
frame= 3186 fps=0.0 q=-1.0 Lsize=   41828kB time=00:01:46.55 bitrate=3215.7kbits
/s
video:37440kB audio:4162kB subtitle:0kB other streams:0kB global headers:0kB mux
ing overhead: 0.541575%

提前致谢!

相关内容