obs-ffmpeg-output.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_audio_info {
  31. AVStream *stream;
  32. AVCodecContext *ctx;
  33. };
  34. struct ffmpeg_data {
  35. AVStream *video;
  36. AVCodecContext *video_ctx;
  37. struct ffmpeg_audio_info *audio_infos;
  38. AVCodec *acodec;
  39. AVCodec *vcodec;
  40. AVFormatContext *output;
  41. struct SwsContext *swscale;
  42. int64_t total_frames;
  43. AVFrame *vframe;
  44. int frame_size;
  45. uint64_t start_timestamp;
  46. int64_t total_samples[MAX_AUDIO_MIXES];
  47. uint32_t audio_samplerate;
  48. enum audio_format audio_format;
  49. size_t audio_planes;
  50. size_t audio_size;
  51. int num_audio_streams;
  52. /* audio_tracks is a bitmask storing the indices of the mixes */
  53. int audio_tracks;
  54. struct circlebuf excess_frames[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  55. uint8_t *samples[MAX_AUDIO_MIXES][MAX_AV_PLANES];
  56. AVFrame *aframe[MAX_AUDIO_MIXES];
  57. struct ffmpeg_cfg config;
  58. bool initialized;
  59. char *last_error;
  60. };
  61. bool ffmpeg_data_init(struct ffmpeg_data *data, struct ffmpeg_cfg *config);
  62. void ffmpeg_data_free(struct ffmpeg_data *data);