Question

I'm using the following libavformat functions to read an audio file (various formats) and then write it to a new file on disk:

  • avformat_open_input (start reading new stream)
  • avio_open (begin new file to write)
  • avformat_write_header (write same header as I started reading)
  • av_read_frame (get frame)
  • av_write_frame (write on frame to disk)

I'm wondering if it's possible to add encryption to this, either just for the header part or for the while file. That is, I want to encrypt the data before it's actually written to the new file and then decrypt before I read it the next time.

Is there any FFMPEG support to encrypt on read and decrypt on write using AES encryption?

If not, is there someway I can intercept and alter the data which is being read or written when using the functions above?

I know that in libavutil there is an AES encrypt/decrypt functions (in aes.h) but I cant find any good information on how to fit it into the other libavformat functions that I'm using.

Thanks

Was it helpful?

Solution

After a lot of research I couldn't find a built-in way to do this in FFMPEG.

My solution instead was to encrypt and decrypt the file before i used it with FFMPEG.

I did however find a function in libavutil/aes.h which helped my do the actual encryption:

void av_aes_crypt (AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top