ffmpeg 또는 avconv를 사용하여 원본 소스에서 파일을 만드는 방법

ffmpeg 또는 avconv를 사용하여 원본 소스에서 파일을 만드는 방법

나는 의사에게 내 파트너의 발작 영상을 찍기 위해 비디오 녹화기를 만들려고 합니다. 예측할 수 없기 때문에 시스템은 예를 들어 15분 클립으로 저장하는 등 지속적으로 녹화해야 합니다.

시스템은 실제로 데비안이지만, 이곳에 물어보면 좋을 것 같다고 생각했습니다.

Raspivid의 h264 원시 비디오와 USB 마이크의 사운드가 있습니다. 테스트를 위해 arecord를 사용할 때 Raspivid가 실행 중이고 USB 마이크가 사운드를 캡처하지만 avconv를 사용하여 얻은 파일은 재생할 수 없으며 한 프레임 동안만 열린 다음 완료됩니다.

raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - |
avconv -y -ac 2 -f alsa -ar 16000 -i plughw:1  -r 30 -i pipe:0  -filter_complex asyncts=compensate=1
-c:a ac3 -c:v copy -t 300 file%04d.mkv

추가 정보:

pi@raspberrypi:~ $ raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv
ffmpeg version N-82665-gbda6f29 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --pkg-config-flags=--static --extra-cflags='-fPIC -I/root/ffmpeg_build/include' --extra-ldflags=-L/root/ffmpeg_build/lib --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-pic --extra-ldexeflags=-pie --enable-shared
  libavutil      55. 41.101 / 55. 41.101
  libavcodec     57. 66.108 / 57. 66.108
  libavformat    57. 58.101 / 57. 58.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 67.100 /  6. 67.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'plughw:1':
  Duration: N/A, start: 1480449777.042259, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Input #1, h264, from 'pipe:0':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, segment, to 'file%04d.mkv':
  Metadata:
    encoder         : Lavf57.58.101
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 1k tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
[alsa @ 0x80e062f0] ALSA buffer xrun.
[segment @ 0x80e8de90] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[h264 @ 0x80e17620] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:40.88 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:45.77 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:50.28 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:55.84 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:17:48.47 bitrate=N/A speed=   1x    

이것은 무한정 계속될 것입니다. 명령을 종료하기 위해 다른 키 조합을 시도한 후 파일을 얻었고 포기한 후 얼마 후에 완료되었으며 결과 파일은 10초의 비디오, 그 다음 몇 분의 마지막 프레임과 진행 중인 오디오였습니다.

답변1

당신은 그것을 사용할 수 있습니다세그먼트 멀티플렉서:

raspivid <options> -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv

관련 정보