最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

concatenation - How to have a clean transition when concat MTS files using ffmpeg? - Stack Overflow

programmeradmin1浏览0评论

I have been struggling for a while and I hope someone can help me. What I want to do: 1- seek MTS files 2- conact them without re-encoding them

How I do that: I write a file concatList.txt

file 'file1.MTS'
file 'file1_cut.MTS'

I execute

ffmpeg -y -i file1.MTS -ss 11.5 -c copy -copyts file1_cut.MTS
ffmpeg -y -f concat -i concatList.txt -c copy output.MTS

(11.5s corresponds to an I-frame)

The transition between the two videos in output.MTS is very buggy during more than 1s

To dig in, I tried to analyse the streams but it rises many questions:

ffprobe -select_streams v -show_entries frame=pict_type,pts_time,pic_type,pts -skip_frame nokey -of compact -i file1.MTS
pts;pts_time;pict_type
147600;1.640000;I
100800;1.120000;I
1083600;12.040000;I
1036800;11.520000;I ==> I cut the file here
2019600;22.440000;I
1972800;21.920000;I
2955600;32.840000;I
2908800;32.320000;I

==> Why not all I-frames are found by the -skip_frame nokey option ?

ffmpeg -y -i file1_cut.MTS -map v:0 -c copy -copyts -f framemd5 file1_cut.md5

combined with the following command output

ffprobe -select_streams v -show_entries frame=pict_type,pts_time,pic_type,pts -of compact -i file1_cut.MTS
stream;dts;diff_dts;pts;duration;size;hash;pts_time;pict_type
0;163800;0;174600;1800;197323;7e228dfab2cb38922cab06844d67bf8c;1.94;I ==> This is the correct I-frame
0;165600;1800;176400;1800;28860;80ef4505813b99bb4484c969f589fa35;;
0;167400;1800;167400;1800;30289;d172722d01631a13caed81fc6be5b828;; ==> Why no frame type found by ffprobe ??
0;169200;1800;169200;1800;23338;e22eb396408abbf66bd6ef4f8893d102;;
0;171000;1800;171000;1800;24414;1a4f128017e8fc239b6c728f0c6d45b2;; ==> Why no frame type found by ffprobe ??
0;172800;1800;172800;1800;28872;acd07b2f3ccbddd072c380bee709a2dc;;
0;174600;1800;181800;1800;42872;eb225b253ebd427f2af01c2861d684c7;2.02;P
0;176400;1800;183600;1800;35942;58a238b781b1bfe720aa6de61830e3b1;;
0;178200;1800;178200;1800;22080;c6b43fbf1083d40499d908f0f02bd3dd;1.98;B
0;180000;1800;180000;1800;24896;4481d088ad425da908daa83220111fd2;;
0;181800;1800;189000;1800;40733;1294f59fe24d17aa8ca34fc327631d80;2.1;P
0;183600;1800;190800;1800;37904;095f7be43c90e97d66fb8427a17cb4c3;;
0;185400;1800;185400;1800;25808;a9d4e63c7607fcf9cd491084cce556ba;2.06;B
0;187200;1800;187200;1800;24874;834117a8d7e106a2278c412ec0acd1df;;
ffmpeg -y -i output.MTS -map v:0 -c copy -copyts -f framemd5 output.md5

combined with the following command output

ffprobe -select_streams v -show_entries frame=pict_type,pts_time,pic_type,pts -of compact -i output.MTS
stream;dts;diff_dts;pts;duration;size;hash;pts_time;pict_type
0;3106800;1800;3114000;1800;45853;7d5c2b6c9f4e1da8f93782b1de7de3a7;34.6;P;
0;3108600;1800;3115800;1800;43213;b07554ad625850e3a4b8de54be6af1dd;;;
0;3110400;1800;3110400;1800;25764;85c4aa6e62db831617a13bf5e6e08dda;34.56;B;
0;3112200;1800;3112200;1800;24328;2e6bac4090917f2bc6ccedc8841612c5;;;
0;3114000;1800;3121200;1800;46802;dfac0337af77c1a895e900048fc757c5;34.68;P; ==> Why pts larger than pts of first file1_cut.MTS frames ??
0;3115800;1800;3123000;1800;41795;b33af7f2e6ca04c3179ef52c37df4fe5;;;
0;3117600;1800;3117600;1800;23488;41a48cd53a2400d9331766ce3565c55c;34.64;B;
0;3119400;1800;3119400;1800;23222;cc85ec074b62a0c51ac8e4e1196db079;;; ==> Last frame of file1.MTS
0;3162240;42840;3173040;1800;197323;7e228dfab2cb38922cab06844d67bf8c;;; ==> First frame of file1_cut.MTS, ==> Why a lag of 42840 (0.4s) between two successive dts ??
0;3164040;1800;3174840;1800;28860;80ef4505813b99bb4484c969f589fa35;;;
0;3165840;1800;3165840;1800;30289;d172722d01631a13caed81fc6be5b828;;; ==> Why all these frames are not detected by ffprobe ??
0;3167640;1800;3167640;1800;23338;e22eb396408abbf66bd6ef4f8893d102;;;
0;3169440;1800;3169440;1800;24414;1a4f128017e8fc239b6c728f0c6d45b2;;;
0;3171240;1800;3171240;1800;28872;acd07b2f3ccbddd072c380bee709a2dc;;;
0;3173040;1800;3180240;1800;42872;eb225b253ebd427f2af01c2861d684c7;;;
0;3174840;1800;3182040;1800;35942;58a238b781b1bfe720aa6de61830e3b1;;;
0;3176640;1800;3176640;1800;22080;c6b43fbf1083d40499d908f0f02bd3dd;;;
0;3178440;1800;3178440;1800;24896;4481d088ad425da908daa83220111fd2;;;
0;3180240;1800;3187440;1800;40733;1294f59fe24d17aa8ca34fc327631d80;35.416;P;
0;3182040;1800;3189240;1800;37904;095f7be43c90e97d66fb8427a17cb4c3;;;
0;3183840;1800;3183840;1800;25808;a9d4e63c7607fcf9cd491084cce556ba;;; ==> Why ffprobe did not recognize the B-frame ??
0;3185640;1800;3185640;1800;24874;834117a8d7e106a2278c412ec0acd1df;;;
0;3187440;1800;3194640;1800;42645;13e6b4afb26734f0515303a5332dec32;35.496;P;
0;3189240;1800;3196440;1800;39393;cfd5bdc15737562fc40ac4527057a034;;;
0;3191040;1800;3191040;1800;25822;01b0d03c710f526c805c7aeaa54a39fb;35.456;B;
0;3192840;1800;3192840;1800;25089;8306d0ab9a0cbaf16283b2019337973e;;;
0;3194640;1800;3201840;1800;44593;1efb42bf015bbd71a54de2999ece272b;35.576;P;
0;3196440;1800;3203640;1800;40391;e6ff5568c1b019250ecd9d3568a7e7b5;;;
0;3198240;1800;3198240;1800;25354;c047b70a8a0725c4d60db8c92ea99706;35.536;B;

So here is my main question: is there a "smart" concat command that cuts the frames of the first file that will never display (pts larger that the first frames of the second file), that anticipates the dts of I-frames of the second files, and that reduces the lag of dts to get a continuous stream?

Thank you if anyone can answer.

发布评论

评论列表(0)

  1. 暂无评论