저는 ffmpeg에 상당히 익숙하지만이 문제에 대해 며칠 동안 조사한 후에 벽돌 벽을 완전히 쳤습니다. 어떤 도움을 주시면 감사하겠습니다.drawtext 필터를 사용한 후 ffmpeg 연결
사례 : Google 고객은 여러 지역의 동영상을 업로드하려고합니다. 각 동영상의 형식은 1920x1080, mp4입니다. 각 지역의 경우 비디오 끝 부분에 몇 초 동안 다른 이미지를 추가하려고합니다. 이 이미지에는 로고, 일부 추가 정보 및 가변 코드가 포함되어 있습니다. 그들은 업로드 된 비디오와 함께이 코드를 입력합니다. 이미지는 동일하게 유지되므로 이미 서버에 있습니다. 기본적으로 입력 비디오, 이미지 비디오 및 작은 코드가 있습니다. 이 코드를 이미지의 비디오에 미리 정의 된 위치에 추가해야합니다. 그런 다음 결과 비디오를 입력 비디오의 끝에 추가해야합니다. 완료되면 1920x1080 및 1024x576으로 비디오를 출력하면됩니다.
여러 가지를 시도했지만 연결 된 단계는 항상 조작 된 비디오와 함께 실패합니다. 내 첫 번째 시도에서 1
시도, 나는 지정된 지역에서 텍스트를 이미지에서 비디오를 생성하고 추가 할 수는 FFmpeg을 사용했다.
ffmpeg -y -f lavfi -i image.png -r 30 -t 10 -pix_fmt yuv420p -map 0:v -vf drawtext="fontfile=HelveticaNeue.dfont: text='GLNS/TEST/1234b': fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=7: x=179: y=805" imageVideo.mp4
이 명령어는 10 초의 지속 시간으로 적절한 크기의 .MP4 영상을 생성하고, 올바른 위치에 문자 '가 GLNS/TEST/1234b'를 추가한다.
다음은 두 개의 비디오를 연결하는 데 다음 명령을 사용합니다. 둘 다 동일한 해상도와 코덱을 사용합니다.
ffmpeg -f concat -safe 0 -i config.txt -vf scale=1920:1080 outputHD.mp4 -vf scale=1024:576 outputSD.mp4
으로 config.txt 다음 포함 :
file my_input_file.mp4
file ImageVideo.mp4
이 연결은 일반 비디오와 함께 작동합니다.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f86dc924600] Auto-inserting h264_mp4toannexb bitstream filtereed=0.509x
[aac @ 0x7f86dc019e00] Number of bands (31) exceeds limit (5).
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0x7f86dc019e00] Number of bands (27) exceeds limit (8).
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0x7f86dd857200] Error splitting the input into NAL units.
[h264 @ 0x7f86dd829400] Invalid NAL unit size.
[h264 @ 0x7f86dd829400] Error splitting the input into NAL units.
[aac @ 0x7f86dc019e00] Number of bands (10) exceeds limit (1).
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0x7f86dd816800] Invalid NAL unit size.
[h264 @ 0x7f86dd816800] Error splitting the input into NAL units.
[aac @ 0x7f86dc019e00] Number of bands (24) exceeds limit (1).
Error while decoding stream #0:1: Invalid data found when processing input
#this goes on for a few hundred lines
결과 출력은 입력 화상과 동일하지만, 원하는 영상 비디오를 포함하지 않는다 : I가 ImageVideo.mp4 (첫번째 명령으로 만든 것)와 함께 사용할 때,이 에러 로그를 얻을 결국.
작동하지 않았다 위의 시도 이후 시도 2
, 나는 비디오을 연결 시도 나는 어도비 애프터 이펙트 (Adobe After Effects)와 이미지의 우리의 디자이너 메이크업을 할 수 있습니다. 이 비디오는 H264 코덱과 함께 .mp4로 저장되었습니다. 입력 비디오와이 비디오를 연결하면 정확한 결과를 얻습니다. 그러나, 곧이 명령으로 지정된 영역의 코드를 추가 :
ffmpeg -i new_image_video.mp4 -vf drawtext="fontfile=HelveticaNeue.dfont: text='GLNS/TEST/1234b': fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=7: x=179: y=805" -c:v libx264 imageVideo.mp4
이 오류를 얻을 :
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ff94c800000] Auto-inserting h264_mp4toannexb bitstream filter97x
[h264 @ 0x7ff94b053800] top block unavailable for requested intra mode -1
[h264 @ 0x7ff94b053800] error while decoding MB 0 0, bytestream 49526
[h264 @ 0x7ff94b053e00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0x7ff94b053e00] chroma_log2_weight_denom 28 is out of range
[h264 @ 0x7ff94b053e00] illegal long ref in memory management control operation 2
[h264 @ 0x7ff94b053e00] cabac_init_idc 32 overflow
[h264 @ 0x7ff94b053e00] decode_slice_header error
[h264 @ 0x7ff94b053e00] no frame!
[h264 @ 0x7ff94b053800] concealing 8160 DC, 8160 AC, 8160 MV errors in I frame
[h264 @ 0x7ff94b072a00] reference overflow 22 > 15 or 0 > 15
[h264 @ 0x7ff94b072a00] decode_slice_header error
[h264 @ 0x7ff94b072a00] no frame!
[h264 @ 0x7ff94b01a400] illegal modification_of_pic_nums_idc 20
[h264 @ 0x7ff94b01a400] decode_slice_header error
[h264 @ 0x7ff94b01a400] no frame!
[h264 @ 0x7ff94b01aa00] illegal modification_of_pic_nums_idc 20
[h264 @ 0x7ff94b01aa00] decode_slice_header error
[h264 @ 0x7ff94b01aa00] no frame!
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x7ff94b053800] deblocking_filter_idc 8 out of range
[h264 @ 0x7ff94b053800] decode_slice_header error
[h264 @ 0x7ff94b053800] no frame!
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x7ff94b053e00] illegal memory management control operation 8
[h264 @ 0x7ff94b053e00] co located POCs unavailable
[h264 @ 0x7ff94b053e00] error while decoding MB 2 0, bytestream -35
[h264 @ 0x7ff94b053e00] concealing 8160 DC, 8160 AC, 8160 MV errors in B frame
[h264 @ 0x7ff94b072a00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
# this goes on for a while...
[h264 @ 0x7ff94b01a400] concealing 4962 DC, 4962 AC, 4962 MV errors in B frame
Error while decoding stream #0:0: Invalid data found when processing input
frame= 2553 fps= 17 q=-1.0 Lsize= 26995kB time=00:01:42.16 bitrate=2164.6kbits/s dup=0 drop=60 speed=0.697x
video:25258kB audio:1661kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.285236%
[libx264 @ 0x7ff94b810400] frame I:35 Avg QP:17.45 size: 55070
[libx264 @ 0x7ff94b810400] frame P:711 Avg QP:19.73 size: 18712
[libx264 @ 0x7ff94b810400] frame B:1807 Avg QP:21.53 size: 5884
[libx264 @ 0x7ff94b810400] consecutive B-frames: 3.4% 5.0% 4.9% 86.6%
[libx264 @ 0x7ff94b810400] mb I I16..4: 38.2% 49.3% 12.5%
[libx264 @ 0x7ff94b810400] mb P I16..4: 12.4% 14.0% 1.0% P16..4: 29.6% 4.8% 1.9% 0.0% 0.0% skip:36.2%
[libx264 @ 0x7ff94b810400] mb B I16..4: 1.5% 1.2% 0.1% B16..8: 27.3% 1.6% 0.1% direct: 1.8% skip:66.4% L0:45.8% L1:51.4% BI: 2.8%
[libx264 @ 0x7ff94b810400] 8x8 transform intra:49.5% inter:85.4%
[libx264 @ 0x7ff94b810400] coded y,uvDC,uvAC intra: 21.2% 22.3% 2.5% inter: 4.6% 7.0% 0.0%
[libx264 @ 0x7ff94b810400] i16 v,h,dc,p: 23% 26% 10% 41%
[libx264 @ 0x7ff94b810400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 19% 35% 3% 3% 3% 3% 3% 2%
[libx264 @ 0x7ff94b810400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 20% 16% 5% 7% 6% 5% 5% 4%
[libx264 @ 0x7ff94b810400] i8c dc,h,v,p: 67% 16% 15% 2%
[libx264 @ 0x7ff94b810400] Weighted P-Frames: Y:7.3% UV:4.2%
[libx264 @ 0x7ff94b810400] ref P L0: 66.3% 8.7% 17.9% 7.0% 0.1%
[libx264 @ 0x7ff94b810400] ref B L0: 88.2% 10.1% 1.7%
[libx264 @ 0x7ff94b810400] ref B L1: 94.9% 5.1%
[libx264 @ 0x7ff94b810400] kb/s:2026.12
[aac @ 0x7ff94b072400] Qavg: 635.626
결과 출력은 입력 비디오와 동일하지만이 포함되어 있지 않습니다 마지막에 원하는 이미지 비디오.내가 발견 한
한 가지 : 내가 Mac에서 비디오 파일을 검사 할 때 그들은 항상 '추가 정보'에서 다음 줄을 포함 (정보 입수) : 그러나
Dimensions: 1920 x 1080
Codecs: H.264, AAC
Color profile: HD(1-1-1)
Duration: 01:42
Audio channels: 2
Last opened: Today 11:02
을의 DrawText에 필터를 통과 비디오의 있습니다 :
Dimensions: 1920 x 1080
Codecs: AAC, H.264
Duration: 00:10
Audio channels: 2
Last opened: Today 11:07
색상 프로필 항목이없고 코덱이 전환되었습니다. 이 문제는 내 문제와 관련 있다고 생각되지만 해결 방법을 찾을 수 없습니다.
PS : 응용 프로그램이 PHP 환경 (Symfony)에서 실행됩니다. symfony 번들에서 ffmpeg에 대해 concat 명령을 사용할 수 없다는 사실을 알고 있으므로 일반 터미널 명령을 사용하고 있습니다. 나는 이것을 PHP를 사용하여 실행할 것이다.
EDIT 3 동료의 조언에
, 나는을 .avi 비디오를 변환 .MP4을 재 변환 시도 시도는 희망이는 DrawText에 필터가 포함 된 모든 손상 또는 추가 정보를 잃게 . 이것은 완전히 다른 오류를 일으킨다.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f812413da00] Auto-inserting h264_mp4toannexb bitstream filtereed=0.516x
[concat @ 0x7f8124009a00] DTS 1569260 < 2551000 out of order
[h264 @ 0x7f8124846800] left block unavailable for requested intra4x4 mode -1
[h264 @ 0x7f8124846800] error while decoding MB 0 0, bytestream 47919
[h264 @ 0x7f8124846800] concealing 8160 DC, 8160 AC, 8160 MV errors in I frame
[aac @ 0x7f8125809a00] Queue input is backward in time
[aac @ 0x7f8125815a00] Queue input is backward in time
[h264 @ 0x7f8124846e00] number of reference frames (1+3) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0x7f8124846e00] chroma_log2_weight_denom 26 is out of range
[h264 @ 0x7f8124846e00] deblocking_filter_idc 32 out of range
[h264 @ 0x7f8124846e00] decode_slice_header error
[h264 @ 0x7f8124846e00] no frame!
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902912, current: 4505491; changing to 4902913. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902912, current: 4505491; changing to 4902913. This may result in incorrect timestamps in the output file.
[h264 @ 0x7f8124803400] reference overflow 20 > 15 or 0 > 15
[h264 @ 0x7f8124803400] decode_slice_header error
[h264 @ 0x7f8124803400] no frame!
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902913, current: 4506515; changing to 4902914. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902913, current: 4506515; changing to 4902914. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8124802200] Non-monotonous DTS in output stream 0:1; previous: 4902914, current: 4507539; changing to 4902915. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f8125813000] Non-monotonous DTS in output stream 1:1; previous: 4902914, current: 4507539; changing to 4902915. This may result in incorrect timestamps in the output file.
# Again, this continues for quite a while.
우리 사이의 멍청한 놈들에게 왜이 효과가 있지만 다른 효과는 실패합니까? – vrwim
감사합니다. 많은 사람, 매력처럼 일했습니다. vlwim이 물었던 것처럼, 왜 이것이 작동하고 무엇이 잘못 되었는가에 대해 설명하고 싶습니까? –
나는 확실히 명령을 디버그 할 수는 없지만, concat demuxer는 일치하는 스트림 순서가 필요합니다. 그리고 코덱, 해상도, 픽셀 형식 (색상 공간은 아님)과 같은 스트림 속성을 일치시킬 수 있지만 timebase, 0-start PTS 같은 속성은 AE와 같은 응용 프로그램이 사용자가 수정하거나 새로운 FFmpeg 사용자가 지정할 수없는 것을 허용합니다. 동일한 소스에서 생성 된 세그먼트를 스티치 할 때 concat demuxer를 사용합니다. – Mulvya