当前位置:网站首页>FFmpeg multimedia file processing (ffmpeg prints audio and video Meta information)

FFmpeg multimedia file processing (ffmpeg prints audio and video Meta information)

2022-08-09 13:51:00 One Leaf Knows Autumn @qqy

Print audio/video information

  • avdevice_register_all()
  • avformat_open_input()/avformat_close_input
  • av_dump_format()

Practice

int main(int argc, const char * argv[]) {int ret = 0;AVFormatContext *fmt_ctx = NULL; //Create AVFormatContext format context pointerav_log_set_level(AV_LOG_INFO); //Set the log print levelavdevice_register_all(); //Register all devicesret = avformat_open_input(&fmt_ctx, "./test.mp4", NULL, NULL); //The third parameter is the format of the input file, NULL willChoose according to the file suffix name. If the file suffix name is not mp4, but the data format is mp4, the third parameter should be specified as mp4, and the fourth parameter is to pass some parameters from the command line. Generally, it is set to NULL.Yesif(ret < 0){av_log(NULL, AV_LOG_ERROR, "Can't open file:%s\n", av_err2str(ret));}av_dump_format(fmt_ctx, 0, "./Fairytale Town.flac", 0); //The second parameter is the index value of the stream, just fill in 0 directly, it should represent the first video stream, the fourth parameter refers to the input stream or the output stream, here is the direction toffmpeg input file so use 0, if it is ffmpeg output file, it will be 1avformat_close_input(&fmt_ctx);return 0;}
原网站

版权声明
本文为[One Leaf Knows Autumn @qqy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091244282572.html