Hướng dẫn merge audio python - hợp nhất âm thanh python

Tôi đang viết một chương trình trong Python trên Raspberrypi (Raspbian), để kết hợp / hợp nhất một tệp âm thanh với tệp video.

Show

    Định dạng tệp âm thanh là định dạng sóng của tệp video là H264

    Âm thanh và video đã được ghi và tạo cùng một lúc, tôi chỉ cần hợp nhất chúng ngay bây giờ.

    Bạn có thể vui lòng hướng dẫn tôi về cách tôi làm điều đó?

    hỏi ngày 29 tháng 1 năm 2015 lúc 14:53Jan 29, 2015 at 14:53

    Hướng dẫn merge audio python - hợp nhất âm thanh python

    FahadkalisfahadkalisFahadkalis

    2.8517 Huy hiệu vàng22 Huy hiệu bạc40 Huy hiệu đồng7 gold badges22 silver badges40 bronze badges

    Tôi đã nhận được câu trả lời của câu hỏi của tôi, bạn cũng có thể thử nó và cho tôi biết nếu cần thêm hỗ trợ

    cmd = 'ffmpeg -y -i Audio.wav  -r 30 -i Video.h264  -filter:a aresample=async=1 -c:a flac -c:v copy av.mkv'
    subprocess.call(cmd, shell=True)                                     # "Muxing Done
    print('Muxing Done')
    

    Đã trả lời ngày 3 tháng 2 năm 2015 lúc 15:20Feb 3, 2015 at 15:20

    Hướng dẫn merge audio python - hợp nhất âm thanh python

    FahadkalisfahadkalisFahadkalis

    2.8517 Huy hiệu vàng22 Huy hiệu bạc40 Huy hiệu đồng7 gold badges22 silver badges40 bronze badges

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    

    Tôi đã nhận được câu trả lời của câu hỏi của tôi, bạn cũng có thể thử nó và cho tôi biết nếu cần thêm hỗ trợ

    Đã trả lời ngày 3 tháng 2 năm 2015 lúc 15:20Apr 6, 2020 at 15:31

    Nguồn :: https: //www.programcalet.com/python/example/105718/moviepy.editor.videofileclip Ví dụ số 6faiza

    Đã trả lời ngày 6 tháng 4 năm 2020 lúc 15:311 silver badge1 bronze badge

    1

    Faizafaiza

    511 Huy hiệu bạc1 Huy hiệu đồng

    { $mergeObjects: [ { a: 1 }, null ] }

    7

    Công cụ tốt nhất để thao tác với luồng âm thanh và video là FFMPEG/LIBAV. Bạn có phải sử dụng Python không? Bạn có thể sử dụng các nhị phân dòng lệnh từ các dự án này.

    Ví dụ: được lấy từ https://wiki.libav.org/snippets/avconv:

    (Tất nhiên bạn sẽ muốn điều chỉnh các tham số cho các tệp của mình và QSCale cho chất lượng bạn muốn.)Jan 29, 2015 at 16:33

    Hướng dẫn merge audio python - hợp nhất âm thanh python

    Bạn có thể gọi cái này từ bên trong Python bằng mô -đun phụ. Nếu bạn phải làm điều đó trực tiếp trong Python, bạn có thể sử dụng PyAV (https://pypi.python.org/pypi/av/0.1.0), nhưng điều này sẽ liên quan đến nỗ lực nhiều hơn.rod

    Đã trả lời ngày 29 tháng 1 năm 2015 lúc 16:334 gold badges18 silver badges24 bronze badges

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 chấp nhận một toán hạng duy nhất.MongoDB Manual

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7

    Tài liệu về nhà → Hướng dẫn sử dụng MongoDB → MongoDB Manual

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 có sẵn trong các giai đoạn này: is available in these stages:

    • { $mergeObjects: [ <document1>, <document2>, ... ] }

      9
    • { $mergeObjects: [ { a: 1 }, null ] }

      0
    • { $mergeObjects: [ { a: 1 }, null ] }

      1

    Khi được sử dụng như một bộ tích lũy giai đoạn

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    9,

    { $mergeObjects: [ { a: 1 }, null ] }

    0 hoặc

    { $mergeObjects: [ { a: 1 }, null ] }

    1,

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 có cú pháp này:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 has this syntax:
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    2

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    has this syntax:
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    2

    Khi được sử dụng trong các biểu thức khác (bao gồm trong các giai đoạn

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    9,

    { $mergeObjects: [ { a: 1 }, null ] }

    0 và

    { $mergeObjects: [ { a: 1 }, null ] }

    1) nhưng không phải là một bộ tích lũy,

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 có cú pháp này:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 has this syntax:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    90 có thể là bất kỳ biểu thức hợp lệ nào giải quyết được một tài liệu.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    has this syntax:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    90 có thể là bất kỳ biểu thức hợp lệ nào giải quyết được một tài liệu.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 bỏ qua các toán hạng
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    92. Nếu tất cả các toán hạng thành

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 giải quyết thành NULL,

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 trả về một tài liệu trống
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    95. ignores
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    92 operands. If all the operands to

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 resolves to null,

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 returns an empty document
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    95.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    resolves to null,

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    returns an empty document
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    95.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 ghi đè lên các giá trị trường khi nó hợp nhất các tài liệu. Nếu các tài liệu hợp nhất bao gồm cùng một tên trường, trường, trong tài liệu kết quả, có giá trị từ tài liệu cuối cùng được hợp nhất cho trường. overwrites the field values as it merges the documents. If documents to merge include the same field name, the field, in the resulting document, has the value from the last document merged for the field.

    Thí dụ

    Kết quả

    { $mergeObjects: [ { a: 1 }, null ] }

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    9

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    2

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    3

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    4

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    5

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    6

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7

    Tạo bộ sưu tập

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    97 với các tài liệu sau:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    0

    Tạo một bộ sưu tập khác

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    98 với các tài liệu sau:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    1

    Hoạt động sau đây sử dụng giai đoạn

    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    99 để tham gia hai bộ sưu tập theo các trường

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    20 và sau đó sử dụng

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 trong

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    22 để hợp nhất các tài liệu đã tham gia từ
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    98 và
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    97:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 in the

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    22 to merge the joined documents from
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    98 and
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    97:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    2

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    in the

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    22 to merge the joined documents from
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    98 and
    def combine_audio(vidname, audname, outname, fps=25):
        import moviepy.editor as mpe
        my_clip = mpe.VideoFileClip(vidname)
        audio_background = mpe.AudioFileClip(audname)
        final_clip = my_clip.set_audio(audio_background)
        final_clip.write_videofile(outname,fps=fps)
    
    97:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    2

    Hoạt động trả về các tài liệu sau:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    3

    Tạo một bộ sưu tập

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    25 với các tài liệu sau:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    4

    Hoạt động sau sử dụng

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 làm bộ tích lũy trong giai đoạn

    { $mergeObjects: [ { a: 1 }, null ] }

    1 nhóm các tài liệu theo trường

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    20:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 as a accumulator in a

    { $mergeObjects: [ { a: 1 }, null ] }

    1 stage that groups documents by the

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    20 field:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    as a accumulator in a

    { $mergeObjects: [ { a: 1 }, null ] }

    1 stage that groups documents by the

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    20 field:

    Ghi chú

    Khi được sử dụng như một bộ tích lũy, toán tử

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 chấp nhận một toán hạng duy nhất.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 operator accepts a single operand.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    5

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7
    operator accepts a single operand.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    5

    Hoạt động trả về các tài liệu sau:

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    6

    Ghi chú

    Khi được sử dụng như một bộ tích lũy, toán tử

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 chấp nhận một toán hạng duy nhất.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    7 operator accepts a single operand.

    { $mergeObjects: [ <document1>, <document2>, ... ] }

    5