[FFmpeg-user] MPEG TS+PS parser
Mark Filipak (ffmpeg)
markfilipak at bog.us
Thu Oct 15 11:44:40 EEST 2020
The command below does a flat, 1st level parse of an MPEG TS+PS (plus a little more). As I expand
the parse further, I'm going to hit the limit of 'sed's capability (I think). For further parses
I'll need to conditionally include subpatterns based on, 1, lookaheads with branching, and 2,
bytesize values extracted by the parse (some of which will have to compute and remember index
offsets). Both are capabilities that may be beyond sed's capabilities (I think).
-If possible, I plan to descend all the way into macroblocks. I'm already doing all this stuff by
hand. Now I want to automate it.-
Got any suggestions how I should proceed?
BTW, give the command a try and let me know what you think.
Thanks,
Mark.
xxd -p -u VIDEOFILE \
| tr -d '\n' \
| sed -r 's/000001/\x0D\x0A&/g' \
| sed -r 's/^00000100/ picture_start_code\: &/g' \
| sed -r 's/^000001(0[1-9A-F]|[1-9A][0-9A-F])/ slice_start_code\: &/g' \
| sed -r 's/slice_start_code\: ......../&\x0D\x0A slice\: /g' \
| sed -r 's/^000001B0/ (reserved)\: &/g' \
| sed -r 's/^000001B1/ (reserved)\: &/g' \
| sed -r 's/^000001B2/ user_data_start_code\: &/g' \
| sed -r 's/^000001B3/ sequence_header_code\: &/g' \
| sed -r 's/^000001B4/ sequence_error_code\: &/g' \
| sed -r 's/^000001B50/ (reserved)\: &/g' \
| sed -r 's/^000001B51/ sequence_extension\: &/g' \
| sed -r 's/^000001B52/ sequence_display_extension\: &/g' \
| sed -r 's/^000001B53/ quant_matrix_extension\: &/g' \
| sed -r 's/^000001B54/ copyright_extension\: &/g' \
| sed -r 's/^000001B55/ sequence_scalable_extension\: &/g' \
| sed -r 's/^000001B56/ (reserved)\: &/g' \
| sed -r 's/^000001B57/ picture_display_extension\: &/g' \
| sed -r 's/^000001B58/ picture_coding_extension\: &/g' \
| sed -r 's/^000001B59/ picture_spatial_scalable_extension\: &/g' \
| sed -r 's/^000001B5A/picture_temporal_scalable_extension\: &/g' \
| sed -r 's/^000001B5B/ camera_parameters_extension\: &/g' \
| sed -r 's/^000001B5C/ ITU-T extension\: &/g' \
| sed -r 's/^000001B5D/ (reserved)\: &/g' \
| sed -r 's/^000001B5E/ (reserved)\: &/g' \
| sed -r 's/^000001B5F/ (reserved)\: &/g' \
| sed -r 's/^000001B6/ (reserved)\: &/g' \
| sed -r 's/^000001B7/ sequence_end_code\: &/g' \
| sed -r 's/^000001B8/ group_start_code\: &/g' \
| sed -r 's/^000001B9/ MPEG_program_end_code\: &/g' \
| sed -r 's/^000001BA/ pack_start_code\: &/g' \
| sed -r 's/^000001BB/ system_header_start_code\: &/g' \
| sed -r 's/^000001BC/ program_stream_map\: &/g' \
| sed -r 's/^000001BD/ private_stream_1\: &/g' \
| sed -r 's/^000001BE/ padding_stream\: &/g' \
| sed -r 's/^000001BF/ private_stream_2\: &/g' \
| sed -r 's/^000001[CD]/ pes_audio_header\: &/g' \
| sed -r 's/^000001E/ pes_video_header\: &/g' \
| sed -r 's/pes_video_header\: ......../&\x0D\x0A pes_packet_length\: /g' \
| sed -r 's/pes_packet_length\: ........../&\x0D\x0A /g' \
| sed -r 's/^000001F0/ ECM_stream\: &/g' \
| sed -r 's/^000001F1/ EMM_stream\: &/g' \
| sed -r 's/^000001F2/ DSMCC_stream\: &/g' \
| sed -r 's/^000001F3/ ISO\/IEC_13522_stream\: &/g' \
| sed -r 's/^000001F4/ H.222.1 type A stream\: &/g' \
| sed -r 's/^000001F5/ H.222.1 type B stream\: &/g' \
| sed -r 's/^000001F6/ H.222.1 type C stream\: &/g' \
| sed -r 's/^000001F7/ H.222.1 type D stream\: &/g' \
| sed -r 's/^000001F8/ H.222.1 type E stream\: &/g' \
| sed -r 's/^000001F9/ ancillary_stream\: &/g' \
| sed -r 's/^000001FA/ 14496-1_SL-packetized_stream\: &/g' \
| sed -r 's/^000001FB/ 14496-1_FlexMux_stream\: &/g' \
| sed -r 's/^000001FC/ metadata stream\: &/g' \
| sed -r 's/^000001FD/ extended_stream_id\: &/g' \
| sed -r 's/^000001FE/ reserved data stream\: &/g' \
| sed -r 's/^000001FF/ program_stream_directory\: &/g' \
> VIDEOFILE.parsed.txt
--
What if you woke up and found yourself in a police state?
African-Americans wake up in a police state every day.
More information about the ffmpeg-user
mailing list