I want to convert an elementary stream(.264) to container format(.mp4). Can someone please help me on this? How can I use ffmpeg to do this task? What are all the other methods that could accomplish the same task?

  • You can also do it via Handbrake gui in software center or via ppa. – Arup Roy Chowdhury Oct 26 '15 at 6:00

This is easy with ffmpeg:

ffmpeg -framerate 24 -i input.264 -c copy output.mp4
  • This simply stream copies (re-muxes) the video so there is no unnecessary re-encoding occurring; therefore the quality is preserved and the whole process is quick.

  • Frame rate is by default assumed to be 25. You can change this with the -framerate input option. Typical values are 30000/1001, 25 (default), 24000/1001, 24, or frame rate aliases such as ntsc, ntsc-film, or pal.

  • 1
    One should note that raw H.264 streams don't carry a rate information, so FFmpeg will display a warning and default to 25 frames/second. If you want a different frame rate you can use the -r switch, e. g. -r 30 for 30 frames/second. – David Foerster Apr 21 '17 at 12:58
  • 1
    @DavidFoerster Yes, good point, but the H.264 demuxer uses -framerate instead of -r. – LordNeckbeard Apr 21 '17 at 18:04
  • You're correct. I should have read the entire paragraph in the FFmpeg documentation: “If in doubt use -framerate instead of the input option -r.” For some reason -framerate isn't documented in this manual here though. – David Foerster Apr 21 '17 at 22:45
  • @DavidFoerster Which man page? – LordNeckbeard Apr 21 '17 at 23:18
  • 1
    That of ffmpeg(1) (Ctrl+F for -framrate). There's documentation for it in the avfoundation input device section but it doesn't look like it applies to other cases. – David Foerster Apr 22 '17 at 0:27

Try these commands :

sudo apt-get install x264
x264 raw_stream.264 -o playable_video.mp4

Run the MP4 files in VLC

  • 1
    This re-encodes for no reason. Better to just re-mux. – LordNeckbeard Oct 26 '15 at 17:22

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.