leandromoreira / ffmpeg-libav-tutorial

FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more. Translations: πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡³ πŸ‡°πŸ‡· πŸ‡ͺπŸ‡Έ πŸ‡»πŸ‡³ πŸ‡§πŸ‡·
https://github.com/leandromoreira/ffmpeg-libav-tutorial
BSD 3-Clause "New" or "Revised" License
9.82k stars 941 forks source link

how to pass the input parameter mpegts_service_id #58

Open vandanachadha opened 4 years ago

vandanachadha commented 4 years ago

I need to read the input from a tuner card specific program id. In ffmpeg, the input option passed is: -mpegts_service_id

How would I set this in the 3_transcoding.c sample?

leandromoreira commented 4 years ago

i believe it's here https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/master/3_transcoding.c#L357

vandanachadha commented 4 years ago

Thanks, that helped, But now, I am getting these errors: [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [mpegts @ 0x2078cc0] PES packet size mismatch [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [mpegts @ 0x2078cc0] PES packet size mismatch [mpegts @ 0x2078cc0] PES packet size mismatch [mpeg2video @ 0x2177280] ac-tex damaged at 25 7 [mpeg2video @ 0x2177280] Warning MVs not available [mpeg2video @ 0x2177280] concealing 1035 DC, 1035 AC, 1035 MV errors in P frame [ac3 @ 0x20ad780] incomplete frame [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [aac @ 0x2263c40] more samples than frame size (avcodec_encode_audio2) [mpeg @ 0x209eec0] Invalid packet stream index: 3 LOG: Error -22 while receiving packet from decoder: Invalid argument

My Streaming Parameters are: /*

The ffmpeg equivalent which I am tryong to emulate thru 3_transcoding is: ffmpeg -re -i /dev/dvb/adapter0/dvr0 -mpegts_service_id 22 -vcodec mpeg2video -s 720x480 -b:v 2M -minrate:v 2M -maxrate:v 2M -bufsize:v 1.4M -t 30 -f mpegts test2.mpg

leandromoreira commented 4 years ago

It seems that you're passing a packet for a wrong index [mpeg @ 0x209eec0] Invalid packet stream index: 3 I suposse there are only two streams

vandanachadha commented 4 years ago

oh, thats because it is reading all the streams from the dvb, rather than the selected program's.

I have passed these demuxer options: demuxer_opt_key = "mpegts_service_id"; demuxer_opt_value = "22"; to the avformat_open_input(&pFormatContext, filename, NULL, &demuxer_opts), but still get r number of programs as 2.

Is the below errors also related to the right program not being read? [aac @ 0x187fa40] more samples than frame size (avcodec_encode_audio2)

Some more logs fyi: Video Codec: resolution 720 x 480Audio Codec: 2 channels, sample rate 48000Audio Codec: 2 channels, sample rate 48000Video Codec: resolution 720 x 480Frame ? (40) pts -1403570077 dts -1403570077 key_frame 0 [coded_picture_number 40, display_picture_number 0]Makefile:48: recipe for target 'run_transcodingr' failed make: *** [run_transcodingr] Error 255

leandromoreira commented 4 years ago

Negative PTS and DTS you maybe have to calculate them =/ (do you want to copy the audio as it is? if so mark sp.copy_audio)

vandanachadha commented 4 years ago

nope, cannot copy. have to transcode from mpeg2 to h264 and from ac3 to aac. But if just transcoding, do I still need to have the filters etc set, as is the case in the init_filter etc in https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcoding.c#L448

Will check the negative pts, will be back with more questions I am sure :-) Thank you for your prompt responses.

vandanachadha commented 4 years ago

The negative pts error went away once the changes to write the output to a udp stream were done. However I now get the PES packet size mismatch. What do I check for this?

Current logs:
Frame ? (145) pts 1249349192 best_effort_timestamp 1249349192, dts 1249349192 key_frame 0 [coded_picture_number 145, display_picture_number 0]Frame ? (146) pts 1249352195 best_effort_timestamp 1249352195, dts 1249352195 key_frame 0 [coded_picture_number 146, display_picture_number 0] Frame ? (147) pts 1249355198 best_effort_timestamp 1249355198, dts 1249355198 key_frame 0 [coded_picture_number 144, display_picture_number 0]Frame ? (148) pts 1249358201 best_effort_timestamp 1249358201, dts 124 [mpegts @ 0x1d23ac0] PES packet size mismatch [aac @ 0x2537140] more samples than frame size (avcodec_encode_audio2) 124[mpegts @ 0x1d23ac0] PES packet size mismatch [aac @ 0x2537140] more samples than frame size (avcodec_encode_audio2) [mpegts @ 0x1d23ac0] PES packet size mismatch [ac3 @ 0x1d5ed00] incomplete frame [aac @ 0x2537140] more samples than frame size (avcodec_encode_audio2) [mpeg2video @ 0x1d5ce00] ac-tex damaged at 21 20 [mpeg2video @ 0x1d5ce00] Warning MVs not available [mpeg2video @ 0x1d5ce00] concealing 450 DC, 450 AC, 450 MV errors in P frame Makefile:48: recipe for target 'run_transcodingr' failed make: *** [run_transcodingr] Error 139

vandanachadha commented 4 years ago

@leandromoreira A few issues:

  1. If i set copy_audio=0 and set the audi_codec as "aac", the output steam does not contain any audio.
  2. Also sometimes, this error comes up and the output stream stops: ADTS frame size too large: 58962 (max 8191) Pls suggest what should be done.
leandromoreira commented 4 years ago

@vandanachadha sometimes you really need to tests things out to make them work I documented my walk to create the chapter 3 and even look at ffmpeg command line source code.