Answers.Body: <p>I used ffmpeg with only '-i' switch to figure out which stream was audio and which was video. Then executed the following to merge two audio channels and its video. </p>
  
  <pre><code>ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -filter_complex "[1:0] [2:0] amerge" -c:v libx264 -c:a aac -strict experimental -qscale 0 -y  ../ffmpeg-att2.mp4
  </code></pre>
  
  <p>I think there can be more options by utilizing all four audio files to make stereo or surround. However, I stopped here as the output was acceptable. <br>Note - used '-qscale 0'  to limit quality-loss. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-21T13:33:19.027Z
Answers.LastActivityDate: 2019-06-21T13:33:19.027Z
Answers.UserDisplayName: anup
Body: <p>On a recent video shoot, the camera man gave us output as .MXF files. Incidentally, Audio and Video are saved in separate .mxf files. 
  <br><br>
  eg:<br>
  0007WA00.MXF - Audio  (<a href="https://paste.ubuntu.com/p/Hqrmwk6rf4/" rel="nofollow noreferrer">probe</a>)<br>
  0007WA01.MXF - Audio  (<a href="https://paste.ubuntu.com/p/HnbFRZsFyR/" rel="nofollow noreferrer">probe</a>)<br>
  0007WA02.MXF - Audio  (<a href="https://paste.ubuntu.com/p/WSvH7gZSFq/" rel="nofollow noreferrer">probe</a>)<br>
  0007WA03.MXF - Audio  (<a href="https://paste.ubuntu.com/p/Y5MQRTfzbq/" rel="nofollow noreferrer">probe</a>)<br>
  0007WA.MXF - Video  (<a href="https://paste.ubuntu.com/p/D7jXN4bgJT/" rel="nofollow noreferrer">probe</a>)<br></p>
  
  <p>I am trying to figure out how to merge these in to a single video file. So far I couldn't find a way out.</p>
  
  <p>[Edit: 20 Jun 2019]<br>
  I managed to get audio and video stitched. However, audio is mono. Want a little clarity on whether I can have stereo or surround by utilizing the 4 audio files.</p>
  
  <p>Command that worked:</p>
  
  <pre><code>ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -c:v libx264 -c:a aac -strict experimental ../ffmpeg-stitch-mxf.mp4
  </code></pre>
  
  <p><em>Let me add that I am not an expert at this. Perhaps some may find my questions naive.</em> </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-19T17:41:37.087Z
