0
votes

i have a problem about transcode with ffmpeg

i want to cover m3u8 to mp4, so i transcode every ts file first, and then concat them to a mp4, but i found that the duration will be bigger than source file.

source file is : http://oc7iy3eta.bkt.clouddn.com/src_20.ts

after transcode, test file is: http://oc7iy3eta.bkt.clouddn.com/test_20.ts

i use the command as bellow to change to 5fps, and 400k bitrate:

sudo ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -nostdin -y -v warning -i ./src_20.ts -threads 3 -movflags faststart -metadata:s:v rotate=0 -chunk_duration 520000 -video_track_timescale 25000 -pix_fmt yuv420p -copytb 1 -vcodec libx264 -b:v 400000 -minrate 400000 -maxrate 400000 -bufsize 500k -force_key_frames "expr:gte(t,n_forced*2)" -vsync 1 -r 5 -s 544*960 -acodec libfaac -async 1 ./test_20.ts

i use ffprobe command to see video info:

source file info:

Duration: 00:00:01.26, start: 28.346989, bitrate: 921 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 23 kb/s Stream #0:1[0x101]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 10.67 tbr, 90k tbn, 180k tbc

test file:

Input #0, mpegts, from 'test_20.ts': Duration: 00:00:01.62, start: 1.576778, bitrate: 447 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 5 fps, 5 tbr, 90k tbn, 10 tbc Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 5 kb/s

=======================================================================

question

so , we can see that the duration of src file is 1.26s , but after transcode, the test file is 1.62s.

why? can anybody help

1
I think -video_track_timescale 90000 could solve it - see video.stackexchange.com/questions/19237/…mika
thank you!but i got the same result after change -video_track_timescale 90000Feilong Luo
I suggest you save the m3u8 to a single TS and then transcode that to MP4. ffmpeg -i in.m3u8 -c copy src.ts . Your current command is transcoding each TS to CFR at half the rate but your source timestamps have some jitter, so due to PTS quantization, there will be a mismatch. A single file transcode will minimize it.Gyan
thank you so much! i save m3u8 to single ts and then transcode to mp4, the duration is okFeilong Luo

1 Answers

0
votes

I suggest you save the m3u8 to a single TS and then transcode that to MP4.

ffmpeg -i in.m3u8 -c copy src.ts

Your current command is transcoding each TS to CFR at half the rate but your source timestamps have some jitter, so due to PTS quantization, there will be a mismatch. A single file transcode will minimize it.