Opened 2 years ago

Last modified 2 years ago

#10074 new defect

No metadata in adts container using libavformat API

Reported by: Igor Serganov Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords:
Cc: Igor Serganov Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

First of all I have to mention that I am not really sure if this is a bug, but probably more a help request.

Background of the issue:

I am doing live mp3 to aac transcoding with adts muxing. I am using C functions from libraries inside FFMPEG (libavcodec, libavformat, etc.) through CGO (a tool that allows call C code within Golang).

Scenario is as follows:

  1. Open mp3 input
  2. Open output format:
        adts := C.CString("adts")
	defer C.free(unsafe.Pointer(adts))
	var ctx *C.AVFormatContext
	if ret := C.avformat_alloc_output_context2(&ctx, nil,  adts, nil); ret < 0 {
		return
	}
  1. Write header with several options that I need for appropriate metadata (according to: https://datatracker.ietf.org/doc/html/rfc8216#section-3.4), options taken from here - https://ffmpeg.org/ffmpeg-formats.html#adts-1:
C.av_dict_set(&f.opts.dict, "write_id3v2","1", 0)
C.av_dict_set(&f.opts.dict, "write_apetag","1", 0)
C.av_dict_set(&outAVFormatCtx.metadata, "TIPL", "Awesome production", 0)
C.avformat_write_header(&outAVFormatCtx, &f.opts.dict)
  1. demuxing and decoding input stream and encoding frames and muxing to output stream. I will not provide too much details here as this part works pretty fine.
  1. Accumulating output stream of certain duration (10 seconds e.g.) and writing .aac segment to a storage. (Ideally this part works forever in order to produce HLS stream out of these segments later)
  1. When receiving a first frame for the following segment I try to write its PTS (start time of the next segment) to the metadata tag:
C.av_dict_set(&outAVFormatCtx.metadata, "PRIV.com.apple.streaming.transportStreamTimestamp", <some random int64 value encoded to bytes>, 0)
outAVFormatCtx.event_flags |= C.avfmt_event_flag_metadata_updated

However I don't see any metadata when ffprobing my segments:

"format": {

"filename": "filename.aac",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "aac",
"format_long_name": "raw ADTS AAC (Advanced Audio Coding)",
"duration": "10.011431",
"size": "26458",
"bit_rate": "38253",
"probe_score": 51

}

However when I do something very similar with ffmpeg command as follows:

ffmpeg -i input.mp3 -vn -acodec copy -f adts -metadata title="Foo" -metadata PRIV.com.apple.streaming.transportStreamTimestam="1111111" -write_id3v2 1 -write_apetag 1 output.aac

I get what I want:

"filename": "output.aac",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "aac",
"format_long_name": "raw ADTS AAC (Advanced Audio Coding)",
"duration": "5.485686",
"size": "33278",
"bit_rate": "48530",
"probe_score": 51,
"tags": {

"TIT2": "Foo",
"PRIV.com.apple.streaming.transportStreamTimestam": "1111111",
"TSSE": "Lavf59.27.100"

}

So my question is how to write ID3v2 metadata to adts container through libavformat? Since this is quite a requirement of RFC-8216 (https://datatracker.ietf.org/doc/html/rfc8216#section-3.4).


Change History (1)

comment:1 by Carl Eugen Hoyos, 2 years ago

Version: 5.1.2unspecified

This is a bug tracker. Please ask all usage questions on the libav-user mailing list:
https://lists.ffmpeg.org/mailman/listinfo/libav-user/

Note: See TracTickets for help on using tickets.