<p>You need to convert the codec used to encode the video to something that the players you are trying to use support. MPlayer supports a wider range of codecs than many players.</p>

<p>To allow you to view the video in other players you need to transcode the video using an application like ffmpeg. The command below will provide the conversion you need:</p>

<pre><code>ffmpeg -i foo.264 -c:a aac -c:v libx264 -preset medium foo.mp4
</code></pre>

<ul>
<li><strong>i</strong> - input file</li>
<li><strong>c:a</strong> - set audio codec to transcode to. Here I chose AAC</li>
<li><strong>c:v</strong> - set video codec to transcode to. libx264 is used to transcode to H.264, one of the most common and widely used video codecs. Most players should be able to play files encoded with H.264.</li>
<li><strong>preset</strong> - used to quickly define the H.264 encoding parameters. Choose from ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. There is obviously a trade-off between quality and transcode speed here.</li>
</ul>

<p>After running this command I could play the video you uploaded in QuickTime on OS X.</p>

<hr>

<p>If you use -copy or don't specify a codec, then ffmpeg will use the same codec as the source. So the command</p>

<pre><code>ffmpeg -f h264 -i foo.264 -c copy foo.mp4
</code></pre>

<p>Will change the container around the video to mp4, but not the video encoding itself. You can read more about the difference between containers and codecs <a href="http://www.techhive.com/article/213612/all_about_video_codecs_and_containers.html" rel="nofollow">here</a>.</p>

CC BY-SA 3.0
2016-05-18T11:15:38.577Z
2016-05-18T12:18:08.927Z
2016-05-18T12:18:08.927Z
James Goodhand
<p>The information realted to input files seems perfectly fine. Can you share the file or file link here. I will experiment with it and update you about the results.</p>

