audio – FFMPEG conversion from .ts files to .mp4 playback issue
I am converting a bunch (990) of .ts
files into an .mp4
video file using ffmpeg
.
The resulting .mp4
file will play perfectly fine in vlc
, however when I play it in QuickTime
on Mac, or more specifically my own video player that uses an AVPlayerView
it will play fine for about 10 minutes, then the sound will start to skip, as in every 2 seconds there is a very brief blip/pause. Stopping the video and playing it again from the same point let’s it play fine again for another ~10mins.
My initial thought was an issue with my own video app, but QuickTime has the same issue.
I’m combining all the .ts
files like this:
ffmpeg -y -f concat -safe 0 -i list.txt -c copy video.ts
Then I convert it into an .mp4
like this:
ffmpeg -y -i video.ts -acodec copy -vcodec copy video.mp4
Other things I tried
Specifying the video codec:
ffmpeg -i video.ts -acodec copy -vcodec libx264 video.mp4
First converting to .mkv
:
ffmpeg -i video.ts -map 0 -c copy output.mkv
ffmpeg -i video.mkv -acodec copy -vcodec copy video.mp4
Convert to m4a
:
ffmpeg -i video.ts -vcodec h264 -c:a aac video.mp4
I noticed when I use ffprobe
it reports the final video as 29.88 fps
but the original .ts
is 30 fps
. I’m not sure if this is the problem, so I tried forcing the framerate to stay the same:
ffmpeg -i video.ts -acodec copy -filter:v fps=30 video.mp4
None of the above seem to make a difference.
Could there be an issue with how the .ts
files are combined? Although the full .ts
appears to play ok in QuickTime.
Is there another method I can try to combine them?
Stream details
Original single .ts file:
Input #0, mpegts, from '162.ts':
Duration: 00:00:05.49, start: 883.612144, bitrate: 873 kb/s
Program 1
Stream #0:0[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s
Stream #0:1[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn
Combined .ts
file:
Input #0, mpegts, from 'video.ts':
Duration: 01:30:21.54, start: 1.400000, bitrate: 690 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn
Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s
Converted to .mp4
:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf61.1.100
Duration: 01:30:21.56, start: 0.000000, bitrate: 616 kb/s
Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 480 kb/s, 29.88 fps, 30 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Converted with fps=30
:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf61.1.100
Duration: 01:30:21.56, start: 0.000000, bitrate: 768 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 632 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc61.3.100 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Read more here: Source link