Konversi aliran bgra ke mp4

1

Saya mencoba merekam video simulator iOS menggunakan perintah berikut;

./fbsimctl stream --bgra --fps 12 - | ffmpeg -f rawvideo -pix_fmt bgra -s 414x736 -framerate 12 -i - -f h264 -r 12 - | ffplay -

Masalahnya adalah video yang dihasilkan kacau.

Sepertinya ffmpeg tidak mengubah format bgra dengan benar.

Apakah ada parameter lain yang perlu saya lewati?

Ada peringatan di tengah output sampel yang ditempelkan di bawah:

Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) [swscaler @ 0x7f8342009000] Warning: data is not aligned! This can lead to a speed loss

Berikut adalah contoh hasil;

./fbsimctl stream --bgra --fps 12 - | ffmpeg -f rawvideo -pix_fmt bgra -s 414x736 -framerate 12  -i - -f h264 -r 12 - | ffplay -
ffmpeg version 4.0.2ffplay version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers Copyright (c) 2003-2018 the FFmpeg developers
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)

  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56. 14.100 / 56. 14.100
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Running /usr/bin/xcode-select --print-path with environment {
    HOME = "/Users/sumancherukuri";
    PATH = "/Users/sumancherukuri/Projects/webrtc/webrtc_ios/depot_tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
}
Connection Did Connect => Bridge: Framebuffer ((null)) | HID (null) | (null)
079C6C51-C335-4273-A566-7D0667693F99 | iPhone X | Booted | iPhone X | iOS 11.4 | x86_64: launch: Bridge: Framebuffer ((null)) | HID (null) | (null)

Mounting Surface with Attributes: {
    format = BGRA;
    "frame_size" = 11069184;
    height = 2436;
    "row_size" = 4544;
    width = 1125;
}
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, start: 0.000000, bitrate: 117006 kb/s
    Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 414x736, 117006 kb/s, 12 tbr, 12 tbn, 12 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
[swscaler @ 0x7f8342009000] Warning: data is not aligned! This can lead to a speed loss
[libx264 @ 0x7f8343801800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8343801800] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
Output #0, h264, to 'pipe:':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (libx264), yuv444p, 414x736, q=-1--1, 12 fps, 12 tbn, 12 tbc
    Metadata:
      encoder         : Lavc58.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1

listen started: Streaming Video
frame=   56 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   frame=   79 fps= 77 q=26.0 size=     950kB time=00:00:01.75 bitrate=4448.9kbits/frame=  116 fps= 76 q=26.0 size=    2501kB time=00:00:04.83 bitrate=4239.1kbits/Input #0, h264, from 'pipe:':q=    0KB vq=    0KB sq=    0B f=0/0   
  Duration: N/A, bitrate: N/A

Terima kasih,

- Manusia

suman cherukuri
sumber
Apakah ./fbsimctl stream --bgra --fps 12 - | ffplay -f rawvideo -video_size 414x736 -framerate 12 -pixel_format bgra -bermain dengan baik?
Gyan
Tidak, ini memainkan suara hitam putih yang kacau di layar. Terima kasih telah melihat ini!
suman cherukuri

Jawaban:

1

Masalahnya adalah video yang dihasilkan kacau.

Saya mengalami masalah yang sama persis hari ini. Penyebabnya adalah, keluaran bbs fbsimctl dalam gaya file BMP dan setiap larik gambar diisi oleh 0 sehingga panjangnya menjadi kelipatan 4 (lihat https://en.wikipedia.org/wiki/BMP_file_format untuk detail).

Dengan memperluas ukuran gambar yang ditentukan ke kelipatan 4, saya menyelesaikan masalah ini. Untuk kasus Anda, Anda harus berubah -s 414x736menjadi -s 416x736.

Nozomi Ito
sumber