2

I'm trying to demux an RTSP stream and remux it into a TS file, using libavformat, libavcodec,etc., copying the video and transcoding the audio. If I use ffmpeg, the command is roughly like this:

ffmpeg -rtsp_transport tcp -re -fflags +genpts -i rtsp://10.0.0.42/channel1 -vcodec copy -copyts -bsf dump_extra -acodec libfdk_aac -b:a 16k -ac 1 -map 0:0 -map 0:1 -f mpegts out.ts

I've looked at the muxing/demuxing examples, but aside from having difficulty understanding how to make a stream copy, I can't find any mention of bitstream filters. I'm currently getting the following error:

[mpegts @ 0x7ff20c009600] H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)

How do I create a bitstream filter and how do I assign it? Do I assign it to the input stream, or the output stream?

evilpenguin
  • 5,448
  • 6
  • 41
  • 49
  • Please try your command with -vbsf h264_mp4toannexb – Dayal rai May 29 '13 at 07:24
  • I'm sorry, I edited my post to be more clear. I'm not using ffmpeg anymore, I'm writing my own code and using the libraries directly. – evilpenguin May 29 '13 at 07:43
  • Check out the response here: [What are bitstream filters in ffmpeg?](https://stackoverflow.com/questions/32028437/what-are-bitstream-filters-in-ffmpeg/32035072#32035072) – Joe Oct 24 '17 at 16:20

2 Answers2

4

The bitstream filters are sadly underdocumented, but shouldn't be all that hard to figure out. The simplest way is probably just emulating what avconv does -- setup, then apply the filter to each packet right before muxing it.

Anton Khirnov
  • 793
  • 5
  • 5
  • Check the response here: https://stackoverflow.com/questions/32028437/what-are-bitstream-filters-in-ffmpeg/32035072#32035072 – Joe Oct 24 '17 at 16:19
0

You could find the MPEG-2 TS short description here http://wiki.multimedia.cx/index.php?title=MPEG-2_Transport_Stream The example TS files (for h.264): http://samples.mplayerhq.hu/V-codecs/h264/

But your question is not clear. What you want to do exactly? Do you want create your own muxer for TS?

BR, Alexander

  • No, I am simply trying to take a H264 stream from a rtsp input and mux it to a TS file on disk and I got that feedback from the muxer. I'm using libaformat with the muxer it automagically selects for mpegts: avformat_alloc_output_context2(&output_ctx, NULL, "mpegts", dst_filename); – evilpenguin May 29 '13 at 12:28