CC BY-SA 3.0
2016-05-18T06:50:11.857Z
The file is available from the following URL: [ https://drive.google.com/file/d/0B0ej35Mor2U-d1NNMFNoZUhuNU0/view?usp=sharing ]
EricVonB
CC BY-SA 3.0
2016-05-18T04:13:47.150Z
2016-05-18T04:13:47.150Z
Raju
<p>You should just be able to place it in a MP4</p>

<pre><code>ffmpeg -i foo.264 -c copy foo.mp4
</code></pre>

<p>Maybe if they don't detect the format, then</p>

<pre><code>ffmpeg -f h264 -i foo.264 -c copy foo.mp4
</code></pre>

CC BY-SA 3.0
2016-05-18T06:44:28.653Z
I ran the second command. Then when I tried to play the output file in Ubuntu Videos app I got the following error message: "An error occurred  GStreamer encountered a general stream error." 

Here is the output of [mediainfo ~/somePath/foo.mp4]:
General;
Complete name : ~/somePath/foo.mp4;
Format : MPEG-4;
Format profile : Base Media;
Codec ID : isom;
File size : 79.2 MiB;
Duration : 18mn 1s;
Overall bit rate : 614 Kbps;
Encoded date : UTC 1904-01-01 00:00:00;
Tagged date : UTC 1904-01-01 00:00:00;
Writing application : Lavf57.29.101;

... _continues_ ...
EricVonB
CC BY-SA 3.0
2016-05-18T06:48:02.390Z
... _continued_ ...
Video;
ID : 1;
Format : AVC;
Format/Info : Advanced Video Codec;
Codec ID : avc1;
Codec ID/Info : Advanced Video Coding;
Duration : 18mn 1s;
Bit rate : 614 Kbps;
Width : 352 pixels;
Height : 240 pixels;
Display aspect ratio : 3:2;
Frame rate mode : Constant;
Frame rate : 25.000 fps;
Bits/(Pixel*Frame) : 0.291;
Stream size : 79.1 MiB (100%);
Encoded date : UTC 1904-01-01 00:00:00;
Tagged date : UTC 1904-01-01 00:00:00
EricVonB
CC BY-SA 3.0
2016-05-18T07:03:43.453Z
The source is not a standard-compliant file. If you run `ffmpeg -i foo.264 foo.mp4` with a recent version of ffmpeg, it will throw some errors but produce a mostly intact generic MP4.
Gyan
CC BY-SA 3.0
2016-05-18T05:00:58.820Z
2016-05-18T05:00:58.820Z
Gyan
<p>I have a file called ~/somePath/foo.264, containing video from a surveillance camera's DVR. I am unable to view this video on several media players including the default media player on an Apple tablet and the Ubuntu Videos application. I am able to view it using MPlayer on Linux. How can I transform the video in this file to something that is more universally useable? I tried the following command at Linux terminal:</p>
<blockquote>
<p>avconv -i ~/somePath/foo.264 -vcodec libx264 -f mp4 ~/somePath/foo.mp4</p>
</blockquote>
<p>but the output mp4 file was basically empty, with a total size of 285 bytes. The source file, foo.264, is 80 MB.
Maybe I need to re-encode the video; maybe I need to place the video into a container of another format; or maybe the solution is something else. I am a novice at audio-video editing, but I am slightly more experience at Linux operating system.</p>
<p>PS. When I do the command</p>
<blockquote>
<p>mediainfo ~/somePath/foo.264</p>
</blockquote>
<p>from linux terminal I receive the following output:</p>
<blockquote>
<p>General</p>
<p>Complete name: ~/somePath/foo.264</p>
<p>Format                                   : AVC</p>
<p>Format/Info                              : Advanced Video Codec</p>
<p>File size                                : 79.1 MiB</p>
<p>Video</p>
<p>Format                                   : AVC</p>
<p>Format/Info                              : Advanced Video Codec</p>
<p>Format profile                           : Baseline@L2</p>
<p>Format settings, CABAC                   : No</p>
<p>Format settings, ReFrames                : 2 frames</p>
<p>Format settings, GOP                     : M=1, N=30</p>
<p>Width                                    : 352 pixels</p>
<p>Height                                   : 240 pixels</p>
<p>Display aspect ratio                     : 3:2</p>
<p>Color space                              : YUV</p>
<p>Chroma subsampling                       : 4:2:0</p>
<p>Bit depth                                : 8 bits</p>
<p>Scan type                                : Progressive</p>
</blockquote>
<p>PPS. I have already posed a related question, <a href="https://unix.stackexchange.com/questions/283548/convert-264-to-mp4-using-avconv">https://unix.stackexchange.com/questions/283548/convert-264-to-mp4-using-avconv</a> , on the Unix &amp; Linux Stackexchange.</p>

<encoding><avconv>
Modify video file for viewing in generic media player
EricVonB
# Modify video file for viewing in generic media player

(Asked by: username_0 on 2016-05-18)

I have a file called ~/somePath/foo.264, containing video from a surveillance camera's DVR. I am unable to view this video on several media players including the default media player on an Apple tablet and the Ubuntu Videos application. I am able to view it using MPlayer on Linux. How can I transform the video in this file to something that is more universally useable? I tried the following command at Linux terminal:

> avconv -i ~/somePath/foo.264 -vcodec libx264 -f mp4 ~/somePath/foo.mp4

but the output mp4 file was basically empty, with a total size of 285 bytes. The source file, foo.264, is 80 MB.
Maybe I need to re-encode the video; maybe I need to place the video into a container of another format; or maybe the solution is something else. I am a novice at audio-video editing, but I am slightly more experience at Linux operating system.

PS. When I do the command

> mediainfo ~/somePath/foo.264

from linux terminal I receive the following output:

> General
>
> Complete name: ~/somePath/foo.264
>
> Format : AVC
>
> Format/Info : Advanced Video Codec
>
> File size : 79.1 MiB
>
> Video
>
> Format : AVC
>
> Format/Info : Advanced Video Codec
>
> Format profile : Baseline@L2
>
> Format settings, CABAC : No
>
> Format settings, ReFrames : 2 frames
>
> Format settings, GOP : M=1, N=30
>
> Width : 352 pixels
>
> Height : 240 pixels
>
> Display aspect ratio : 3:2
>
> Color space : YUV
>
> Chroma subsampling : 4:2:0
>
> Bit depth : 8 bits
>
> Scan type : Progressive

PPS. I have already posed a related question, <https://unix.stackexchange.com/questions/283548/convert-264-to-mp4-using-avconv> , on the Unix & Linux Stackexchange.

**Tags:** encoding, avconv


---

## 3 answers

### Answer by username_1 on 2016-05-18. Score: 1 | Accepted answer

You need to convert the codec used to encode the video to something that the players you are trying to use support. MPlayer supports a wider range of codecs than many players.
To allow you to view the video in other players you need to transcode the video using an application like ffmpeg. The command below will provide the conversion you need:
ffmpeg -i foo.264 -c:a aac -c:v libx264 -preset medium foo.mp4


i - input file
c:a - set audio codec to transcode to. Here I chose AAC
c:v - set video codec to transcode to. libx264 is used to transcode to H.264, one of the most common and widely used video codecs. Most players should be able to play files encoded with H.264.
preset - used to quickly define the H.264 encoding parameters. Choose from ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. There is obviously a trade-off between quality and transcode speed here.

After running this command I could play the video you uploaded in QuickTime on OS X.

If you use -copy or don't specify a codec, then ffmpeg will use the same codec as the source. So the command
ffmpeg -f h264 -i foo.264 -c copy foo.mp4

Will change the container around the video to mp4, but not the video encoding itself. You can read more about the difference between containers and codecs here.


---

### Answer by username_2 on 2016-05-18. Score: 0

The information realted to input files seems perfectly fine. Can you share the file or file link here. I will experiment with it and update you about the results.

> **Comments:**
> **username_0**: The file is available from the following URL: [ https://drive.google.com/file/d/0B0ej35Mor2U-d1NNMFNoZUhuNU0/view?usp=sharing ]  

---

### Answer by username_3 on 2016-05-18. Score: 0

You should just be able to place it in a MP4
ffmpeg -i foo.264 -c copy foo.mp4

Maybe if they don't detect the format, then
ffmpeg -f h264 -i foo.264 -c copy foo.mp4

> **Comments:**
> **username_0**: I ran the second command. Then when I tried to play the output file in Ubuntu Videos app I got the following error message: "An error occurred  GStreamer encountered a general stream error."   Here is the output of [mediainfo ~/somePath/foo.mp4]: General; Complete name : ~/somePath/foo.mp4; Format : MPEG-4; Format profile : Base Media; Codec ID : isom; File size : 79.2 MiB; Duration : 18mn 1s; Overall bit rate : 614 Kbps; Encoded date : UTC 1904-01-01 00:00:00; Tagged date : UTC 1904-01-01 00:00:00; Writing application : Lavf57.29.101;  ... _continues_ ...  
> **username_0**: ... _continued_ ... Video; ID : 1; Format : AVC; Format/Info : Advanced Video Codec; Codec ID : avc1; Codec ID/Info : Advanced Video Coding; Duration : 18mn 1s; Bit rate : 614 Kbps; Width : 352 pixels; Height : 240 pixels; Display aspect ratio : 3:2; Frame rate mode : Constant; Frame rate : 25.000 fps; Bits/(Pixel*Frame) : 0.291; Stream size : 79.1 MiB (100%); Encoded date : UTC 1904-01-01 00:00:00; Tagged date : UTC 1904-01-01 00:00:00  
> **username_3**: The source is not a standard-compliant file. If you run `ffmpeg -i foo.264 foo.mp4` with a recent version of ffmpeg, it will throw some errors but produce a mostly intact generic MP4.  

---

