Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLC will not play an h264 file the first attemp, but either plays the second attempt or plays twice on the second attempt ... #95

Open
lmitcham opened this issue Dec 8, 2023 · 0 comments

Comments

@lmitcham
Copy link

lmitcham commented Dec 8, 2023

I am developing on a Raspberry Pi Zero 2W under Bullseye OS. I am capturing video off of a Pi HQ camera at 1080p to an h264 video file using Picamera2 and the circular buffer function.

The first time I attempt to playback my video using vlc, the video will sporadically not play at all, even though the log output indicates that it did play. However, the second attempt to play the video is successful and will sometimes play the video twice.

This is my code snippet to play a single h264 video file that is 2.5 seconds:

    if LOG_MSG == 1: 
        do_log("Display Video Start TIME: " + str( DisplayVideoStartTime ))

    if LOG_MSG == 1: do_log( "[STOPBV] Close CAMERA" ) 
    CAMERA.stop_recording()
    CAMERA.close()

    instance = vlc.Instance("--verbose=0","--no-xlib","--vout=mmal_vout")
    media_list = instance.media_list_new([video_file])
    list_player = instance.media_list_player_new()
    list_player.set_media_list(media_list)

    if LOG_MSG == 1: do_log('    Video Found')

    if LOG_MSG == 1: 
        do_log("Display Video TIME (IN SECONDS): " + str( (dt.datetime.now() - DisplayVideoStartTime ).total_seconds() ))

    list_player.play()
    if LOG_MSG == 1: do_log('        Play')
    
    list_player.pause()
    if LOG_MSG == 1: do_log('        Pause')
    time.sleep( 0.1 )
    list_player.play()
    if LOG_MSG == 1: do_log('        Play')
   
    time.sleep(TriggerOnTime.seconds + (TriggerOnTime.microseconds / 1000000) + 1)

    list_player.stop()
    if LOG_MSG == 1: do_log('        Stop')
    time.sleep( 1 )
       
    if LOG_MSG == 1: do_log('    End of Video')

and here is the diagnostic output :

First try did not display a video ...

2023-12-08 12:59:10,569 - Display Video Start TIME: 2023-12-08 12:59:10.569063
2023-12-08 12:59:10,570 - [STOPBV] Close CAMERA
2023-12-08 12:59:10,616 - Execute job: <picamera2.job.Job object at 0x627809b8>
2023-12-08 12:59:10,627 - Camera stopped
2023-12-08 12:59:10,830 - Camera was not started
2023-12-08 12:59:11,029 - Camera closed successfully.
2023-12-08 12:59:11,270 - Video Found
2023-12-08 12:59:11,272 - Display Video TIME (IN SECONDS): 0.702867
2023-12-08 12:59:11,273 - Play
2023-12-08 12:59:11,277 - Pause
2023-12-08 12:59:11,379 - Play
2023-12-08 12:59:16,949 - Stop
2023-12-08 12:59:17,952 - End of Video

second try did display a video:

2023-12-08 13:00:01,058 - Display Video Start TIME: 2023-12-08 13:00:01.058117
2023-12-08 13:00:01,059 - [STOPBV] Close CAMERA
2023-12-08 13:00:01,081 - Execute job: <picamera2.job.Job object at 0x62fea958>
2023-12-08 13:00:01,095 - Camera stopped
2023-12-08 13:00:01,297 - Camera was not started
2023-12-08 13:00:01,497 - Camera closed successfully.
2023-12-08 13:00:01,620 - Video Found
2023-12-08 13:00:01,621 - Display Video TIME (IN SECONDS): 0.563051
2023-12-08 13:00:01,622 - Play
2023-12-08 13:00:01,623 - Pause
2023-12-08 13:00:01,724 - Play
2023-12-08 13:00:05,205 - Stop
2023-12-08 13:00:06,207 - End of Video

Note that the time between play and stop in the first attempt was 5.57 seconds, while the second attempt was 3.481 seconds.

Also note that the same h264 file plays flawlessly on a Windows PC using MediaPlayerLite version 0.5.4.

Any thoughts on the difference in "play" time and the unsuccessful first attempt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant