MP4 Video Encoding

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MP4 Video Encoding

1,152 Views
remusmp
Contributor I

Dear NXP Community,

1. I'm using the following command to encode /dev/video0 straight into mp4 (Yocto/gstreamer/video – Gateworks):

gst-launch-1.0  imxv4l2videosrc device=/dev/video0 ! imxvpuenc_mpeg4 bitrate=10000 ! filesink location=/tmp/file.mp4

The problem is that some players (e.g. VLC under Linux/Windows) cannot play the file (they give an error saying they don't understand the file format). If I run ffmpeg:

ffmpeg -i video.mp4 -vcodec copy output.mp4

then all players are able to read the file and it works. I'd like not to depend on ffmpeg - could gst-launch and its plugins create a valid mp4 file? How would you modify the above command to achieve that?

2. I'd like to be able to encode straight into mp4 from C and I'm following the example from libimxvpuapi - encode-example-writecb.c. I have the same problem there - the encoded file cannot be read by players but after running ffmpeg things work. I'd like my app not to depend on ffmpeg.

What's missing from encode-example-writecb.c in order to produce an mp4 file that can be read by all players?

Many thanks in advance!

Regards,

Remus.

Labels (4)
0 Kudos
2 Replies

815 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Remus,

Maybe the VLC driver has a modification is bitrate, so try removing this part for the launch file,  I dont know if there are other possible option.

0 Kudos

815 Views
remusmp
Contributor I

Please correct me if I am wrong: the mp4 file that I create either with gst-launch command above or the C example code from libimxvpuapi is only the encoded stream without a container. The video stream needs a container in order to be played (by VLC or other players). I can see the file is missing a container:

pastedImage_1.png

This ffmpeg command creates an MPEG-4 container for the video stream:

ffmpeg -i video.mp4 -vcodec copy output.mp4

pastedImage_2.png

The gst-launch command that I had above needs to be extended with an mp4mux in order to create the container. The output file then works.

Would have been nice to have a function in libimxvpuapi to create a container for the encoded stream.

Please let me know if I'm wrong about this container thing.

Regards,

R.

0 Kudos