Q:

FFmpeg : Check if the aac bitstream is malformed or not

I want to upload few sets of videos on my server and later play them in the HTML5 video tag. But some of them are not playing.
I checked the audio stream and video stream of the video, they have AAC and H264 codec respectively.So nothing seems wrong to me.
Then I tried re-encoding it, i got the following message:
malformated aac bitstream, use -absf aac_adtstoasc
av_interleaved_write_frame(): Operation not permitted

However I don't want to encode the videos before upload and just need to check if video has a malformed aac or h264 bitsream.

PS. Users are limited and will be provided with videos h264 and aac
  encoded for the upload.

A:

malformated aac bitstream, use -absf aac_adtstoasc doesn't mean the input stream is invalid. It's rather the re-encoding that's invalid. The idea is that you're using an MPEG-2 transport stream as input and the AAC stream in it uses the ADTS format.
If you want to re-encode the file and change the container to FLV or MP4 for example you MUST use the bitstream filter aac_adtstoasc to remove the ADTS header:
-bsf:a aac_adtstoasc

To view the input streams you can use ffprobe. Eg:
ffprobe -v quiet -print_format json -show_streams [input]

Verifying file integrity is another matter.
If the input is MPEG-TS it will not play in HTML5 natively. Check the uploaded format and re-encode to a HTML5 supported format.

