Avconv

如何使用 avconv 將 PPM 轉換為 MP4

  • August 17, 2020

我正在嘗試使用 .將 PPM 影片文件轉換為 MP4 影片文件avconv。我試過這個:

avconv -r 1 -i Hole0.0001.mp4.ppm -r 24 Hole.mp4

avconv version 12.3, Copyright (c) 2000-2018 the Libav developers
 built on Oct  2 2019 11:39:18 with gcc 8 (GCC)
Input #0, image2, from 'Hole0.0001.mp4.ppm':
 Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
   Stream #0:0: Video: ppm
     rgb24, 1310x560
     25 tbn
Stream mapping:
 Stream #0:0 -> #0:0 (ppm (native) -> mpeg4 (native))
Press ctrl-c to stop encoding
Output #0, mp4, to 'Hole.mp4':
 Metadata:
   encoder         : Lavf57.7.2
   Stream #0:0: Video: mpeg4 [ [0][0][0] / 0x0020]
     yuv420p, 1310x560, q=2-31, 200 kb/s
     24 fps, 24 tbn
   Metadata:
     encoder         : Lavc57.25.0 mpeg4
   Side data:
     cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=    1 fps=  0 q=3.2 Lsize=      16kB time=10000000000.00 bitrate=   0.0kbits/s    
video:15kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 5.397969%

然後,當我檢查創建的 MP4 影片文件時Hole.mp4,它不起作用。我的意思是影片立即開始和停止。

272M Hole0.0001.mp4.ppm
16K Hole.mp4 

display Hole0.0001.mp4.ppm(輸入文件)的輸出給了我這個:

在此處輸入圖像描述

如您所見,我在輸入文件中有 150 幀:

(base) alexandre@alexandre-Latitude-E7270:~/Documents$ ffprobe Hole0.0001.mp4.ppm 
ffprobe version 3.4.8-0ubuntu0.2 Copyright (c) 2007-2020 the FFmpeg developers
 built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
 configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
 libavutil      55. 78.100 / 55. 78.100
 libavcodec     57.107.100 / 57.107.100
 libavformat    57. 83.100 / 57. 83.100
 libavdevice    57. 10.100 / 57. 10.100
 libavfilter     6.107.100 /  6.107.100
 libavresample   3.  7.  0 /  3.  7.  0
 libswscale      4.  8.100 /  4.  8.100
 libswresample   2.  9.100 /  2.  9.100
 libpostproc    54.  7.100 / 54.  7.100
Hole0.0001.mp4.ppm: Invalid data found when processing input
(base) alexandre@alexandre-Latitude-E7270:~/Documents$ ffplay Hole0.0001.mp4.ppm 
ffplay version 3.4.8-0ubuntu0.2 Copyright (c) 2003-2020 the FFmpeg developers
 built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
 configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
 libavutil      55. 78.100 / 55. 78.100
 libavcodec     57.107.100 / 57.107.100
 libavformat    57. 83.100 / 57. 83.100
 libavdevice    57. 10.100 / 57. 10.100
 libavfilter     6.107.100 /  6.107.100
 libavresample   3.  7.  0 /  3.  7.  0
 libswscale      4.  8.100 /  4.  8.100
 libswresample   2.  9.100 /  2.  9.100
 libpostproc    54.  7.100 / 54.  7.100
Hole0.0001.mp4.ppm: Invalid data found when processing inputf=0/0 

當我使用這個命令時,我得到:

(base) alexandre@alexandre-Latitude-E7270:~/Documents$ display -verbose Hole0.0001.mp4.ppm 
Hole0.0001.mp4.ppm[0] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.690u 0:00.699
Hole0.0001.mp4.ppm[1] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.680u 0:00.690
Hole0.0001.mp4.ppm[2] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.680u 0:00.690
Hole0.0001.mp4.ppm[3] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.679
Hole0.0001.mp4.ppm[4] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.679
Hole0.0001.mp4.ppm[5] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.670u 0:00.670
Hole0.0001.mp4.ppm[6] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.660u 0:00.670
Hole0.0001.mp4.ppm[7] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.670
Hole0.0001.mp4.ppm[8] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.660
Hole0.0001.mp4.ppm[9] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.660
Hole0.0001.mp4.ppm[10] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.650u 0:00.650
Hole0.0001.mp4.ppm[11] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.640u 0:00.650
Hole0.0001.mp4.ppm[12] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.640u 0:00.650
Hole0.0001.mp4.ppm[13] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.630u 0:00.640
Hole0.0001.mp4.ppm[14] PPM 1310x560 1310x560+0+0 8-bit sRGB 330.1MB 0.630u 0:00.640

我究竟做錯了什麼?我怎樣才能解決這個問題?

我發現這個更好:

avconv -r 10 -vcodec ppm -f image2pipe -i Hole0.0001.mp4.ppm -vcodec mpeg4 -vb 40M -r 20 Hole.mp4

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