{"action":"opened","issue":{"url":"https://api.github.com/repos/wang-bin/QtAV/issues/429","labels_url":"https://api.github.com/repos/wang-bin/QtAV/issues/429/labels{/name}","comments_url":"https://api.github.com/repos/wang-bin/QtAV/issues/429/comments","events_url":"https://api.github.com/repos/wang-bin/QtAV/issues/429/events","html_url":"https://github.com/wang-bin/QtAV/issues/429","id":74955743,"number":429,"title":"tuning for Zero Latency LiveStream","user":{"login":"christianVT","id":12382992,"avatar_url":"https://avatars.githubusercontent.com/u/12382992?v=3","gravatar_id":"","url":"https://api.github.com/users/christianVT","html_url":"https://github.com/christianVT","followers_url":"https://api.github.com/users/christianVT/followers","following_url":"https://api.github.com/users/christianVT/following{/other_user}","gists_url":"https://api.github.com/users/christianVT/gists{/gist_id}","starred_url":"https://api.github.com/users/christianVT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christianVT/subscriptions","organizations_url":"https://api.github.com/users/christianVT/orgs","repos_url":"https://api.github.com/users/christianVT/repos","events_url":"https://api.github.com/users/christianVT/events{/privacy}","received_events_url":"https://api.github.com/users/christianVT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-10T16:44:57Z","updated_at":"2015-05-10T16:44:57Z","closed_at":null,"body":"Hi,\r\nI want to show a livestream from an IP-Camera with minimum latency.\r\nWithout modification my latency was ~1200ms. I read and tweaked some time around\r\nand with the code below I have reached 440 - 560 ms latency.\r\nThe ONVIF Device Manager (which is also using ffmpeg) has on the same setup a latency of ~320ms.\r\nSo there is still space for improvement.\r\n\r\nI think this is a very common requirement for an app, that is why \r\nI would like to do an community approach. \r\nIn the code below you can see how I did it, and what I have already tried.\r\nIf you have some idea what I should try please tell me. I will try them out and I will post the optimal solution here.\r\nI think it would be great feature if such tuning would be integrated in QtAV.\r\n\r\nsincerely,\r\n\r\nChristian\r\n\r\n\r\n```Cpp\r\n// call this before loading the stream\r\nstatic void tuneForZeroLatencyLiveStream(QtAV::AVPlayer* player)\r\n{\r\n  QVariantHash settings;\r\n\r\n  // sets av_opt_set_xx and av_dict_set settings\r\n  QVariantHash avFormat;\r\n\r\n  {// these settings seem to have no impact on latency?\r\n    //avFormat[\"fpsprobesize\"] = 32;\r\n    //avFormat[\"framerate\"] = 100; // from: https://github.com/wang-bin/QtAV/issues/369\r\n    //avFormat[\"rtbufsize\"] = 512 * 1024;\r\n    //avFormat[\"flush_packets\"] = 1;\r\n    //avFormat[\"avioflags\"] = \"direct\";\r\n    //avFormat[\"max_delay\"] = 1000;\r\n    //avFormat[\"fflags\"] = \"nobuffer\";\r\n    //avFormat[\"vprofile\"] = \"baseline\";\r\n  }\r\n\r\n  avFormat[\"probesize\"] = 4096; // great impact but how to calc the optimum?  // from: https://github.com/wang-bin/QtAV/wiki/FFmpeg-dict-opt-in-QtAV\r\n  avFormat[\"tune\"] = \"zerolatency,fastdecode\";\r\n  {\r\n    // is what zerolatency does:\r\n    //  avFormat[\"bframes\"] = 0;\r\n    //  avFormat[\"force-cfr\"] = 1;\r\n    //  avFormat[\"no-mbtree\"] = 1;\r\n    //  avFormat[\"sync-lookahead\"] = 0;\r\n    //  avFormat[\"sliced-threads\"] = 1;\r\n    //  avFormat[\"rc-lookahead\"] = 0;\r\n  }\r\n\r\n  settings[\"avformat\"] = avFormat;\r\n  player->setOptionsForFormat(avFormat);\r\n}\r\n```"}}