obs-ffmpeg-output.h 1.7 KB

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