Excellent question. You've provided the perfect diagnostic information with the ffprobe output. The problem you're experiencing is very common with modern phone videos, and the clues are right there in the data.
Let's break down the causes and then walk through the solutions, from easiest to most robust.
The Two Main Causes
- HEVC (H.265) Codec: Your video uses
hevc (also known as H.265). This is a highly efficient codec that creates smaller files for the same quality compared to the older AVC/H.264. However, it's much more computationally demanding to decode. If your PC's hardware or software isn't set up for it, the CPU gets overloaded, leading to stuttering and lag.
- Variable Frame Rate (VFR): The line
30.04 fps is a strong indicator that your phone recorded with a Variable Frame Rate. This means the number of frames per second changes slightly throughout the video to save space. While this is efficient for recording, many video players and especially video editors struggle with it, causing the audio (which has a constant rate) to drift out of sync with the video. This is almost certainly why your "audio ends earlier than video".
Solution 1: Improve Playback (The Easy Way)
Before you change the files themselves, let's try to make your PC play them better.
Option A: Use a More Powerful Video Player (VLC)
The default video players on Linux Mint (Celluloid or Videos) are good, but VLC is legendary for handling difficult files. It also has excellent, easy-to-configure hardware acceleration.
-
Install VLC:
sudo apt update
sudo apt install vlc
-
Enable Hardware Acceleration in VLC:
- Open VLC.
- Go to
Tools -> Preferences.
- Click on the
Input / Codecs tab.
- Find the
Hardware-accelerated decoding dropdown menu. By default, it's often on "Automatic". Try changing it to "Video Acceleration (VA-API)", which is the standard for Linux.
- Click
Save and restart VLC.
- Now try playing your video file in VLC. For many, this alone solves the problem.
Option B: Check System-Wide Hardware Acceleration
For other players like Celluloid (the Mint default) to work well, your system's graphics drivers and VA-API support must be in order.
- Install the VA-API utility:
sudo apt install vainfo
- Run the utility:
vainfo
- Analyze the output:
-
If it works, you'll see a list of supported codecs, like this (example from an Intel system):
vainfo: VA-API version: 1.17
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.6.5
vainfo: Supported profile and entrypoints
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264High : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD <-- This is the one you need!
... and so on
If you see VAProfileHEVCMain or VAProfileHEVCMain10, your system is capable of hardware decoding.
-
If it fails with an error like vaGetDisplay() failed or vainfo: command not found, it means your graphics drivers may not be installed or configured correctly. The easiest way to check this in Linux Mint is to use the Driver Manager. Open it from your system menu and see if it recommends any proprietary drivers for your graphics card (especially if you have NVIDIA or AMD).
Solution 2: Fix the Video File (The Permanent Fix)
If the playback tweaks don't work, or if you want these files to be compatible with other software (like video editors) and devices, the best solution is to re-encode them into a more standard format.
We will use ffmpeg to do this. The goal is to:
- Convert the video from HEVC (H.265) to the more compatible AVC (H.264).
- Convert the audio/video from Variable Frame Rate (VFR) to Constant Frame Rate (CFR).
- Keep the audio as is, since it's already in a standard format (
aac).
- Correctly apply the 90-degree rotation.
The FFmpeg Command
Open your terminal in the folder where your video is located. Let's say your original file is named input.mp4.
ffmpeg -i input.mp4 -vf "transpose=2" -c:v libx264 -preset medium -crf 23 -r 30 -c:a copy output.mp4
Let's break down what each part does:
ffmpeg -i input.mp4: Specifies the input file.
-vf "transpose=2": This is a video filter (-vf). The transpose filter handles rotation. Your ffprobe shows a rotation of -90 degrees, which corresponds to transpose=2. (For future reference, 1 is for +90 degrees).
-c:v libx264: Sets the video codec (-c:v) to libx264, which is the most popular H.264 encoder. This will make it much easier for your PC to play.
-preset medium: This is a balance between encoding speed and file size. medium is a good default. You can use fast or veryfast for quicker encoding at the cost of a slightly larger file.
-crf 23: This is the quality setting (Constant Rate Factor). 23 is a great default for H.264, offering a good balance of quality and file size. Lower numbers mean better quality and larger files (e.g., 18 is visually lossless).
-r 30: This is a key part for fixing the sync issue. It forces the output video to a constant frame rate (-r) of 30 frames per second. This will fix the audio desync.
-c:a copy: Tells ffmpeg to copy the audio stream (-c:a) without re-encoding it. This is fast and preserves the original audio quality.
output.mp4: The name of your new, fixed video file.
How to Batch Process All Your Videos
If you have many videos in a folder, you can use a simple for loop to convert them all.
- Make a new folder to hold the converted files, for example
mkdir fixed_videos.
- Run this command in the terminal from the folder containing your original videos:
for f in *.mp4; do ffmpeg -i "$f" -vf "transpose=2" -c:v libx264 -preset medium -crf 23 -r 30 -c:a copy "fixed_videos/${f%.mp4}_fixed.mp4"; done
This loop will take every .mp4 file, run the conversion command on it, and save a new version with _fixed at the end of the name inside the fixed_videos folder.
Summary / TL;DR
- First, try the easy fix: Install VLC (
sudo apt install vlc), enable its VA-API hardware acceleration, and see if it plays the file smoothly.
- If that doesn't work, use the permanent fix: Re-encode the video using the
ffmpeg command above. This will convert it to a universally compatible format (H.264, Constant Frame Rate) that will play smoothly on almost any device and fix the audio sync problem for good.