Video-Editing

切割 AV 文件 (MP4)

  • August 9, 2015

我曾嘗試使用 openshot、pitivi、kdenlive、videolan 來剪切音頻/影片文件,但它們似乎都凍結了。所以我現在嘗試使用以下命令:

avconv -i input.MP4 -vcodec copy -acodec copy -ss 01:25:00 -t 01:26:00 output.MP4

這會在我的電腦上創建一個文件,但是當我在 vlc 中打開它時,我只能聽到聲音,長度為 37.04 分鐘。它應該是1分鐘長。

另外,剛剛試過這個:

ffmpeg -ss 01:24:30 -t 01:25:00 -i orginalfile -vcodec copy -acodec copy newfile

這根本不會剪切 av 文件,它最終是全長的,但只有音頻可用,沒有影片。

我究竟做錯了什麼?

我也試過:

avconv -i input.MP4 -ss 01:25:00 -t 01:26:00 -c:a copy -c:v copy output.MP4

它給了我與上面相同的結果。


兩個命令的完整輸出可以在這裡看到:

oshiro@home-desktop:~/Desktop$ avconv -i SDV_1195.MP4 -vcodec copy -acodec copy -ss 01:24:00 -t 01:25:30 2.MP4
avconv version 0.8.13-4:0.8.13-0ubuntu0.12.04.1, Copyright (c) 2000-2014 the Libav developers
 built on Jul 15 2014 12:56:47 with gcc 4.6.3
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1e8c7a0] max_analyze_duration reached
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SDV_1195.MP4':
 Metadata:
   major_brand     : avc1
   minor_version   : 0
   compatible_brands: avc1isom
   creation_time   : 1947-02-10 00:03:08
 Duration: 02:01:04.29, start: 0.000000, bitrate: 2137 kb/s
   Stream #0.0(eng): Video: h264 (Main), yuv420p, 720x576, 2000 kb/s, PAR 64:45 DAR 16:9, 50 fps, 50 tbr, 90k tbn, 180k tbc
   Metadata:
     creation_time   : 1947-02-10 00:03:08
   Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s
   Metadata:
     creation_time   : 1947-02-10 00:03:08
Output #0, mp4, to '2.MP4':
 Metadata:
   major_brand     : avc1
   minor_version   : 0
   compatible_brands: avc1isom
   creation_time   : 1947-02-10 00:03:08
   encoder         : Lavf53.21.1
   Stream #0.0(eng): Video: ![0][0][0] / 0x0021, yuv420p, 720x576 [PAR 64:45 DAR 16:9], q=2-31, 2000 kb/s, 90k tbn, 90k tbc
   Metadata:
     creation_time   : 1947-02-10 00:03:08
   Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, 127 kb/s
   Metadata:
     creation_time   : 1947-02-10 00:03:08
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press ctrl-c to stop encoding
frame=    0 fps=  0 q=-1.0 Lsize=   35570kB time=2224.30 bitrate= 131.0kbits/s    /s    
video:0kB audio:34755kB global headers:0kB muxing overhead 2.345804%
oshiro@home-desktop:~/Desktop$ avconv -i SDV_1195.MP4 -ss 01:24:00 -t 01:25:30 -c:a copy -c:v copy output-clip.mp4
avconv version 0.8.13-4:0.8.13-0ubuntu0.12.04.1, Copyright (c) 2000-2014 the Libav developers
 built on Jul 15 2014 12:56:47 with gcc 4.6.3
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xd307a0] max_analyze_duration reached
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SDV_1195.MP4':
 Metadata:
   major_brand     : avc1
   minor_version   : 0
   compatible_brands: avc1isom
   creation_time   : 1947-02-10 00:03:08
 Duration: 02:01:04.29, start: 0.000000, bitrate: 2137 kb/s
   Stream #0.0(eng): Video: h264 (Main), yuv420p, 720x576, 2000 kb/s, PAR 64:45 DAR 16:9, 50 fps, 50 tbr, 90k tbn, 180k tbc
   Metadata:
     creation_time   : 1947-02-10 00:03:08
   Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s
   Metadata:
     creation_time   : 1947-02-10 00:03:08
Output #0, mp4, to 'output-clip.mp4':
 Metadata:
   major_brand     : avc1
   minor_version   : 0
   compatible_brands: avc1isom
   creation_time   : 1947-02-10 00:03:08
   encoder         : Lavf53.21.1
   Stream #0.0(eng): Video: ![0][0][0] / 0x0021, yuv420p, 720x576 [PAR 64:45 DAR 16:9], q=2-31, 2000 kb/s, 90k tbn, 90k tbc
   Metadata:
     creation_time   : 1947-02-10 00:03:08
   Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, 127 kb/s
   Metadata:
     creation_time   : 1947-02-10 00:03:08
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press ctrl-c to stop encoding
frame=    0 fps=  0 q=-1.0 Lsize=   35570kB time=2224.30 bitrate= 131.0kbits/s    /s    
video:0kB audio:34755kB global headers:0kB muxing overhead 2.345804%
oshiro@home-desktop:~/Desktop$ 

我已經使用Avidemux在 Linux 和 Windows 上剪輯了影片。它有一個易於使用的 GUI。

  • 載入影片
  • 選擇起點和終點
  • 選擇輸出格式(使用複制避免影片重新編碼)
  • 保存您的剪切文件

在 Ubuntu 中安裝它:

sudo apt-get install avidemux

-t需要一個duration ,而不是end-time

所以改為-t 60-t 0:01:00

來自libav 文件

‘-t duration (output)’
   Stop writing the output after its duration reaches duration.
   duration may be a number in seconds, or in hh:mm:ss[.xxx] form.

引用自:https://unix.stackexchange.com/questions/145747