2

first time here. Please be gentle. let me know what I missed out on and I will correct it.

my question is similar to this. So, I am hoping to get an answer for my specific query too.

How can I convert .264 file to .mp4

I have an entire directory with frames in .h264 format. These are generated from WebRTC for a single video.

I am able to convert the very first frame to image. However, when I am trying it for the subsequent frames, I am getting an error with ffmpeg. I am assuming there might be some dependency on the prior frames because of which I am getting this error.

How can I convert all the frames in that directory to images (jpeg or png)

2 Answers2

2

Typical H.264 frames are interdependent, so most frames can't be decoded individually.

Use cat to combine them all and pipe to ffmpeg:

cat *.h264 | ffmpeg -i - frame-%04d.png
llogan
  • 11,518
  • 43
  • 54
  • Thank a ton. This worked for me. – Harsh Solanki Nov 23 '20 at 05:21
  • Any chance you know the reason on how the quality of the same can be increased? Currently, I am getting the entire directory converted to images but the quality of most of the images is not that great. Currently, I am trying to change frame rates to see if something improves. – Harsh Solanki Nov 23 '20 at 14:28
  • 1
    @HarshSolanki The input `frame-0001.h264` to `frame-0004.h264` have bad quality, so therefore the output PNG will also have bad quality for those 4 frames. Check the later frames and they should look better. Nothing you can do about it except to re-generate the h264 frames with a higher quality. Frame rate is meaningless when extracting individual images, so you do not need to change frame rate. – llogan Nov 23 '20 at 19:32
0

You could try to use handbrake.

$ HandBrakeCLI -Z Universal -i myinputfile -o myoutputfile

I found it here. Maybe it'll help.

And pleases also provide the error message, so we can help you more effectively.

Ottega
  • 1
  • The error is mentioned in the below link:https://docs.google.com/document/d/1__F9ZfP4qdr_yXf52zWTNZiZDfwZCevhJXUbrRtfAGc/edit?usp=sharing – Harsh Solanki Nov 19 '20 at 11:21