특정 파일과 동일한 코덱 및 매개변수를 사용하여 ffmpeg를 인코딩하는 방법은 무엇입니까?

특정 파일과 동일한 코덱 및 매개변수를 사용하여 ffmpeg를 인코딩하는 방법은 무엇입니까?

두 개의 서로 다른 비디오 파일을 병합해야 하는데 사용 중입니다.무손실컷작업을 위해. 하지만 파일의 코덱, 크기, 프레임 속도가 동일해야 한다고 나와 있습니다.

소스는 Vorbis의 mkv V_MPEG4/ISO/AVC이고, 대상은 ac3의 avi xvid입니다.

  • ffmpeg 인코딩을 사용하는 두 파일의 전체 매개변수
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 6.20 MiB
Duration                                 : 46 s 280 ms
Overall bit rate                         : 1 124 kb/s
Writing application                      : Lavf58.45.100

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings                          : BVOP2
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (MPEG)
Muxing mode                              : Packed bitstream
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 46 s 280 ms
Bit rate                                 : 921 kb/s
Width                                    : 576 pixels
Height                                   : 432 pixels
Display aspect ratio                     : 3:2
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.148
Stream size                              : 5.08 MiB (82%)
Writing library                          : XviD 64

Audio
ID                                       : 1
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : 2000
Duration                                 : 46 s 254 ms
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 28.711 FPS (1536 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 1.06 MiB (17%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 35  ms (0.87 video frame)
Interleave, preload duration             : 347  ms
Service kind                             : Complete Main
  • 레코딩/인코딩하려는 파일의 매개변수(위에 표시된 매개변수를 갖기 위해):
Format                                   : Matroska
Format version                           : Version 4
File size                                : 2.36 MiB
Duration                                 : 27 s 999 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 706 kb/s
Writing application                      : Lavf58.45.100
Writing library                          : Lavf58.45.100
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 27 s 933 ms
Bit rate                                 : 564 kb/s
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.303 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.045
Stream size                              : 1.88 MiB (80%)
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : Vorbis
Format settings, Floor                   : 1
Codec ID                                 : A_VORBIS
Duration                                 : 27 s 837 ms
Bit rate mode                            : Variable
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Delay relative to video                  : -52 ms
Stream size                              : 435 KiB (18%)
Writing application                      : Lavc58.91.100
Writing library                          : libVorbis (Reducing Environment) (20200704 (Reducing Environment))
Default                                  : Yes
Forced                                   : No

대상 파일에서 모든 데이터를 추출하여 FFmpeg 소스 파일 인코딩 명령에 매개변수로 입력하려면 어떻게 해야 합니까? 이에 대한 스크립트가 있는지 찾아봤는데 찾을 수 없습니다.

답변1

수동으로 수행해야합니다.

ffmpeg -i input.mkv -c:v libxvid -vf scale=-2:432 -r 25 -profile:v 0 -level 5 -vtag XVID -mpeg_quant 1 -b:v 921k -bf 2 -c:a ac3 -ac 2 -ar 44100 output.avi

답변2

아직 좋은 해결책을 찾지는 못했지만,Linux bash 스크립트가 있습니다병합할 비디오 조각에서 차이점을 찾는 작업을 자동화하고 차이점을 수정하기 위한 명령을 제안합니다.

답변3

이것은 거의 비슷합니다. "크기를 미리 정의하지 않고 하나의 비디오를 다른 비디오와 일치하도록 크기를 조정합니다", 두 개의 비디오를 나란히 배치하고 첫 번째 비디오 크기와 일치하도록 두 번째 비디오 크기를 갖습니다.

ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:h=in_h:[v1][v0];[v0][v1]hstack[vo]" -map "[vo]" ./output-video.mp4

원천

관련 정보