FFmpeg Fails to Process MP4 File Despite VLC Media Player Success
When it comes to working with audio and video files, FFmpeg is a popular choice for many users. However, there are instances when FFmpeg may encounter issues while processing certain files, even though other media players, such as VLC Media Player, can handle them seamlessly.
The Problem: FFmpeg Fails to Merge MP4 Files
Suppose you have multiple video files with the same codec (Video, h264 (avc1), 1920x1080) and wish to merge them into a single file using FFmpeg 5.1.4. You might execute a command similar to the following:
ffmpeg -i "concat:file1.mp4|file2.mp4|file3.mp4" -c copy output.mp4However, you receive an error instead of the desired output:
$ ffmpeg -i "concat:file1.mp4|file2.mp4|file3.mp4" -c copy output.mp4
[mp4 @ 0x7f883c000600] Non-monotonous DTS in output stream 0:0; previous: 285528, current: 285528; changing to 285529. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f883c000600] Non-monotonous DTS in output stream 0:0; previous: 285529, current: 285551; changing to 285530. This may result in incorrect timestamps in the output file.
...
[mp4 @ 0x7f883c000600] Non-monotonous DTS in output stream 0:0; previous: 8564159, current: 8564159; changing to 8564160. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f883c000600] Non-monotonous DTS in output stream 0:0; previous: 8564160, current: 8564382; changing to 8564161. This may result in incorrect timestamps in the output file.
frame= 3376 fps=0.0 q=-1.0 size=N/A time=00:01:45.42 bitrate=N/A speed= 543x
video:3375688kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!The Solution: Use VLC Media Player Instead
Although FFmpeg fails to merge the files, VLC Media Player can accomplish the task without any issues. To merge the files using VLC, follow these steps:
- Open VLC Media Player.
- Click on Media in the top menu and select Open Multiple Files...
- In the Open Media dialog, click on the Add... button and select the video files you wish to merge.
- After adding the files, click on the Play dropdown button and select Stream.
- In the Stream Output dialog, check the Display locally option.
- Click on the Next button.
- In the New Destination dialog, select File and click on the Add button.
- Choose a destination file name and click on the Next button.
- In the Profile Edition dialog, ensure that the Video - H.264 + MP3 (MP4) profile is selected.
- Click on the Next button.
- In the Options dialog, leave all options at their default values and click on the Next button.
- Finally, in the Stream Output dialog, click on the Stream button to start the merging process.
While FFmpeg is a powerful tool for working with audio and video files, it is not invulnerable to issues. In such cases, alternative media players like VLC Media Player can often provide a solution. By understanding the limitations of different tools and learning how to work around them, you can effectively manage and merge your multimedia files.