0
votes

I want to demux audio (AMR_WB) and video(H264) from an mp4 file. I need to write a program which does this using ffmpeg libraries.

In demuxing.c file which is there in FFMPEG examples i was able to get only the raw formats as the output.

Can i somehow modify that code to get H264 and AMR_WB in encoded format from the mp4 file?

1
But then why does the output say that play the output file using ffplay -f rawvideo -pix_fmt yuv420p -video_size 450x360 out.h264 ? plus when i did file command on the output file it said PEX Binary Archive. Didn't mention anything abt h264Akshay Rajan
The size of the file which i get as the output from Demuxing.c is 100 times the input file size. But when i run a command line task for demuxing using demuxing command the size of the demuxed video file ie. the h264 file whic i got is somewhat the same size of the input file. so mostly the output which im getting in demuxing.c is raw format.Akshay Rajan

1 Answers

0
votes

Run ffmpeg twice , each time specify that just 1 track be copy to output.

Example on diff mp4 will provide most of the idea which u will need to adapt to your specific track types for the respective video/audio in your container...

MP4 example : demux h264 and aac tracks to separate outputs (tout1, tout2 )

Whats in input?

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'phoneCam_20120902_112701.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2012-09-02 18:27:14
  Duration: 00:00:12.65, start: 0.000000, bitrate: 8011 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 7707 kb/s, SAR 65536:65536 DAR 16:9, 28.64 fps, 29.83 tbr, 90k tbn, 180k tbc
    Metadata:
      creation_time   : 2012-09-02 18:27:14
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, s16, 96 kb/s

Pass 1, just get the Vid

ffmpeg -i phoneCam_20120902_112701.mp4 -map 0:0 -c copy tout1.mp4

Pass2 just get the aud

ffmpeg -i phoneCam_20120902_112701.mp4 -map 0:1 -c aac -ar 48000 -ab 48000 -strict -2 tout2.3gp

In your program, just run ffmpeg from the CLI or call main() in ffmpeg.c