gpt4 book ai didi

audio - ffmpeg 将 MXF 视频的多个 (N) 单声道音频 channel 合并到 MP4 视频的多个 (M) 立体声 channel

转载 作者:行者123 更新时间:2023-12-02 23:27:43 26 4
gpt4 key购买 nike

我有一个包含 16 个音频单声道流的 MXF 文件,我需要将其重新编码为一个 mp4 文件,其中 2<=n<=16 个 channel 合并输入流,例如在输出 channel 1 上输入 channel 1 和 2,在输出 channel 2 上输入 channel 9 和 10。这项工作将使用 ffmpeg 完成。我阅读了文档,发现 amerge 和 amix 过滤器会很好,但它们只输出一个 channel 。这个问题有什么解决办法吗?

谢谢,
劳拉

在 mxf 文件的 ffprobe 输出下方找到:

{ "streams":[ { "index":0, "codec_name":"mpeg2video", "codec_long_name":"MPEG-2 video", "profile":"4:2:2", "codec_type":"video", "codec_time_base":"1/25", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "width":1920, "height":1080, "coded_width":0, "coded_height":0, "has_b_frames":1, "sample_aspect_ratio":"1:1", "display_aspect_ratio":"16:9", "pix_fmt":"yuv422p", "level":2, "color_range":"tv", "color_space":"bt709", "color_transfer":"bt709", "color_primaries":"bt709", "chroma_location":"topleft", "field_order":"tt", "refs":1, "r_frame_rate":"25/1", "avg_frame_rate":"25/1", "time_base":"1/25", "start_pts":0, "start_time":"0.000000", "duration_ts":448, "duration":"17.920000", "bit_rate":"50000000", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":1, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":2, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":3, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":4, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":5, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":6, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":7, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } }, { "index":8, "codec_name":"pcm_s24le", "codec_long_name":"PCM signed 24-bit little-endian", "codec_type":"audio", "codec_time_base":"1/48000", "codec_tag_string":"[0][0][0][0]", "codec_tag":"0x0000", "sample_fmt":"s32", "sample_rate":"48000", "channels":1, "bits_per_sample":24, "r_frame_rate":"0/0", "avg_frame_rate":"0/0", "time_base":"1/48000", "start_pts":0, "start_time":"0.000000", "duration_ts":860160, "duration":"17.920000", "bit_rate":"1152000", "bits_per_raw_sample":"24", "disposition":{ "default":0, "dub":0, "original":0, "comment":0, "lyrics":0, "karaoke":0, "forced":0, "hearing_impaired":0, "visual_impaired":0, "clean_effects":0, "attached_pic":0, "timed_thumbnails":0 }, "tags":{ "file_package_umid":"0x060A2B340101010501010D2313000000968F75C6B5B34D649967EEDD0076B989" } } ], "format":{ "filename":"/media-caches/video-essence/VIDEO/MXF-XDCAM_HD422@50Mbps1080i25_16Ch/941.mxf", "nb_streams":9, "nb_programs":0, "format_name":"mxf", "format_long_name":"MXF (Material eXchange Format)", "start_time":"0.000000", "duration":"17.920000", "size":"135028296", "bit_rate":"60280489", "probe_score":100, "tags":{ "uid":"0a9ef41a-36b4-4066-a8a3-b95f62299b6c", "generation_uid":"e134647e-fea1-4673-91c1-afa277d13c00", "company_name":"Sony", "product_name":"MPC", "product_version":"v1.0", "application_platform":"Sony MXF Development Kit (Win32)", "product_uid":"060e2b34-0401-0103-0e06-0120027f0200", "modification_date":"2012-09-17T11:56:20.000000Z", "material_package_umid":"0x060A2B340101010501010D231300000081C32F48A63347D4890F55D3ADC25B99", "timecode":"00:35:30:08" } } }

最佳答案

代码用换行符组织。一个 \在 Unix shell 中换行。

ffmpeg -i "in.mxf" \
-filter_complex "\
[a:0][a:1]amerge=inputs=2[ch1ch2];\
[a:8][a:9]amerge=inputs=2[ch9ch10]" \
-map 'v:0' \
-map '[ch1ch2]' \
-map '[ch9ch10]' \
-c:v copy \
-c:a aac -b:a 128k -ar 48000 -ac 2 \
"out.mp4"
  • 输入
  • filter_complex (使用 " 而不是 ' 。如果我使用 shell 换行符 \ 我会收到单引号错误 ' )
  • 使用 amerge筛选和选择
  • 第一个音频流 a:0
  • 第二个音频流a:1 ,
  • 合并它们和
  • 将其存储在输出垫 ch1ch2 (你可以给它任何名字)
  • 使用另一个 amerge筛选和选择
  • 第 9 个音频流 a:8
  • 第 10 个音频流 a:9 ,
  • 合并它们和
  • 将其存储在输出垫 ch9ch10
  • 映射视频流(如果省略,则输出没有视频)
  • map 垫ch1ch2到第一个音频流
  • map 垫ch9ch10到第二个音频流
  • 复制视频流(如果省略,您的视频将被重新编码)
  • 使用 aac
  • 对所有音频流进行编码
  • 输出

  • 这里的输出只有 2 个映射的音频 channel 。

    如果你想保留一些剩余的 channel ,你必须映射它们。
    您甚至可以添加 -map 0在第 7 行之后将所有流堆叠在合并的流之下。 (当然你最终会得到 2+16 个音频流。)

    您可以添加更多 amerge过滤器。用 ; 将它们分开
    您还可以将 3 个音频流与 [a:0][a:1][a:2]amerge=inputs=3[ch1ch2ch3] 合并.
    将音频 channel 命名为
    -metadata:s:a:0 title="channel 1 and 2"
    这对于测试很有用,因为您可以在 VLC 中看到名称。

    关于audio - ffmpeg 将 MXF 视频的多个 (N) 单声道音频 channel 合并到 MP4 视频的多个 (M) 立体声 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60211488/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com