Giter Site home page Giter Site logo

pl_mpeg's People

Contributors

crudelios avatar cw-b-w avatar jrdennisoss avatar phoboslab avatar ricop avatar sridenour avatar stapelberg avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pl_mpeg's Issues

Corrupt decoding :(

Hi,
I was looking forward to using this in a m.a.m.e. project but for some reason it doesn't correctly decode the mpg files I've got.
The files are OK, they play with vlc and all other players I've tried including a hardware decoder :(
The decoded data is wrong from frame one :(
I've absolutely no idea how to fault finding on this :(
I've many files all with similar problems. This is the first frame from a file here.
https://drive.google.com/file/d/1_wrjTUzgTOf9hCEqX-G6tlmaoBSp1I2_/view?usp=sharing
000001

Anyone any suggestions or ideas ? Any help is really appreciated.
Thanks
Paul

Segfault found by AFL

For fun I ran american fuzzy lop against this. Here's an MPEG that segfaults when pl_mpeg_extract_frames is run on it. Looks like a wild pointer dereference.

bad.mpg.gz

Corrupted video on GBA

Hello, great library. I am attempting to play a video on the GBA the library compiles fine with devkitpro. However everything decoded is corrupted. For example, my first frame should be completely black. But when grabbing a frame with the library on the gameboy advance it has randomish characters like 7e 6e 0f 0f 00 44 44 FF FF FF instead of being 0's. I can send the project to an email or upload here if interested. It would be awesome if you were. I did verify the same code on windows works. So I know it's GBA specific just not sure what.

Thanks!

Using mini_audio to play the audio?

I noticed that the example uses SDL2, which lets you "push" audio, I don't think miniaudio supports this - any way to allow miniaudio to pull the required pcm frames from the audio as it needs?

Streaming from the net introduces latency or requires separate thread

When feeding a plm_buffer() from the network (or slow media) there's no way to tell the buffer that no data is available at this time, but may be available later.

This forces you to either only decode a frame whenever you are sure that the data for the whole frame is available (as the video decoder can't pause in the middle of a frame) or to run the decoder in a separate thread and busy wait in the plm_buffer_callback until more data is available.

Making sure that enough data is available for decoding a full frame is not straight forward, because we don't know the size of a frame until it has been fully decoded, or we find the PICTURE_START code of the next frame. This introduces unnecessary latency for streaming.

The problem is described in more detail in this blog post towards the end.

This issue is meant for discussion of the problem and possible solutions.

sfml + pl_mpeg

Does anyone know of any examples of using pl_mpeg with SFML?

Corrupted video

When playing video sometimes I get corrupt blocks on the right hand side.
When played in VLC media player it is not corrupted.

See example here:
image

Source file here:
https://www.mdawson.net/files/termcrop.mpg

Frame number 980
I wonder if it's something to do with certain motion blocks on the right hand side?

(Minor suggestion) Compiler warnings

Lines 1187 and 1872 involve an assignment within a conditional. Some compilers complain about this. Easy fix: explicitly adding "!= 0" in each conditional appears to work equivalently and silences the warnings.

Small encoder lib suggestions?

Thanks a lot for doing this!! This lets me use video in my apps without the hassle of gigantic libs dependencies!

Now the only open question is... how can I encode too, without depending on FFmpeg? I searched and found some possibilities, like ezMPEG, or jo_mpeg, but, it seems neither of them support P frames, so they encode every frame as an independent image (I frame), and besides, they don't encode audio either...

Do you have any recommendation for a small (yet with reasonable quality) MPEG1 encoder with audio that would work with your decoder?

Custom malloc/realloc/free and disable stdlib

Sometimes we don't have access to the standard library, and/or we want to use custom allocation functions. Thus, it would make sense to add in some defines that can be set by the user of the library before the header is included. These would define memory allocation functions. There will also be a define that controls whether stdio is used, and also remove the *_create_with_file functions to prevent compilation errors.
stb_image is an example implementation of this.
Of course, it would be trivial for the user to manually modify the source code, and the license is permissive enough. However, it is better to have this be done in a well-defined manner, signed off by someone who has a more intimate knowledge of the code, and therefore is less likely to make mistakes than some impatient newbie running %s/malloc/my_malloc.

Any chance of a seek API?

I'm using this library with raylib to play MPEG files, it works flawlessly! In under 150 lines of C I got a nice video player!

Just wondering if there is any plan to add a frame/sample seek API. It would be really great.

(I can keep decoding frames/samples to implement a seek mechanism but it seems a bit inefficient)

EDIT: Just created a function to get video length but it's extremely inefficient, it takes up to 10 seconds on my system. I can probably execute it in a second thread while starting playing the video in main thread... but... any better idea to get video length?

int plm_get_total_frames(const char *filename)
{
    int total_frames = 0;
    
    plm_t *plm = plm_create_with_filename(filename);

    if (plm != NULL)
    {
        plm_frame_t *frame = plm_decode_video(plm);
        while (frame != NULL)
        {
            total_frames++;
            frame = plm_decode_video(plm);
        }

        plm_destroy(plm);
    }

    return total_frames;
}

Modify public struct typedefs to enable fwd declaration in C++

It would be helpful to change

typedef struct {
...
} plm_frame_t;

into

typedef struct plm_frame_t {
...
} plm_frame_t;

This would make it easier to forward-declare the structs in a C++ header without including pl_mpeg.h from there, exposing it to the rest of the program.

Example my.hpp:

struct plm_frame_t; // trying to not include pl_mpeg.h here

class MyClass {
public:
    void render( plm_frame_t *frame );
};

Example my.cpp:

#include "my.hpp"
#define PL_MPEG_IMPLEMENTATION
#include "pl_mpeg.h"

MyClass::render( plm_frame_t *frame ) {
...
}

Duplicate lines in plm_buffer_has method

There seem to be some duplicate lines in plm_buffer_has method:

int plm_buffer_has(plm_buffer_t *self, size_t count) {
	if (((self->length << 3) - self->bit_index) >= count) {
		return TRUE;
	}

	if (self->load_callback) {
		self->load_callback(self, self->load_callback_user_data);
	}

	if (((self->length << 3) - self->bit_index) >= count) {
		return TRUE;
	}
	
	if (self->total_size != 0 && self->length == self->total_size) {
		self->has_ended = TRUE;
	}
	return FALSE;
}

Green rectangles when decoding

I'm porting pl_mpeg_player.c to GLFW and it decodes smoothly and accurately, except for these rectangles which appear in the areas of the video which are updating. (The colors are accurate where there is no movement.)

I'm hoping that someone knows at a glance what I'm doing wrong. Is there a step that, when skipped, results in these artifacts? The same artifacting appears regardless of whether I'm using the three-texture YCRCB approach or the one-texture RGB approach; they work equally well and give the same result.

I'd like to thank the creator for his hard work; this is a fantastic library with a ton of utility for creators such as myself.
2021-09-24 15_51_41-WIP
2021-09-24 17_19_45-WIP

pl_mpeg + physfs = possible?

Hi, I'm looking around for a video playback solution and considering pl_mpeg. Can it be made to work with physfs?? I'm currently using physfs to load resources from a zip archive, so I need to be able to also play the videos from this archive as well. At present I don't see a way to easily do it. Maybe I've overlooked something, please advise.

Thanks

Jarrod

Decode slice macroblock loop condition may be incorrect

When looping to decode macroblocks you call plm_buffer_no_start_code, which is an aligned check for no start code.
I think this can lose undecoded bits in the stream. In the spec it seems they do an unaligned bitcheck for 23 0's.
I believe if there were no more macroblocks and the stream wasn't aligned it would be padded with 0's.
What do you think?

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.