Questions tagged [libavformat]

Libavformat (lavf) is a library for dealing with various media container formats.

Detailed Description

Libavformat (lavf) is a library for dealing with various media container formats.

Its main two purposes are demuxing - i.e. splitting a media file into component streams, and the reverse process of muxing - writing supplied data in a specified container format. It also has an I/O module which supports a number of protocols for accessing the data (e.g. file, tcp, http and others). Before using lavf, you need to call av_register_all() to register all compiled muxers, demuxers and protocols. Unless you are absolutely sure you won't use libavformat's network capabilities, you should also call avformat_network_init().

A supported input format is described by an AVInputFormat struct, conversely an output format is described by AVOutputFormat. You can iterate over all registered input/output formats using the av_iformat_next() / av_oformat_next() functions. The protocols layer is not part of the public API, so you can only get the names of supported protocols with the avio_enum_protocols() function.

Main lavf structure used for both muxing and demuxing is AVFormatContext, which exports all information about the file being read or written. As with most Libav structures, its size is not part of public ABI, so it cannot be allocated on stack or directly with av_malloc(). To create an AVFormatContext, use avformat_alloc_context() (some functions, like avformat_open_input() might do that for you).

Most importantly an AVFormatContext contains:

  • the input or output format. It is either autodetected or set by user for input; always set by user for output.
  • an array of AVStreams, which describe all elementary streams stored in the file. AVStreams are typically referred to using their index in this array.
  • an I/O context. It is either opened by lavf or set by user for input, always set by user for output (unless you are dealing with an AVFMT_NOFILE format).

Source and further information, Documentation, API and Links to Tutorials: http://libav.org/ http://libav.org/doxygen/master/group__libavf.html

280 questions
36
votes
2 answers

Raw H264 frames in mpegts container using libavcodec

I would really appreciate some help with the following issue: I have a gadget with a camera, producing H264 compressed video frames, these frames are being sent to my application. These frames are not in a container, just raw data. I want to use…
Ferenc Deak
  • 34,348
  • 17
  • 99
  • 167
34
votes
3 answers

Reading a file located in memory with libavformat

I'm currently trying to read small video files sent from a server In order to read a file using libavformat, you are supposed to call av_open_input_file(&avFormatContext, "C:\\path\\to\\video.avi", 0, 0, 0); The problem is that in this case the…
Tomaka17
  • 4,832
  • 5
  • 29
  • 38
22
votes
1 answer

FFMPEG: multiplexing streams with different duration

I am multiplexing video and audio streams. Video stream comes from generated image data. The audio stream comes from aac file. Some audio files are longer than total video time I set so my strategy to stop audio stream muxer when its time becomes…
Michael IV
  • 11,016
  • 12
  • 92
  • 223
17
votes
4 answers

Record RTSP stream with FFmpeg libavformat

I'm trying to record RTSP stream from Axis camera with FFmpeg libavformat. I can grab video from files and then save it to another file, this is OK. But camera sends strange data, FPS is 100 and camera sends every 4th frame so result FPS is about…
chatoooo
  • 326
  • 1
  • 3
  • 13
17
votes
3 answers

Difference between Frames and Packets in FFmpeg

I am trying to decode an MPEG video file using LibAV. There are two terms which I am not able to grok properly, Frames and Packets. As per my present understanding, Frames are uncompressed video frames and packets are the compressed…
pseudo_teetotaler
  • 1,485
  • 1
  • 15
  • 35
16
votes
1 answer

H.264 muxed to MP4 using libavformat not playing back

I am trying to mux H.264 data into a MP4 file. There appear to be no errors in saving this H.264 Annex B data out to an MP4 file, but the file fails to playback. I've done a binary comparison on the files and the issue seems to be somewhere in what…
Brad Mitchell
  • 254
  • 1
  • 3
  • 12
15
votes
5 answers

C++ FFmpeg create mp4 file

I'm trying to create mp4 video file with FFmpeg and C++, but in result I receive broken file (windows player shows "Can't play ... 0xc00d36c4"). If I create .h264 file, it can be played with 'ffplay' and successfully converted to mp4 via CL. My…
DDovzhenko
  • 1,295
  • 1
  • 15
  • 34
13
votes
2 answers

Unable to store pcm audio in .mp4 container file

Is it possible to store a pcm audio file into .mp4 file? I used ffmpeg command "ffmpeg -i tempA.wav -acodec copy temp.mp4" but unable to store it in mp4 container file. Input #0, wav, from 'tempA.wav': Duration: 00:01:36.51, bitrate: 128…
mrsatish
  • 429
  • 2
  • 7
  • 15
12
votes
4 answers

How can I turn libavformat error messages off

By default, libavformat writes error messages to stderr, Like: Estimating duration from bitrate, this may be inaccurate How can I turn it off? or better yet, pipe it to my own neat logging function? Edit: Redirecting stderr to somewhere else is not…
amrhassan
  • 2,285
  • 3
  • 16
  • 12
12
votes
4 answers

Fragmented MP4 - problem playing in browser

I try to create fragmented MP4 from raw H264 video data so I could play it in internet browser's player. My goal is to create live streaming system, where media server would send fragmented MP4 pieces to browser. The server would buffer input data…
PookyFan
  • 785
  • 1
  • 8
  • 23
12
votes
1 answer

Decode MP3, then increase the audio volume, and then encode the new audio

I want to first decode a MP3 audio file, and then increase the volume of the audio, and then encode it again into a new MP3 file. I want to use libavformat or libavcodec for this. Can you help me how I can do this? Any example?
Blue Sky
  • 293
  • 1
  • 5
  • 14
11
votes
2 answers

Recording video with unknown framerate with FFmpeg

I am recording video with FFmpeg and I would like the frame rate it is written with to at least be in the right ballpark. Right now I take the frame rate that my input claims to have and use that to set the frame rate (time_base) for my output video…
Chris
  • 574
  • 7
  • 24
11
votes
5 answers

How to obtain titles and chapters information in DVD?

I found many question about creating DVD menu using ffmpeg but i did not find any one about programmically access to DVD structure information. When i using libav (or FFmpeg) library i can open DVD image (iso file) and access to video, audio and…
Tarhan
  • 536
  • 1
  • 7
  • 15
10
votes
0 answers

FFmpeg: av_interleaved_write_frame doesn't detect failure for TLS output

How can I detect failure from av_interleaved_write_frame/av_write_frame when the output uses TLS and the connection fails? Both functions continue to return 0 after the destination becomes unavailable. When TLS isn't used, the functions detect the…
DanielB6
  • 1,181
  • 1
  • 10
  • 22
10
votes
1 answer

streaming H.264 over RTP with libavformat

I've been trying over the past week to implement H.264 streaming over RTP, using x264 as an encoder and libavformat to pack and send the stream. Problem is, as far as I can tell it's not working correctly. Right now I'm just encoding random data…
Jacob Peddicord
  • 367
  • 2
  • 6
  • 15
1
2 3
18 19