
Ich komme nicht weiter, wenn ich versuche, eine Reihe von 16-Bit-PGM-Dateien mit ffmepg in ein Video umzuwandeln. Die Dateien selbst sind alle gültige PGM-Dateien und heißen
0.pgm 1.pgm 2.pgm ...
Die Bilder wurden mit einer Bildrate von ~1 fps aufgenommen und ich möchte, dass das resultierende Video in Echtzeit ist (ein Bild = 1 Sekunde).
Ich habe verwendetffmpeg -r 1 -i %d.pgm -pix_fmt yuv420p output.mp4
Die Ausgabedatei wird erstellt, aber das Video zeigt nur schwarze Pixel (bis auf ein paar graue in der oberen rechten Ecke). Sowohl im Windows Media Player als auch bei ffplay
.
Hier ist die vollständige Konsolenausgabe, die ich erhalte:
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (pgm (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0000027f39775c80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000027f39775c80] profile High, level 2.2
[libx264 @ 0000027f39775c80] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf58.10.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 640x480, q=-1--1, 1 fps, 16384 tbn, 1 tbc
Metadata:
encoder : Lavc58.13.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 549 fps=109 q=-1.0 Lsize= 503kB time=00:09:06.00 bitrate= 7.6kbits/s speed= 109x
video:496kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.459769%
[libx264 @ 0000027f39775c80] frame I:3 Avg QP: 2.81 size: 34676
[libx264 @ 0000027f39775c80] frame P:139 Avg QP: 4.47 size: 1849
[libx264 @ 0000027f39775c80] frame B:407 Avg QP:14.75 size: 359
[libx264 @ 0000027f39775c80] consecutive B-frames: 1.1% 0.0% 0.5% 98.4%
[libx264 @ 0000027f39775c80] mb I I16..4: 20.2% 79.1% 0.6%
[libx264 @ 0000027f39775c80] mb P I16..4: 0.0% 1.3% 0.0% P16..4: 19.2% 0.7% 1.6% 0.0% 0.0% skip:77.1%
[libx264 @ 0000027f39775c80] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 10.2% 0.5% 0.3% direct: 0.3% skip:88.7% L0:34.6% L1:64.1% BI: 1.2%
[libx264 @ 0000027f39775c80] 8x8 transform intra:85.7% inter:66.0%
[libx264 @ 0000027f39775c80] coded y,uvDC,uvAC intra: 83.8% 89.0% 88.8% inter: 2.1% 0.3% 0.2%
[libx264 @ 0000027f39775c80] i16 v,h,dc,p: 54% 20% 24% 2%
[libx264 @ 0000027f39775c80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 16% 59% 1% 0% 0% 0% 0% 0%
[libx264 @ 0000027f39775c80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 23% 35% 4% 9% 4% 9% 2% 6%
[libx264 @ 0000027f39775c80] i8c dc,h,v,p: 43% 29% 27% 2%
[libx264 @ 0000027f39775c80] Weighted P-Frames: Y:2.9% UV:0.0%
[libx264 @ 0000027f39775c80] ref P L0: 84.0% 0.1% 9.8% 6.0% 0.1%
[libx264 @ 0000027f39775c80] ref B L0: 73.4% 22.6% 4.0%
[libx264 @ 0000027f39775c80] ref B L1: 85.3% 14.7%
[libx264 @ 0000027f39775c80] kb/s:7.39
Wir sind für jede Hilfe dankbar und danken im Voraus.
Grüße
Antwort1
Entschuldigen Sie die verspätete Antwort.
Ich habe die Kommentare nicht beantwortet, weil ich die Antwort selbst gefunden habe. Der Fehler liegt in den Konventionen des pgm-Dateikopfes. ffmpeg verarbeitet anscheinend nur P5-Dateien korrekt (solche, die eine binäre Kodierung für Pixel haben). Meine Dateien waren jedoch P2, also solche, die eine ASCII-Kodierung haben.
Die einfachste Lösung, die ich gefunden habe, bestand darin, die Bilder in das PNG-Format zu konvertieren und dann FFMPG darauf anzuwenden.
Danke für eure Hilfe und Grüße
Leon