obs-ffmpeg-output.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 AVColorSpace color_space;
  25. int scale_width;
  26. int scale_height;
  27. int width;
  28. int height;
  29. };
  30. struct ffmpeg_data {
  31. AVStream *video;
  32. AVStream **audio_streams;
  33. AVCodec *acodec;
  34. AVCodec *vcodec;
  35. AVFormatContext *output;
  36. struct SwsContext *swscale;
  37. int64_t total_frames;
  38. AVFrame *vframe;
  39. int frame_size;
  40. uint64_t start_timestamp;
  41. int64_t total_samples[MAX_AUDIO_MIXES];
  42. uint32_t audio_samplerate;
  43. enum audio_format audio_format;
  44. size_t audio_planes;
  45. size_t audio_size;
  46. int num_audio_streams;
  47. /* audio_tracks is a bitmask storing the indices of the mixes */
  48. int audio_tracks;
  49. struct circlebuf excess_frames[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  50. uint8_t *samples[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  51. AVFrame *aframe[MAX_AUDIO_MIXES];
  52. struct ffmpeg_cfg config;
  53. bool initialized;
  54. char *last_error;
  55. };
  56. bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config);
  57. void ffmpeg_data_free(struct ffmpeg_data *data);