Choose yuy2 or MJPEG in V4L - mjpeg

I am implementing a Camera Preview application. I am using V4L and until now I basically use this code> https://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
In this example, or any other example I found for that matter, I could not find a possibility to change the frame format to MJPEG to get a higher fps rate. Is there a way to tell V4L to use MJPEG instead of YUY2?

Found it, it is actually pretty simple. Just change the pixelformat in the format struct to V4L2_PIX_FMT_MJPEG.
So
format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
becomes
format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;

Related

FFmpeg poor quality encoded MPEG-4 video

Have adapted FFmpeg sample muxing.c under Windows 7 to write MP4 files from video camera RGB data.
Using muxing.c default bit_rate=400000.
Am not setting global_quality.
Resultant MP4 is poor quality, highly pixelated.
Original raw images in video camera are sharp.
What values should I use for bit_rate? Do I have to also set rc_max_rate?
What values should I use for global_quality? Do I have to set any flags to enable use of global_quality?
Is bit_rate versus global_quality an either/or situation? Or can both be useful in adjusting quality?
Thanks for your time.

Can you set initial buffer for Clappr Player?

We are using Clappr Player to live stream HLS.
We are trying to make the video start playing quicker.
Anyone know if there is a way to set the initial buffer size of Clappr Player?
I want to set it lower to seep up the video starting...
Thanks.
Clappr uses hls.js. You should be able to pass a hlsjsConfig object in the player's configuration. You can find the fine-tuning options here.
That being said you probably need to tweak the HLS encoding too.

Is the values in avcC box in .mp4 video files affected only by FFmpeg version?

I am studying on the source identification of video files especially about those from smartphones.
I got to know that the values in avcC box in .mp4 video files have the encoding options(h.264) which decoder must know when processing the encoded stream.
And I guess most of the smartphone uses the customized FFmpeg to encode the raw stream. I want to know if the values in the avcC box are affected only by the version of FFmpeg(if not customized version is used).
I didn't delve into this but think that the libavcodec.so in FFmpeg fill the values in avcC box when doing encoding(is this right?).
So what I want to ask is if two different smartphones use the same libavcodec.so(even in the case whether other .so files, .apk file used for the recording, etc are different) and two video files which have the same resolution were filmed from each smartphone, do the values in avcC box the same?
I think this question may equal to "are the values in avcC box affected by other FFmpeg library or other layers in overall Android framework"?
++ there is one more question! Is there any case that two videos which have same resolution from the same smartphone have different values in avcC box? (I suggest the the difference of encoding option originating from low-battery mode, execution conditions of other apps, etc and if any core developer customize FFmpeg for that.)
It would be a great help if anyone let me know the answer~!
the avcC box contains the out of band extradata for the AVC stream. This stores way more than just resolution, such as profile, level, entropy encoding mode, color space information, etc. This is a standard, ffmpeg just implements that standard. iPhones for example produce perfectly valid mp4 file and do not use libav* / ffmpeg. See exactly what is is the avcC box here Possible Locations for Sequence/Picture Parameter Set(s) for H.264 Stream

avformat_write_header produces invalid header (resulting MPG broken)

I am rendering a video file from input pictures that come from a 3D engine at runtime (I don't pass an actual picture file, just RGB memory).
This works perfectly when outputting MP4 using CODEC_ID_H264 as video codec.
But when I want to create an MPG file using CODEC_ID_MPEG2VIDEO, the resulting file is simply broken. No player can play the video correctly and when I then want to concatenate that MPG with another MPG file, and transform the result MP4 in another step, the resulting .mp4 file has both videos, but many frames from the original MPG video (and only video! Sound works fine) are simply skipped.
At first I thought the MPG -> MP4 conversion was the problem, but then I noticed that the initial MPG, which comes from the video render engine, is already broken, which would speak for broken headers. Not sure if it is the system or sequence headers that are broken, though.
Or if it could be something totally different.
If you want to have a look, here is the file:
http://www.file-upload.net/download-7093306/broken.mpg.html
Again, the exact same muxing code works perfectly fine when directly creating an MP4 from the video render engine, so I'm pretty sure the input data, swscale(), etc. is correct. The only difference is that CODEC_ID_H264 is used and some additional variables (like qmin, qmax, etc.) are set, which are all specific to H264 so should not have an impact.
Also, neither avformat_write_header nor av_write_trailer report an error.
As an additional info, when viewing the codec data of the MPG in VLC player, it is not able to show the FPS, resolution and format (should show 640x360, 30 fps and 4:2:0 YUV).
I am using a rather new (2-3 months old, maybe) FFmpeg version, which I compiled from sources with MinGW.
Any ideas on how to resolve this would be welcome. Currently, I am out of those :)
Alright, the problem was not the avformat_write_header, but that I did not set the PTS value of each written video packet to AV_NOPTS_VALUE.
Once I do set it for each video packet, everything works fine.
I assumed that AV_NOPTS_VALUE was the default, as I never needed to set any special PTS value.

How to get the MJPEG stream from a NC541 camera?

I have an NC541 IP camera, which supposedly does have an MJPEG stream, as in the manual it says "The video is compressed by MJPEG", but I can not find a way of how to get that stream from the camera. Seems that it wants to work only with the build-in program, while I need the way mjpeg stream instead.
Any ideas? Thanks!
I don't have this camera, but on many you can simply right click on the video window in your browser, select properties, and it will tell you the URL of the raw stream. If this is a multi codec camera you may or may not get the mjpeg stream depending on which one is chosen for the camera's home page. This often works for me.

Resources