there was a task to record twitch broadcasts for further editing.

I wrote a Python script using livestreamer and the ffmpeg codec for writing.

There was a problem at the installation stage. It turned out that all the records come with a variable frame rate.

In Sony Vegas and Adobe Premiere, audio and video are out of sync. Although the latest version of Adobe Premiere added support for working with variable frame rates, but I could not cope with it (it was also dissynchronized).

Found ways to edit this video:

  1. Before editing, saving video to a constant frame rate (in fact, to produce extra additional rendering of the recording) is not an option
  2. To open a video in Sony Vegas, to pull out the audio track, and substituting it for editing video is not an option.

To get rid of this, you just need to immediately record with a constant frame rate. But how to implement it automatically.

Decided to use a bandicam with a constant frame rate.

Using the Twitch API in an infinite loop, we check the presence of a broadcast on the channel.

In the case of a broadcast, open the browser using Selenium in full screen mode, start Bandicam using the command line (subprocess) and start recording.

If the stream ends, stop the recording and close the browser.

Do you think I'm confused, or are there better ways to organize recording at a constant frequency?

And how to enable full screen mode (as well as in the browser - F11, or each browser has a special setting such)?

Update

cls && @echo off & setlocal enableextensions enabledelayedexpansion set "_tag_00=%*" set "_tag_01=--ignore-errors --abort-on-error --ignore-config --flat-playlist --geo-bypass " set "_tag_02=--restrict-filenames --no-part --no-cache-dir --write-thumbnail --prefer-ffmpeg " set "_tag_03=--ffmpeg-location .\ --postprocessor-args -i "%%(title)s.%%(ext)s" -vf fps^=fps^=60^," set "_tag_04=scale^=1920x1080 -c:v libx264 -b:v 500k -preset superfast -c:a copy -f segment -segment_time " set "_tag_05=60 %%^(title^)s.mp4" youtube-dl "https://www.twitch.tv/gamesprouttv" -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "%%^(title^)s.%%^(ext^)s" !_tag_1!!_tag_2!!_tag_3!!_tag_4!!_tag_5! 
  • Take youtube-dl and not suffer? (No, despite the name, it supports Twitch) - andmalmal
  • @andreymal he can record video in online mode (as long as the broadcast goes)? - danilshik
  • I did not try it, but literally a couple of hours ago I recorded a broadcast from VKontakte with VKontakte - surely Twitch can. And it is also written in Python, perhaps this will also simplify a lot (although it requires the presence of the ffmpeg command for its work) - andreymal
  • @ andreaymal and what frame rate? constant? I just read somewhere that the broadcasts come with a variable frame rate - danilshik
  • For youtube-dl there is no concept of frame rate, it simply downloads the existing stream as it is without any decoding and transformations (except folding into your preferred media container) - andreymal

0