how to join ts files together into mp4 with ffmpeg?
Solution 1
You're asking ffmpeg to encode the files into mp4 instead joining them into a single stream. You need to concatenate into temp.ts
and then convert that into .mp4
with -codec copy
.
Also, I believe you need to convert adts
to aac
in the second step -bsf:a aac_adtstoasc
.
Solution 2
If you do not re-encode, you might not be able to change the key frames etc of the video, resulting to the behavior you describe.
You could try however something like:
ffmpeg -i stream.m3u8 -codec:v "libx264" "-preset" "ultrafast" output.mp4
Keep in mind that what you gain in speed you lose in quality, so "fast" might be better...
Related videos on Youtube
Nicky Smits
Updated on September 18, 2022Comments
-
Nicky Smits over 1 year
I download a lot of streams since the internet speed is too slow to watch high definition. When I download a stream I find the .m3u8 file which points to the TS files. Then I use the following command:
ffmpeg -i stream.m3u8 vid.mp4
This works. But it takes a really long time because it basically reëncodes everything, even though it's already the right format. To avoid reëncoding I can use this command:
ffmpeg -i stream.m3u8 -vcodec copy -acodec copy vid.mp4
This works fine when I play from start to end without interuption. But When I skip back or forward, vlc has trouble creating an image. It can't properly display for a few seconds. This is very annoying.
My question: How Can I create the video without complete reëncoding, but WITH good vlc rendering at any point?
-
Elisa Cha Cha over 9 yearsDo you specifically need the MP4 container format? Please show the complete console output from your second command.
-
Nicky Smits over 9 yearsI do not specifically need the mp4 container. An MKV would siffice. That doesnt get rid of the problem though
-
-
Nicky Smits about 9 yearsI tried this and the result is not satisfying. The audio never had any problems in the MKV format, just the video stream had hiccups. And with this, I get the same while having to perform three seperate steps.
-
Thalys about 6 yearsIt might be worth adding a little more than a screenshot - here's a guide on how to recommend software. I also noticed your username and the name on the github account is the same - revealing your affliation to the software is necessary,