Comments.Text: What command did you try?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T05:39:17.363Z
Comments.Text: ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -c:v copy -c:a aac -strict experimental ../ffmpeg-stitch-mxf.mxf
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T05:40:24.343Z
Comments.Text: that didn't work. However, gonna re-try with video codec too. Let's see if that works!
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T05:53:01.833Z
Comments.Text: added an edit to the question.
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T10:46:58.480Z
Comments.Text: Do you want to open the merged file in a professional video editor?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T18:03:44.047Z
Comments.Text: So the audio is 4 channels and they are supposed to play over the 1 video stream?  Seems that way, since they are all the same length, but just want to be clear. Gyan asks an important question: What do you want to do with the resultant file (e.g. post to YT, open in a editor for further processing, etc.)?
Comments.UserDisplayName: user3643
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T18:04:45.693Z
Comments.Text: A follow up on the audio channels: Are all of them actually used? I find that most times, only 1 or 2 channels are used. Can you verify that all files have content that you want?
Comments.UserDisplayName: user3643
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T18:07:31.757Z
Comments.Text: You probably need to look into the `-map` flag to get what you want. See this related question: [ffmpeg - mapping an audio file with 2 channels to a video file?](https://video.stackexchange.com/questions/18738/ffmpeg-mapping-an-audio-file-with-2-channels-to-a-video-file)
Comments.UserDisplayName: user3643
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:31:58.543Z
Comments.Text: Q: So the audio is 4 channels and they are supposed to play over the 1 video stream >> A: Yes |  Q: Gyan asks an important question: What do you want to do with the resultant file >> A: Eventually to Web. But, a video editor will process it before uploading. Processing = adding watermark, text, cut-n-merge etc.
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:34:08.333Z
Comments.Text: Addon-Q: Why look at ffmpeg when there is a video editor? >> A: Video editor wants a format he/she can work with. The Panasonic camera for some reason recorded in MXF and with audio separate from video (courtesy camera man). Me, a Linux user is exploring solution to the given problem.
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:37:16.227Z
Comments.Text: Suggestion: You probably need to look into the -map flag to get what you want. >> Reply:  That is what I did eventually. I wanted to post that as an answer, but I waited to see if some one gives a better solution. I used only two audio files in the merge. |  I think I should post that as an answer and let community enhance it, if there is scope.
Comments.UserDisplayName: anup
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T14:45:16.970Z
Comments.Text: Use `ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -map 0 -map 1 -map 2 -map 3 -map 4 -c copy merged.mov` to generate a file for the editor.
Comments.UserDisplayName: Gyan
Tags: <ffmpeg><mxf>
Title: How to merge 4 Audio and 1 Video .MXF files in to one h.264 video file on Linux using ffmpeg?
UserDisplayName: anup
ThreadText: # How to merge 4 Audio and 1 Video .MXF files in to one h.264 video file on Linux using ffmpeg?
  
  (Asked by: username_0 on 2019-06-19)
  
  On a recent video shoot, the camera man gave us output as .MXF files. Incidentally, Audio and Video are saved in separate .mxf files.
    
    
  eg:  
  0007WA00.MXF - Audio ([probe](https://paste.ubuntu.com/p/Hqrmwk6rf4/))  
  0007WA01.MXF - Audio ([probe](https://paste.ubuntu.com/p/HnbFRZsFyR/))  
  0007WA02.MXF - Audio ([probe](https://paste.ubuntu.com/p/WSvH7gZSFq/))  
  0007WA03.MXF - Audio ([probe](https://paste.ubuntu.com/p/Y5MQRTfzbq/))  
  0007WA.MXF - Video ([probe](https://paste.ubuntu.com/p/D7jXN4bgJT/))
  
  I am trying to figure out how to merge these in to a single video file. So far I couldn't find a way out.
  
  [Edit: 20 Jun 2019]  
  I managed to get audio and video stitched. However, audio is mono. Want a little clarity on whether I can have stereo or surround by utilizing the 4 audio files.
  
  Command that worked:
  
  ```
  ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -c:v libx264 -c:a aac -strict experimental ../ffmpeg-stitch-mxf.mp4
  
  ```
  
  *Let me add that I am not an expert at this. Perhaps some may find my questions naive.*
  
  **Tags:** ffmpeg, mxf
  
  > **Comments:**
  > **username_1**: What command did you try?  
  > **username_0**: ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -c:v copy -c:a aac -strict experimental ../ffmpeg-stitch-mxf.mxf  
  > **username_0**: that didn't work. However, gonna re-try with video codec too. Let's see if that works!  
  > **username_0**: added an edit to the question.  
  > **username_1**: Do you want to open the merged file in a professional video editor?  
  > **username_2**: So the audio is 4 channels and they are supposed to play over the 1 video stream?  Seems that way, since they are all the same length, but just want to be clear. username_1 asks an important question: What do you want to do with the resultant file (e.g. post to YT, open in a editor for further processing, etc.)?  
  > **username_2**: A follow up on the audio channels: Are all of them actually used? I find that most times, only 1 or 2 channels are used. Can you verify that all files have content that you want?  
  > **username_2**: You probably need to look into the `-map` flag to get what you want. See this related question: [ffmpeg - mapping an audio file with 2 channels to a video file?](https://video.stackexchange.com/questions/18738/ffmpeg-mapping-an-audio-file-with-2-channels-to-a-video-file)  
  > **username_0**: Q: So the audio is 4 channels and they are supposed to play over the 1 video stream >> A: Yes |  Q: username_1 asks an important question: What do you want to do with the resultant file >> A: Eventually to Web. But, a video editor will process it before uploading. Processing = adding watermark, text, cut-n-merge etc.  
  > **username_0**: Addon-Q: Why look at ffmpeg when there is a video editor? >> A: Video editor wants a format he/she can work with. The Panasonic camera for some reason recorded in MXF and with audio separate from video (courtesy camera man). Me, a Linux user is exploring solution to the given problem.  
  > **username_0**: Suggestion: You probably need to look into the -map flag to get what you want. >> Reply:  That is what I did eventually. I wanted to post that as an answer, but I waited to see if some one gives a better solution. I used only two audio files in the merge. |  I think I should post that as an answer and let community enhance it, if there is scope.  
  > **username_1**: Use `ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -i 0007WA02.MXF -i 0007WA03.MXF -map 0 -map 1 -map 2 -map 3 -map 4 -c copy merged.mov` to generate a file for the editor.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-06-21. Score: 0
  
  I used ffmpeg with only '-i' switch to figure out which stream was audio and which was video. Then executed the following to merge two audio channels and its video.
  
  ```
  ffmpeg -i 0007WA.MXF -i 0007WA00.MXF -i 0007WA01.MXF -filter_complex "[1:0] [2:0] amerge" -c:v libx264 -c:a aac -strict experimental -qscale 0 -y  ../ffmpeg-att2.mp4
  
  ```
  
  I think there can be more options by utilizing all four audio files to make stereo or surround. However, I stopped here as the output was acceptable.   
  Note - used '-qscale 0' to limit quality-loss.
  
  
  ---
  
  