ammen99 / wf-recorder

MIT License
872 stars 63 forks source link

All recorded videos appear to be corrupt (?) #152

Closed Hubro closed 11 months ago

Hubro commented 3 years ago

I record videos with this script:

#!/bin/bash

# Convenience script for recording under sway

if [[ -z "$1" ]]; then
    echo "Fatal error: First argument must be the recording destionation" >&2
    exit 1
fi

wf-recorder \
    -g "$(slurp-window)" \
    -c libx264rgb \
    -p "tune=animation" \
    -p "preset=faster" \
    -p "crf=14" \
    --audio="alsa_output.pci-0000_11_00.4.analog-stereo.monitor" \
    --file "$1"

The resulting video plays well with mpv and VLC, but if I try to embed it in a browser it doesn't work:

https://user-images.githubusercontent.com/597206/119030219-e3f49280-b9a9-11eb-8ca7-cce5924f6111.mp4

If I try to open the file in Avidemux to re-encode it, all it shows is a green box:

image

Does anybody else have this issue? Is it an issue with wf-recorder or with my ffmpeg parameters?

ghost commented 3 years ago

i have simillar problem: when i record video from terminal, it plays fine everywhere. but when i record it with sway keybind (bindsym), it doesnt play anywhewre

ammen99 commented 3 years ago

i have simillar problem: when i record video from terminal, it plays fine everywhere. but when i record it with sway keybind (bindsym), it doesnt play anywhewre

Do you send SIGINT to stop the recording?

Hubro commented 3 years ago

i have simillar problem: when i record video from terminal, it plays fine everywhere. but when i record it with sway keybind (bindsym), it doesnt play anywhewre

Do you send SIGINT to stop the recording?

I just press Ctrl+C, as I thought was the intended way 🤔

ammen99 commented 3 years ago

I just press Ctrl+C, as I thought was the intended way

Yes, this is the intended way. Ctrl+C == SIGINT :)

I am unfortunately not sure what is causing your original issue, just thought that maybe @SNvMK has a different issue where they haven't set up the stop binding properly (for ex. killing with -9)

ghost commented 3 years ago

i have simillar problem: when i record video from terminal, it plays fine everywhere. but when i record it with sway keybind (bindsym), it doesnt play anywhewre

Do you send SIGINT to stop the recording?

i just doing exec killall wf-recorder. do i do something other?

ammen99 commented 3 years ago

i just doing exec killall wf-recorder. do i do something other?

Yes, you're sending SIGTERM. Try killall -SIGINT wf-recorder

AtifChy commented 3 years ago

I record videos with this script:

#!/bin/bash

# Convenience script for recording under sway

if [[ -z "$1" ]]; then
    echo "Fatal error: First argument must be the recording destionation" >&2
    exit 1
fi

wf-recorder \
    -g "$(slurp-window)" \
    -c libx264rgb \
    -p "tune=animation" \
    -p "preset=faster" \
    -p "crf=14" \
    --audio="alsa_output.pci-0000_11_00.4.analog-stereo.monitor" \
    --file "$1"

The resulting video plays well with mpv and VLC, but if I try to embed it in a browser it doesn't work: test.mp4

If I try to open the file in Avidemux to re-encode it, all it shows is a green box:

image

Does anybody else have this issue? Is it an issue with wf-recorder or with my ffmpeg parameters?

wf-recorder || pkill -SIGINT $(pgrep wf-recorder) put this at the end of your script

AtifChy commented 3 years ago

trap "pkill -INT wf-recorder" INT pulling this before the wf-recorder command also does the job.

paul-ri commented 2 years ago

I'm getting a similar problem where plain wf-recorder (v0.3.0) produces a recording that is said to be corrupted on GitHub or "not compatible" on WhatsApp.

[...]

[00007fad40840b80] chain filter error: Too high level of recursion (3) [00007fad40828dc0] main filter error: Failed to create video converter [00007fad4080c090] main filter error: Failed to create video converter [00007fad400013c0] main vout display error: Failed to create video converter [00007fad400013c0] main vout display error: Failed to adapt decoder format to display [00007fad3c0ac5e0] main video output error: video output creation failed [00007fad58c15700] main decoder error: failed to create video output [00007fad4080d0a0] gl gl: Initialized libplacebo v4.192.1 (API v192)

- Installing version 0.2.1 of wf-recorder works: WhatsApp accepts to display the video
  - With that version, VLC logs are different

❯ vlc recording.mp4 VLC media player 3.0.17.4 Vetinari (revision 3.0.13-8-g41878ff4f2) [000055b222169580] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. [00007f4d14007940] gl gl: Initialized libplacebo v4.192.1 (API v192) libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) [00007f4d14007940] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error [00007f4d14007940] glconv_vaapi_drm gl error: vaInitialize: unknown libva error [00007f4d14007940] glconv_vaapi_drm gl error: vaInitialize: unknown libva error [00007f4d1481cbf0] gl gl: Initialized libplacebo v4.192.1 (API v192) Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory [00007f4d1481cbf0] gl gl: Initialized libplacebo v4.192.1 (API v192) [h264 @ 0x7f4d34d0b780] get_buffer() failed [h264 @ 0x7f4d34d0b780] thread_get_buffer() failed [h264 @ 0x7f4d34d0b780] decode_slice_header error [h264 @ 0x7f4d34d0b780] get_buffer() failed [h264 @ 0x7f4d34d0b780] thread_get_buffer() failed [h264 @ 0x7f4d34d0b780] decode_slice_header error [h264 @ 0x7f4d34d0b780] get_buffer() failed [...]



I tried to compile previous commit versions to find a culprit but getting build issues and failing to cherry-pick 47a3905f670fe12ecbdfe4719df654df1cd183e2 on older commits (I've not put much effort after that)

This is on Arch Linux with sway wm. 
paul-ri commented 2 years ago

Well, rubber duck debugging effect: that made me search for codec options; and the following fixed it:

  -t, --force-yuv           Use the -t or --force-yuv option to force conversion of the data to
                            yuv format, before sending it to the gpu.

Hopefully that helps someone else in the same situation!

mohamad-supangat commented 2 years ago

https://user-images.githubusercontent.com/48933993/176851454-e5f9b43e-da54-4b14-a68a-04955751665f.mp4

same here using artix linux, how to stop the recording in terminal ??

soreau commented 2 years ago

same here using artix linux, how to stop the recording in terminal ??

Ctrl+C

joanbm commented 2 years ago

When wf-recorder is terminated with a SIGTERM, e.g. by running pkill wf-recorder, it should exit gracefully and correctly closing the recording just like with SIGINT. SIGTERM (as opposed to SIGKILL) indicates a graceful termination (it is described in the glibc guide as "the normal way to politely ask a program to terminate") and is the obvious way to stop a wf-recorder instance running in the background. And perhaps SIGHUP should be handled similarly as well.

aerosol commented 1 year ago

It's now again broken for me with some of the recent updates on Arch/Wayland. --force-yuv worked will, except now all the videos are again corrupt in Firefox. Anyone else?

aerosol commented 1 year ago

This solves it. Sorry for the noise.