Ffmpeg camera from local video file

I am trying to set up the ffmpeg camera with an input from a local video file.

The entity shows up in lovelace with a thumbnail of the video but will not play the video. When i check the logs I see “Error demuxing stream: No dts in packet”

Does the ffmpeg platfrom not support local files?

configuration.yaml

camera:
  - platform: ffmpeg
    name: Bedroom
    input: "/config/www/blink_video/blink_video_bedroom_latest.mp4"
  - platform: ffmpeg
    name: Living Room
    input: "/config/www/blink_video/blink_video_livingroom_latest.mp4"
  - platform: ffmpeg
    name: Kitchen
    input: "/config/www/blink_video/blink_video_kitchen_latest.mp4"

Have you tried the command “camera_view: live” in the lovelace card?


camera_view: live
entity: camera.Kitchen
show_name: false
show_state: false
type: picture-entity

And check if the video’s path is in the whitliste… in your configuration.yaml add:

homeassistant:
 whitelist_external_dirs:
  - /config/www/blink_video

I hope it will help you

I’ll tried this out myself. I used a GoPro clip mp4. Plays fine with QuickTime and Windows Media Player including audio. The HA entity I created is camera.test_video_file.

(Skipping lovelace) I went to the developers tools->state->camera.test_video_file and clicked on the upper left box where one should get a pop up.

If the path/file isn’t configured correctly, the popup just spins, no logs.

When the path/file is configured correctly, video is played in my case (but no audio), AND I also get the same log error as you,

The complaint about “Error demuxing stream: No dts in packet”, would suggest ffmpeg is expecting the encoded video/audio stream to be in a particular format and the file does not meet that format. I ran an ffmpeg analysis on my go pro file, and it had what looks like a minor issue with with the timestamp mid-stream…to where it could analyze the video but it couldn’t analyze the audio.

So to answer your question, ffmpeg can play a local file, it may be the case that it has to be in the right format.

I too have this issue and I have added the additional parameter: -an.
While this worked, however, the video plays only half way then it was stuck.

have you got it working?

I ended up using vlc to create a rtsp stream from the video file and that worked great with the ffmpeg platform and played just fine in lovelace. Below is my solution.

Create a vlc config named vlc_vod_config:

new Bedroom vod enabled
setup Bedroom input "file:///mnt/blink_video/blink_bedroom.mp4"

new Kitchen vod enabled
setup Kitchen input "file:///mnt/blink_video/blink_kitchen.mp4"

new LivingRoom vod enabled
setup LivingRoom input "file:///mnt/blink_video/blink_livingroom.mp4"

run vlc in command line (change password from videolan)

vlc --ttl 3 -vvv --color -I telnet --telnet-password videolan --rtsp-port 5554 

telnet into vlc (port 4212) and run the command to load the config file

load vlc_vod_config

Home Assistant config:

camera:
  - platform: ffmpeg
    name: Living Room
    input: rtsp://10.0.0.220:5554/LivingRoom

lovelace config:

      - entity: camera.living_room
        camera_image: camera.living_room
        aspect_ratio: 50%
        type: picture-entity
1 Like

There is really a bug with playing mp4 files.
I got the same error while the file plays fine in VLC or somewhere else.
This is a serious workaround

I found an easier solution and it refreshes!
See:

Be advised that if anyone is using FireFox to display MP4 videos in LoveLace using this method, that it will only display a small portion of the video. There is a video length header bug fix for this that will be in version .110. Chrome works just fine and plays the video to completion.