obs-ffmpeg-output.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <libavutil/opt.h>
  3. #include <libavutil/pixdesc.h>
  4. #include <libavformat/avformat.h>
  5. #include <libswscale/swscale.h>
  6. struct ffmpeg_cfg {
  7. const char *url;
  8. const char *format_name;
  9. const char *format_mime_type;
  10. const char *muxer_settings;
  11. int gop_size;
  12. int video_bitrate;
  13. int audio_bitrate;
  14. const char *video_encoder;
  15. int video_encoder_id;
  16. const char *audio_encoder;
  17. int audio_encoder_id;
  18. const char *video_settings;
  19. const char *audio_settings;
  20. int audio_mix_count;
  21. int audio_tracks;
  22. enum AVPixelFormat format;
  23. enum AVColorRange color_range;
  24. enum AVColorPrimaries color_primaries;
  25. enum AVColorTransferCharacteristic color_trc;
  26. enum AVColorSpace colorspace;
  27. int scale_width;
  28. int scale_height;
  29. int width;
  30. int height;
  31. };
  32. struct ffmpeg_audio_info {
  33. AVStream *stream;
  34. AVCodecContext *ctx;
  35. };
  36. struct ffmpeg_data {
  37. AVStream *video;
  38. AVCodecContext *video_ctx;
  39. struct ffmpeg_audio_info *audio_infos;
  40. AVCodec *acodec;
  41. AVCodec *vcodec;
  42. AVFormatContext *output;
  43. struct SwsContext *swscale;
  44. int64_t total_frames;
  45. AVFrame *vframe;
  46. int frame_size;
  47. uint64_t start_timestamp;
  48. int64_t total_samples[MAX_AUDIO_MIXES];
  49. uint32_t audio_samplerate;
  50. enum audio_format audio_format;
  51. size_t audio_planes;
  52. size_t audio_size;
  53. int num_audio_streams;
  54. /* audio_tracks is a bitmask storing the indices of the mixes */
  55. int audio_tracks;
  56. struct circlebuf excess_frames[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  57. uint8_t *samples[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  58. AVFrame *aframe[MAX_AUDIO_MIXES];
  59. struct ffmpeg_cfg config;
  60. bool initialized;
  61. char *last_error;
  62. };
  63. bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config);
  64. void ffmpeg_data_free(struct ffmpeg_data *data);