3
$\begingroup$

I am trying to visualize a short recording of an insect, using a WAV file, using the scrolling_spectro command in the R package dynaSpec. the MP4 file is being created, but with no video and only audio in it. I have tried opening it in VLC and in chrome, and the video is not there. The problem is not with my WAV file, as it is the same when trying to use the example files that come with the package (e.g. the code for "canyon_wren" provided here: https://marce10.github.io/dynaSpec/). Any idea what might be causing it?

Thanks

$\endgroup$
0

2 Answers 2

2
$\begingroup$

This seems to be a known issue

see: https://github.com/maRce10/dynaSpec/issues/15

which is a 1 year old issue.

Comment: removed previous observations replacing them by the following

I tested the ffmpeg using tiff files created in python (jupyter notebook) and in R (R-Studio)

Here are the two code snippets

Python:

import numpy as np
import matplotlib.pyplot as plt

xx=np.arange(100)
for ii in range(300):
    plt.clf()
    plt.plot(xx,np.sin(2*np.pi*(xx+ii)/100))
    plt.savefig(f"movie/{ii:05}_test.tiff",)
    #plt.show()

R:

x=seq(-pi,pi,0.1)

for(ii in 1:300)
{
  fname <- sprintf("movie/%05d_test.tiff",ii)
  tiff(fname, units="in", width=5, height=5, res=100)
  
  y=sin(x+ii/10)
  plot(x,y)
  
  dev.off()  
}

Moving to the *.tiff folder and executing

ffmpeg -framerate 50 -i ./%05d_test.tiff -y test.mp4

produces correct the mp4 file for python-generated files but fails for R-generated files

Conclusion: ffmpeg seems to work fine, but the tiff files differ.

I futher checked the content of the tiff files (using HxD) and it turned out that the header of the Python-generated files are much longer (about 206 bytes) than the header of the R-generated files (about 8 bytes). The R-generated tiff file has a trailer of about 184 bytes, while the python generated file has no trailer.

It is clear that R-generated tiff files differ from Python-generated tiff files and that the ffmpeg code has difficulties with the R-generated tiff files.

For the record: following Python Jupyter Notepad cell also works (windows 11 without cmd.exe)

import os
os.environ.update(comspec="powershell.exe")

!ffmpeg "-framerate 50 -i ./movie/%05d_test.tiff  -y ./movie/test.mp4"
$\endgroup$
1
  • $\begingroup$ Thanks, I guess this is completely out of my knowledge level to try and fix it. I am entirely unfamiliar with Python and only a novice with R. I will take the simple solution of just "recording the screen" to create those dynamic spectrograms. Best regards $\endgroup$
    – leafhooper
    Commented Oct 27, 2023 at 14:17
2
$\begingroup$

The bug is already fixed. That said, many of the issues are related to not finding (not having installed?) external dependencies. So a convenient alternative is to use a google colab to make the videos. This google colab notebook shows step-by-step how to do that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.