pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.5k stars 644 forks source link

how support ffmpeg args rtmp_playpath #3684

Closed hackerxiaobai closed 11 months ago

hackerxiaobai commented 11 months ago

🚀 The feature

ffmpeg args rtmp_playpath , StreamWriter support ?

Motivation, pitch

ffmpeg args rtmp_playpath , StreamWriter support ?

Alternatives

No response

Additional context

No response

mthrok commented 11 months ago

I don't think this is currently supported. For StreamReader, there is option argument for the constructor. However, StreamWriter does not have the equivalent one, this is because I don't know how to pass such option dict to the underlying implementation.

For StreamReader, the option is set when creating AVFormatContext with avformat_open_input function.

https://github.com/pytorch/audio/blob/c5b69336e951beac842aae09bca5cc62c114e018/src/libtorio/ffmpeg/stream_reader/stream_reader.cpp#L39

But for StreamWriter, AVFormatContext is created with avformat_alloc_output_context2, which does not have the equivalent option argument.

https://github.com/pytorch/audio/blob/c5b69336e951beac842aae09bca5cc62c114e018/src/libtorio/ffmpeg/stream_writer/stream_writer.cpp#L22-L30

Need to understand how ffmpeg CLI handles this.

mthrok commented 11 months ago

Hmm, looking at the implementation of avformat_open_input, perhaps one can just do av_opt_set_dict??

mthrok commented 11 months ago

Actually, this is already supported. Pass the "rtmp_playpath": "" to open method.