2014-07-28 9:38 GMT+02:00 Claudiu Rad <[email protected]>: > hello all, > > using ffmpeg i want to live transcode an input live stream into multiple > variants and push all of them (including the original) to the client. > everything works all right except for one thing: i want all keyframes to be > properly aligned between streams but it seems that over time, they get > misaligned which is probably as expected because it would make sense for > ffmpeg to treat each output and do its keyframe generation quite > independently. however, the first question: > > 1. how can i enforce keyframe alignment between output transcoded > (reencoded) streams in ffmpeg? i don't need P/B or other frame types to be > aligned, but I-frames should be exactly on the same frame numbers on all > streams > > to extend this even further: > > 2. how can i enforce keyframe alignment also with input which i would like > to simply -c copy ? this means that reencoded outputs should have the > exactly same keyframe placements as the input, thus, internal codec > heuristics should be disabled on this matter. > > i am talking about a h264/x264 input/output. > > thanks much. > > -- > Claudiu
I do live encoding with ffmpeg via rtmp to Akamai. I have not been able to use the original stream, but that was not a problem in my case since it was an mpeg2 stream from multicast or raw video from a capturecard and, needed to be transcoded anyways. I have had more problems with the bug where rtmp and issue #1604. But I have had good success on the current git version with something like this, if you can live with transcoding the original stream (example in PAL SD format): ffmpeg -i udp://X.X.X.X:XXXX^ -filter_complex "[0:0] yadif=0:0,split=4[v1][v2][v3][v4];[v1]scale=720:576[v1o];[v2]scale=720:432[v2o];[v3]scale=640:360[v3o];[v4]scale=384:216[v4o];[0:1] asplit=4[a1][a2][a3][a4]"^ -map "[v1o]" -map "[a1"] -pix_fmt yuv420p^ -r 25 -c:v libx264 -preset veryfast -x264opts keyint=50:min-keyint=50 -crf 18 -maxrate 3372k -bufsize 7000k -profile:v high -aspect 16:9^ -c:a libvo_aacenc -b:a 128k -ac 2^ -f flv "rtmp://p.epXXXXXX.i.akamaientrypoint.net/EntryPoint/XXXXX_1_3500@XXXXXX flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=XXXXX pubPasswd=XXXXX"^ -map "[v2o]" -map "[a2"] -pix_fmt yuv420p^ -r 25 -c:v libx264 -preset veryfast -x264opts keyint=50:min-keyint=50 -crf 18 -maxrate 2372k -bufsize 5000k -profile:v main -aspect 16:9^ -c:a libvo_aacenc -b:a 128k -ac 2^ -f flv "rtmp://p.epXXXXXX.i.akamaientrypoint.net/EntryPoint/XXXXX_1_2500@XXXXXX flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=XXXXX pubPasswd=XXXXX"^ -map "[v3o]" -map "[a3"] -pix_fmt yuv420p^ -r 25 -c:v libx264 -preset veryfast -x264opts keyint=50:min-keyint=50 -crf 18 -maxrate 1404k -bufsize 3000k -profile:v main -aspect 16:9^ -c:a libvo_aacenc -b:a 96k -ac 2^ -f flv "rtmp://p.epXXXXXX.i.akamaientrypoint.net/EntryPoint/XXXXX_1_1500@XXXXXX flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=XXXXX pubPasswd=XXXXX"^ -map "[v4o]" -map "[a4"] -pix_fmt yuv420p^ -r 10 -c:v libx264 -preset veryfast -x264opts keyint=20:min-keyint=20 -crf 18 -maxrate 252k -bufsize 500k -profile:v baseline -aspect 16:9^ -c:a libvo_aacenc -b:a 48k -ac 2^ -f flv "rtmp://p.epXXXXXX.i.akamaientrypoint.net/EntryPoint/XXXXX_1_300@XXXXXX flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) live=true pubUser=XXXXX pubPasswd=XXXXX" I hope it can be of use to someone. Keyframes seem aligned at every 2 seconds, and HLS from Akamai seem to work fine. The rates above are not fine tuned, I have mostly been experimenting. Your question is interesting, though. It could be really useful for adaptive streaming to align keyframes to a source and keep that as the most high quality stream. /Carl L _______________________________________________ ffmpeg-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-user
