<p>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. <a href="https://colab.research.google.com/drive/1t3Wn9OifcZTvxOMVNmz9dF25vnzU3_Fr?usp=sharing" rel="nofollow noreferrer">This google colab notebook</a> shows step-by-step how to do that.</p>

CC BY-SA 4.0
2024-02-05T15:55:55.020Z
2024-02-06T17:13:35.103Z
2024-02-06T17:13:35.103Z
Marcelo Araya-Salas
<p>This seems to be a known issue</p>
<p>see: <a href="https://github.com/maRce10/dynaSpec/issues/15" rel="nofollow noreferrer">https://github.com/maRce10/dynaSpec/issues/15</a></p>
<p>which is a 1 year old issue.</p>
<p><strong>Comment</strong>: <em>removed previous observations replacing them by the following</em></p>
<p>I tested the ffmpeg using tiff files created in python (jupyter notebook) and in R (R-Studio)</p>
<p>Here are the two code snippets</p>
<p>Python:</p>
<pre><code>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&quot;movie/{ii:05}_test.tiff&quot;,)
    #plt.show()
</code></pre>
<p>R:</p>
<pre><code>x=seq(-pi,pi,0.1)

for(ii in 1:300)
{
  fname &lt;- sprintf(&quot;movie/%05d_test.tiff&quot;,ii)
  tiff(fname, units=&quot;in&quot;, width=5, height=5, res=100)
  
  y=sin(x+ii/10)
  plot(x,y)
  
  dev.off()  
}
</code></pre>
<p>Moving to the *.tiff folder and executing</p>
<pre><code>ffmpeg -framerate 50 -i ./%05d_test.tiff -y test.mp4
</code></pre>
<p>produces correct the mp4 file for python-generated files but fails for R-generated files</p>
<p>Conclusion: ffmpeg seems to work fine, but the tiff files differ.</p>
<p>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.</p>
<p>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.</p>
<p>For the record: following Python Jupyter Notepad cell also works (windows 11 without cmd.exe)</p>
<pre><code>import os
os.environ.update(comspec=&quot;powershell.exe&quot;)

!ffmpeg &quot;-framerate 50 -i ./movie/%05d_test.tiff  -y ./movie/test.mp4&quot;
</code></pre>

CC BY-SA 4.0
2023-10-27T14:17:30.260Z
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
leafhooper
CC BY-SA 4.0
2023-10-22T16:41:40.257Z
2023-10-23T15:12:25.107Z
2023-10-23T15:12:25.107Z
WMXZ
<p>I am trying to visualize a short recording of an insect, using a WAV file, using the <code>scrolling_spectro</code> command in the R package <code>dynaSpec</code>. 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 &quot;canyon_wren&quot; provided here: <a href="https://marce10.github.io/dynaSpec/" rel="nofollow noreferrer">https://marce10.github.io/dynaSpec/</a>).
Any idea what might be causing it?</p>
<p>Thanks</p>

<r><spectrogram><audio>
dynaSpec R package is creating an MP4 file with only audio and no video
# dynaSpec R package is creating an MP4 file with only audio and no video

(Asked by: username_0 on 2023-10-21)

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

**Tags:** r, spectrogram, audio


---

## 2 answers

### Answer by username_1 on 2024-02-05. Score: 2

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](https://colab.research.google.com/drive/1t3Wn9OifcZTvxOMVNmz9dF25vnzU3_Fr?usp=sharing) shows step-by-step how to do that.


---

### Answer by username_2 on 2023-10-22. Score: 2

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"

```

> **Comments:**
> **username_0**: 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  

---

